]> Pileus Git - wmpus/commitdiff
Fix bugs in wm-tags
authorAndy Spencer <andy753421@gmail.com>
Mon, 10 Oct 2011 07:30:30 +0000 (07:30 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 10 Oct 2011 07:32:13 +0000 (07:32 +0000)
wm-tags.c

index 6e23c82d2bffa97ddb70144cb7c6b7a3cbbf36fb..83f7b2857617de5ea8026084afac96778f6060dd 100644 (file)
--- a/wm-tags.c
+++ b/wm-tags.c
@@ -38,17 +38,14 @@ void wm_update(void)
 int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr)
 {
        int new = key - '0';
-       if (!win)
-               return 0;
-       if (!mod.MODKEY)
-               return 0;
-       if (key < '0' || '9' < key)
-               return 0;
-       if (new == tag)
+       if (!win || !mod.MODKEY || mod.up || new == tag ||
+                       key < '0' || key > '9')
                return 0;
 
        if (mod.shift) {
                list_t *node = list_find(tags[tag], win);
+               if (node == NULL)
+                       return 0;
                tags[tag] = list_remove(tags[tag], node, 0);
                tags[new] = list_insert(tags[new], win);
                sys_show(win, st_hide);
@@ -76,6 +73,8 @@ void wm_remove(win_t *win)
 {
        for (int i = 0; i < 10; i++) {
                list_t *node = list_find(tags[i], win);
+               if (node == NULL)
+                       continue;
                tags[i] = list_remove(tags[i], node, 0);
        }
 }