]> code.delx.au - spectrwm/commitdiff
next/prev window swap logic that sucks less.
authorRyan McBride <mcbride@countersiege.com>
Thu, 15 Jan 2009 08:27:56 +0000 (08:27 +0000)
committerRyan McBride <mcbride@countersiege.com>
Thu, 15 Jan 2009 08:27:56 +0000 (08:27 +0000)
scrotwm.c

index 66fb62719b4674d868675cbcc642fb42260a5132..f1c498df6d7407b21eaecbe84dea6f571cd146c5 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -458,36 +458,26 @@ swapwin(union arg *args)
        switch (args->id) {
        case SWM_ARG_ID_SWAPPREV:
                target = TAILQ_PREV(ws[current_ws].focus, ws_win_list, entry);
-               if (target == NULL)
-                       target = TAILQ_LAST(&ws[current_ws].winlist,
-                           ws_win_list);
-               if (target == ws[current_ws].focus)
-                       return;
                TAILQ_REMOVE(&ws[current_ws].winlist,
                    ws[current_ws].focus, entry);
-               TAILQ_INSERT_BEFORE(target, ws[current_ws].focus, entry);
+               if (target == NULL)
+                       TAILQ_INSERT_TAIL(&ws[current_ws].winlist,
+                           ws[current_ws].focus, entry);
+               else
+                       TAILQ_INSERT_BEFORE(target, ws[current_ws].focus,
+                           entry);
                break;
-       case SWM_ARG_ID_SWAPNEXT: {
-               int loop = 0;
-
+       case SWM_ARG_ID_SWAPNEXT: 
                target = TAILQ_NEXT(ws[current_ws].focus, entry);
-               if (target == NULL) {
-                       loop = 1;
-                       target = TAILQ_FIRST(&ws[current_ws].winlist);
-               }
-               if (target == ws[current_ws].focus)
-                       return;
                TAILQ_REMOVE(&ws[current_ws].winlist,
                    ws[current_ws].focus, entry);
-               TAILQ_INSERT_AFTER(&ws[current_ws].winlist, target,
-                   ws[current_ws].focus, entry);
-               if (loop) {
-                       TAILQ_REMOVE(&ws[current_ws].winlist, target, entry);
-                       TAILQ_INSERT_TAIL(&ws[current_ws].winlist,
-                           target, entry);
-               }
+               if (target == NULL)
+                       TAILQ_INSERT_HEAD(&ws[current_ws].winlist,
+                           ws[current_ws].focus, entry);
+               else
+                       TAILQ_INSERT_AFTER(&ws[current_ws].winlist, target,
+                           ws[current_ws].focus, entry);
                break;
-       }
        case SWM_ARG_ID_SWAPMAIN:
                target = TAILQ_FIRST(&ws[current_ws].winlist);
                if (target == ws[current_ws].focus)