From 98b3c95a0e8208d8f60f1d87047b3766ffa16608 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 8 Sep 2013 15:18:07 +0200
Subject: [PATCH] Silently ignore characters in config/windows/toggle_order to
 which no window exists.

---
 src/wincontrol.c | 6 +++++-
 src/wincontrol.h | 5 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/wincontrol.c b/src/wincontrol.c
index 487b1fa..582b631 100644
--- a/src/wincontrol.c
+++ b/src/wincontrol.c
@@ -2,7 +2,7 @@
 
 #include "wincontrol.h"
 #include <stdlib.h> /* for free() */
-#include <string.h> /* for strlen() */
+#include <string.h> /* for strlen(), strchr(), strstr() */
 #include <stdint.h> /* for uint8_t, uint16_t */
 #include <stdio.h> /* for fwrite() */
 #include <unistd.h> /* for access(), unlink() */
@@ -382,6 +382,10 @@ extern void sorted_wintoggle(struct World * world)
     uint8_t i = 0;
     for (; i < linemax - 1; i++)
     {
+        if (NULL == strchr(world->winconf_ids, win_order[i]))
+        {
+            continue;
+        }
         toggle_window(world->wmeta, get_win_by_id(world, win_order[i]));
     }
 }
diff --git a/src/wincontrol.h b/src/wincontrol.h
index 6a1021b..e783160 100644
--- a/src/wincontrol.h
+++ b/src/wincontrol.h
@@ -52,8 +52,9 @@ extern void free_wins(struct World * world);
 
 
 /* Toggle windows in world->wins in the order desribed by the first line of
- * config/windows/toggled_win_order, wherein each character may correspond to
- * one hardcoded window.
+ * config/windows/toggled_win_order, wherein each character should correspond to
+ * one window the ID of which is found in world->winconf_ids. Unknown characters
+ * are silently ignored.
  */
 extern void sorted_wintoggle(struct World * world);
 
-- 
2.30.2