home · contact · privacy
Moved check for existence of active window inside cycle_active_window().
authorChristian Heller <c.heller@plomlompom.de>
Fri, 17 May 2013 00:11:43 +0000 (02:11 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 17 May 2013 00:11:43 +0000 (02:11 +0200)
roguelike.c
windows.c

index e1852abb0b415f57e33ca26a7c4739dd083e37b0..4bd6c7ee15cdd51dd353ba8bfa424650a2161e59 100644 (file)
@@ -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');
index af6647978a0aa98b2411c6d16e089ef9bcfa99bd..77a35b28556e267a837e59d08c53b4f869db8d08 100644 (file)
--- 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.