about summary refs log tree commit diff stats
path: root/src/ui/windows.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/windows.c')
-rw-r--r--src/ui/windows.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 48ab9ea8..44639040 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -394,6 +394,7 @@ wins_swap(int source_win, int target_win)
     if (source != NULL) {
         ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
 
+        // target window empty
         if (target == NULL) {
             g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
             status_bar_inactive(source_win);
@@ -407,8 +408,27 @@ wins_swap(int source_win, int target_win)
                 ui_switch_win(1);
             }
             return TRUE;
+
+        // target window occupied
         } else {
-            return FALSE;
+            g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
+            g_hash_table_steal(windows, GINT_TO_POINTER(target_win));
+            g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target);
+            g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
+            if (source->unread > 0) {
+                status_bar_new(target_win);
+            } else {
+                status_bar_active(target_win);
+            }
+            if (target->unread > 0) {
+                status_bar_new(source_win);
+            } else {
+                status_bar_active(source_win);
+            }
+            if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
+                ui_switch_win(1);
+            }
+            return TRUE;
         }
     } else {
         return FALSE;