Allow /wins swap to move to empty position

This commit is contained in:
James Booth
2014-04-24 23:06:42 +01:00
parent 547b6cf4da
commit e9ddbab585
3 changed files with 23 additions and 2 deletions

View File

@@ -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();

View File

@@ -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;