From: Christian Heller Date: Fri, 17 May 2013 00:11:43 +0000 (+0200) Subject: Moved check for existence of active window inside cycle_active_window(). X-Git-Tag: tce~1293 X-Git-Url: https://plomlompom.com/repos/%7B%7Bitem_name%7D%7D?a=commitdiff_plain;h=969ba2899d6abd9d06a187098a5cd015d1aac1e0;p=plomrogue Moved check for existence of active window inside cycle_active_window(). --- diff --git a/roguelike.c b/roguelike.c index e1852ab..4bd6c7e 100644 --- a/roguelike.c +++ b/roguelike.c @@ -474,9 +474,9 @@ int main () { toggle_window(&win_meta, &win_info); else if (key == get_action_key(world.keybindings, "toggle log window")) toggle_window(&win_meta, &win_log); - else if (key == get_action_key(world.keybindings, "cycle forwards") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "cycle forwards")) cycle_active_window(&win_meta, 'n'); - else if (key == get_action_key(world.keybindings, "cycle backwards") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "cycle backwards")) cycle_active_window(&win_meta, 'p'); else if (key == get_action_key(world.keybindings, "shift forwards") && win_meta.active != 0) shift_window(&win_meta, 'f'); diff --git a/windows.c b/windows.c index af66479..77a35b2 100644 --- a/windows.c +++ b/windows.c @@ -198,16 +198,17 @@ void resize_window (struct WinMeta * win_meta, char change) { void cycle_active_window (struct WinMeta * win_meta, char dir) { // Cycle active window selection forwards (dir = 'n') or backwards. - if ('n' == dir) { - if (win_meta->active->next != 0) - win_meta->active = win_meta->active->next; - else - win_meta->active = win_meta->chain_start; } - else { - if (win_meta->active->prev != 0) - win_meta->active = win_meta->active->prev; - else - win_meta->active = win_meta->chain_end; } } + if (0 != win_meta->active) { + if ('n' == dir) { + if (win_meta->active->next != 0) + win_meta->active = win_meta->active->next; + else + win_meta->active = win_meta->chain_start; } + else { + if (win_meta->active->prev != 0) + win_meta->active = win_meta->active->prev; + else + win_meta->active = win_meta->chain_end; } } } void shift_window (struct WinMeta * win_meta, char dir) { // Move active window forward/backward in window chain. If jumping beyond start/end, move to other chain end.