diff --git a/src/command/commands.c b/src/command/commands.c index 8a37305a..83fe4322 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -478,6 +478,8 @@ cmd_wins(gchar **args, struct cmd_help_t help) int target_win = atoi(args[2]); if ((source_win == 1) || (target_win == 1)) { cons_show("Cannot move console window."); + } else if (source_win == 10 || target_win == 10) { + cons_show("Window 10 does not exist"); } else if (source_win != target_win) { gboolean swapped = ui_swap_wins(source_win, target_win); if (swapped) { diff --git a/src/ui/core.c b/src/ui/core.c index 3b7789d9..383eafef 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -691,7 +691,6 @@ static gboolean _ui_switch_win(const int i) { if (ui_win_exists(i)) { - ui_current_page_off(); ProfWin *new_current = wins_get_by_num(i); wins_set_current_by_num(i); ui_current_page_off(); 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;