stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] [PATCH] Modify run-or-raise to cycle through all matched windows


From: John Li
Subject: [STUMP] [PATCH] Modify run-or-raise to cycle through all matched windows.
Date: Sun, 22 Jun 2008 11:52:36 -0400

Sorting by window number and then by group gives a predictable cycling
order. I removed the comments about not looking for a match because it
didn't seem to refer to any code.
---
 user.lisp |   39 +++++++++++++++++++--------------------
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/user.lisp b/user.lisp
index 7484bd3..a137912 100644
--- a/user.lisp
+++ b/user.lisp
@@ -374,26 +374,25 @@ instance. @var{all-groups} overrides this default. 
Similarily for
            (focus-all win)
            (unless (eq frame old-frame)
              (show-frame-indicator group))))
-       (find-window (group)
-         (find-if (lambda (w)
-                    (apply 'window-matches-properties-p w props))
-                  (group-windows group))))
-    (let*
-        ((screens (if all-screens
-                      *screen-list*
-                      (list (current-screen))))
-         (win
-          ;; If no qualifiers are set don't bother looking for a match.
-          ;; search all groups
-          (if all-groups
-              (loop named outer
-                    for s in screens
-                    do (loop
-                        for g in (screen-groups s)
-                        for win = (find-window g)
-                        when win
-                        do (return-from outer win)))
-              (find-window (current-group)))))
+       (sort-windows-by-group (winlist)
+         (stable-sort (sort winlist #'< :key #'window-number)
+                      #'< :key #'(lambda (w) (group-number (window-group w)))))
+       (find-window (winlist)
+         (let* ((match (remove-if-not #'(lambda (w)
+                                          (apply 'window-matches-properties-p 
w props))
+                                      winlist))
+                (match-sorted (sort-windows-by-group match))
+                (rest (member (current-window) match-sorted)))
+           (if (<= (length rest) 1) ; current win not a match or no matches 
left
+               (car match-sorted)
+               (cadr rest)))))
+    (let* ((screens (if all-screens
+                        *screen-list*
+                        (list (current-screen))))
+           (winlist (if all-groups
+                        (mapcan (lambda (s) (screen-windows s)) screens)
+                        (group-windows (current-group))))
+           (win (find-window winlist)))
       (if win
           (goto-win win)
           (run-shell-command cmd)))))
-- 
1.5.5.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]