[sawfish] make opaque move/resize animator work with tabbed windows several minor improvements in tabgroup



commit ffec603f715ccaf0efc9460704da4a51dc080e0b
Author: Christopher Roy Bratusek <zanghar freenet de>
Date:   Mon Feb 21 21:08:27 2011 +0100

    make opaque move/resize animator work with tabbed windows
    several minor improvements in tabgroup

 ChangeLog                        |    5 +
 lisp/sawfish/wm/tabs/tabgroup.jl |  197 ++++++++++++++++++++++++--------------
 2 files changed, 131 insertions(+), 71 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e304fb4..3fa68fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-21  Christopher Roy Bratusek <zanghar freenet de>
+	* lisp/sawfish/wm/tabs/tabgropu.jl: make opaque move and
+	resize animator work with tabbed windows. Improved various functions
+	tab-refresh-group, tab-group-window, tab-put-window-in-group [fuchur]
+
 2011-02-20  Christopher Roy Bratusek <zanghar freenet de>
 	* lisp/sawfish/wm/edge/hot-spot.jl: small string-change
 
diff --git a/lisp/sawfish/wm/tabs/tabgroup.jl b/lisp/sawfish/wm/tabs/tabgroup.jl
index ead0ab5..4ee55d4 100644
--- a/lisp/sawfish/wm/tabs/tabgroup.jl
+++ b/lisp/sawfish/wm/tabs/tabgroup.jl
@@ -31,7 +31,7 @@
             tab-group-window-list
             tab-group-window-index
             tab-group-window
-	    maybe-raise-tab)
+            maybe-raise-tab)
     
     (open rep
           rep.system
@@ -57,17 +57,19 @@
     :group focus
     :type boolean)
 
-  (define (maybe-raise-tab w)
-    "Raise a window, when it's a tab and automatic raising of is disabled"
-    (when (and (not tab-raise-on-hover)
-	       (window-tabbed-p w))
-      (tab-refresh-group w 'raise)))
-
-  (define-command 'maybe-raise-tab maybe-raise-tab #:spec "%W")
+    (define (maybe-raise-tab w)
+      "Raise a window, when it's a tab and automatic raising of is disabled"
+      (when (and (not tab-raise-on-hover)
+                 (window-tabbed-p w))
+        (tab-refresh-group w 'raise)))
+    
+    (define-command 'maybe-raise-tab maybe-raise-tab #:spec "%W")
 
+  (define current-win nil)
+  (define all-wins nil)
+  (define oldgroup nil)
   (define tab-groups nil)
   (define tab-refresh-lock t)
-  (define tab-move-lock t)
 
   (define (window-tabbed-p w)
     (window-get w 'tabbed))
@@ -142,29 +144,25 @@
         (rplaca (nthcdr index tab-groups)
                 (tab-build-group (tab-group-position old) (tab-group-dimensions old) l))
         (window-put win 'tabbed nil)
-        (tab-refresh-group win 'raise)
-        (tab-refresh-group win 'frame)
-        (window-put win 'fixed-position nil)
         (if (not (cdr l))
             (window-put (car l) 'tabbed nil))
-        (tab-refresh-group (car l) 'frame))))
+        (setq oldgroup (car l)))))
 
   (define (tab-delete-window-from-tab-groups w)
     "Find window's group and remove it."
     (when (window-tabbed-p w)
-      (tab-delete-window-from-group w (tab-window-group-index w))))
+      (tab-delete-window-from-group w (tab-window-group-index w))
+      (window-put w 'fixed-position nil)
+      (tab-refresh-group oldgroup 'frame)
+      (rebuild-frame w 'frame)))
 
   (define (tab-put-window-in-group win index)
     "Put window in group at given index."
-    (let* ((group (nth index tab-groups))
-           (dim (tab-group-dimensions group))
-           (pos (tab-group-position group)))
+    (let* ((group (nth index tab-groups)))
       (rplaca (nthcdr index tab-groups)
               (tab-build-group (tab-group-position group)
                                (tab-group-dimensions group)
-                               (append (tab-group-window-list group) (list win))))
-      (tab-move-resize-frame-window-to win (car pos) (cdr pos) (car dim) (cdr dim))
-      (rebuild-frame win)))
+                               (append (tab-group-window-list group) (list win))))))
 
   (define (tab-refresh-group win prop)
     "Refresh the entire group containing WIN according to PROP.
@@ -176,7 +174,8 @@ sticky, unsticky, fixed-position."
       (unwind-protect
           (let* ((index (tab-window-group-index win))
                  (wins (tab-group-window-list (nth index tab-groups)))
-                 (focus (tab-group-offset win 0)))
+                 (focus (tab-group-offset win 0))
+                 (unfocus (remove focus wins)))
             (adjust-title win)
             (cond
              ((eq prop 'raise)
@@ -184,68 +183,72 @@ sticky, unsticky, fixed-position."
              ((eq prop 'title-position)
               (let ((group-title-position (window-get win 'title-position)))
                 (mapcar (lambda (w)
-                          (window-put w 'title-position group-title-position)) wins)))
+                          (window-put w 'title-position group-title-position)) unfocus)
+               (window-put focus 'title-position group-title-position)))
              ((eq prop 'frame)
               (mapcar (lambda (w)
-                        (rebuild-frame w)) wins))
+                        (rebuild-frame w)) unfocus)
+              (rebuild-frame focus))
              ((eq prop 'reframe)
               (mapcar (lambda (w)
-                        (reframe-window w)) wins))
+                        (reframe-window w)) unfocus)
+              (reframe-window focus))
              ((eq prop 'style)
               (let ((group-frame-style (window-get win 'frame-style))
                     (dim (window-frame-dimensions win))
                     (pos (window-position win)))
                 (mapcar (lambda (w)
                           (set-frame-style w group-frame-style)
-                          (tab-move-resize-frame-window-to w (car pos) (cdr pos) (car dim) (cdr dim))
-                          (reframe-window w)) wins)))
+                          (tab-move-resize-frame-window-to w (car pos) (cdr pos) (car dim) (cdr dim))) unfocus)
+                (set-frame-style focus group-frame-style)
+                (tab-move-resize-frame-window-to focus (car pos) (cdr pos) (car dim) (cdr dim))))
              ((or (eq prop 'move) (eq prop 'resize))
               (let ((dim (window-frame-dimensions win))
                     (pos (window-position win)))
                 (mapcar (lambda (w)
-                          (tab-move-resize-frame-window-to w (car pos) (cdr pos) (car dim) (cdr dim))
-                          (rebuild-frame w)) wins)
+                          (tab-move-resize-frame-window-to w (car pos) (cdr pos) (car dim) (cdr dim))) unfocus)
+                (tab-move-resize-frame-window-to focus (car pos) (cdr pos) (car dim) (cdr dim))
                 (rplaca (nthcdr index tab-groups)
                         (tab-build-group pos dim wins))))
              ((eq prop 'fixed-position)
               (let ((group-frame-fixed-position (window-get win 'fixed-position)))
                 (mapcar (lambda (w)
-                          (window-put w 'fixed-position group-frame-fixed-position)
-                          (rebuild-frame w)) wins)))
+                          (window-put w 'fixed-position group-frame-fixed-position)) unfocus)
+                (window-put focus 'fixed-position group-frame-fixed-position)))
              ((eq prop 'type)
               (let ((group-frame-type (window-get win 'type)))
                 (mapcar (lambda (w)
-                          (window-put w 'type group-frame-type)
-                          (rebuild-frame w)) wins)))
+                          (window-put w 'type group-frame-type)) unfocus)
+                (window-put focus 'type group-frame-type)))
              ((eq prop 'depth)
               (let ((group-frame-depth (window-get win 'depth)))
                 (mapcar (lambda (w)
-                          (window-put w 'depth group-frame-depth)
-                          (rebuild-frame w)) wins)))
+                          (window-put w 'depth group-frame-depth)) unfocus)
+                 (window-put focus 'depth group-frame-depth)))
              ((eq prop 'iconify)
               (mapcar (lambda (w)
-                        (iconify-window w)
-                        (rebuild-frame w)) wins))
+                        (iconify-window w)) unfocus)
+              (iconify-window focus))
              ((eq prop 'uniconify)
               (mapcar (lambda (w)
-                        (uniconify-window w)
-                        (rebuild-frame w)) wins))
+                        (uniconify-window w)) unfocus)
+              (uniconify-window focus))
              ((eq prop 'sticky)
               (mapcar (lambda (w)
-                        (make-window-sticky w)
-                        (rebuild-frame w)) wins))
+                        (make-window-sticky w)) unfocus)
+              (make-window-sticky focus))
              ((eq prop 'unsticky)
               (mapcar (lambda (w)
-                        (make-window-unsticky w)
-                        (rebuild-frame w)) wins))
+                        (make-window-unsticky w)) unfocus)
+              (make-window-unsticky focus))
              ((eq prop 'shade)
               (mapcar (lambda (w)
-                        (shade-window w)
-                        (rebuild-frame w)) wins))
+                        (shade-window w)) unfocus) 
+              (shade-window focus))
              ((eq prop 'unshade)
               (mapcar (lambda (w)
-                        (unshade-window w)
-                        (rebuild-frame w)) wins))))
+                        (unshade-window w)) unfocus) 
+              (unshade-window focus))))
         (setq tab-refresh-lock t))))
 
   ;; Entry points
@@ -254,39 +257,42 @@ sticky, unsticky, fixed-position."
     ;; don't add a window as tab, if it already
     ;; exists on another workspace
     (when (not (cdr (window-get win 'workspaces)))
-      ;; from tabgroup to tabgroup
-      (when (window-tabbed-p w)
-        (tab-delete-window-from-tab-groups w))
-      ;; sort windows/tabs (depth)
-      (tab-refresh-group win 'raise)
-      (raise-window w)
-      (set-input-focus w)
       (let* ((index (tab-window-group-index win))
              (index2 (tab-window-group-index w))
+             (pos (window-position win))
+             (dim (window-dimensions win))
              ;; adopt window settings for the new tab
              (group-frame-style (window-get win 'frame-style))
              (group-frame-type (window-get win 'type))
              (group-frame-sticky (window-get win 'sticky))
+             (group-frame-never-iconify (window-get win 'never-iconify))
              (group-frame-fixed-position (window-get win 'fixed-position))
              (group-frame-title-position (window-get win 'title-position))
              (group-frame-depth (window-get win 'depth)))
         (when (not (eq index index2))
+          ;; tabgroup to tabgroup
+          (when (window-tabbed-p w)
+            (tab-delete-window-from-tab-groups w))
+          (setq tab-refresh-lock nil)
           (if (window-get w 'shaded) (unshade-window w))
           (if (window-get win 'shaded) (unshade-window win))
           (window-put w 'frame-style group-frame-style)
           (window-put w 'type group-frame-type)
           (window-put w 'title-position group-frame-title-position)
           (window-put w 'sticky group-frame-sticky)
+          (window-put w 'never-iconify group-frame-never-iconify)
           (window-put w 'depth group-frame-depth)
           (window-put w 'fixed-position group-frame-fixed-position)
           ;; reframe w here, tab-refresh-group expectet
           ;; the same frame for w and win
           (reframe-window w)
-          (tab-refresh-group win 'move)
           (tab-put-window-in-group w index)
           (tab-delete-window-from-group w index2)
-          (tab-refresh-group win 'frame)
-          (tab-refresh-group w 'move)
+          (resize-window-to w (car dim) (cdr dim))
+          (move-window-to w (car pos) (cdr pos))
+          (setq tab-refresh-lock t)
+          (tab-refresh-group w 'frame)
+          (set-input-focus w)
           (if (not (window-tabbed-p win)) (window-put win 'tabbed t))
           (window-put w 'tabbed t)))))
   
@@ -340,35 +346,84 @@ sticky, unsticky, fixed-position."
         (tab-refresh-group win 'sticky)
       (tab-refresh-group win 'unsticky)))
 
+  (define (before-move-resize win)
+    "Releas win from the tabgroup and iconify the rest from the group."
+    (let* ((index (tab-window-group-index win))
+           (wins (tab-group-window-list (nth index tab-groups)))
+           (tabs (remove win (tab-group-window-list (nth index tab-groups))))
+	   (default-window-animator 'none))
+      (tab-delete-window-from-group win index)
+      (rebuild-frame win)
+      (setq tab-refresh-lock nil)
+      (mapcar (lambda (w)
+                (when (window-get w 'never-iconify)
+                  (window-put w 'never-iconify nil)
+                  (window-put w 'never-iconify-opaque t))
+		(iconify-window w)) tabs)
+      (setq all-wins wins)
+      (setq current-win win))
+    (setq tab-refresh-lock t))
+
+  (define (after-move-resize win)
+    "Add all tabs to the tabgroup from win. (Releas and iconify by before-move-resize)"
+    (setq tab-refresh-lock nil)
+    (let* ((wins all-wins)
+	   (default-window-animator 'none)
+           (pos (window-position win))
+           (dim (window-dimensions win))
+           index index-old)
+      (when (and (cdr wins)
+                 (eq win current-win))
+        (setq index (tab-window-group-index (car wins)))
+        (mapcar (lambda (w)
+                  (when (not (eq index (tab-window-group-index w)))
+                    (setq index-old (tab-window-group-index w))
+                    (tab-put-window-in-group w index)
+                    (tab-delete-window-from-group w index-old))
+                  (move-window-to w (car pos) (cdr pos))
+                  (resize-window-to w (car dim) (cdr dim))
+                  (uniconify-window w)
+                  (when (window-get w 'never-iconify-opaque)
+                    (window-put w 'never-iconify-opaque nil)
+                    (window-put w 'never-iconify t))
+                  (window-put w 'tabbed t)) wins)
+        (raise-window win)
+        (setq all-wins nil)
+        (setq current-win nil))
+      (setq tab-refresh-lock t)
+      (when (window-tabbed-p win) 
+        (tab-refresh-group win 'move)
+        (tab-refresh-group win 'frame))))
+
   (unless batch-mode
     (add-hook 'window-state-change-hook
               (lambda (win args)
                 (when (window-tabbed-p win)
                   (setq args (car args))
                   (cond ((eq 'sticky args)
-                         (tab-group-sticky win))
+                         (tab-group-sticky win)
+                         (tab-refresh-group win 'frame))
                         ((eq 'fixed-position args)
-                         (tab-refresh-group win 'fixed-position))
+                         (tab-refresh-group win 'fixed-position)
+                         (tab-refresh-group win 'frame))
                         ((eq 'frame-style args)
                          (tab-refresh-group win 'style)
+                         (tab-refresh-group win 'reframe)
                          (tab-refresh-group win 'move))
                         ((eq 'type args)
-                         (tab-refresh-group win 'type))
+                         (tab-refresh-group win 'type)
+                         (tab-refresh-group win 'reframe))
                         ((eq 'stacking args)
-                         (tab-refresh-group win 'depth))))))
+                         (tab-refresh-group win 'depth)
+                         (tab-refresh-group win 'frame))))))
     
-    (add-hook 'focus-in-hook 
-              (lambda (win) 
-                (if tab-raise-on-hover
-                    (tab-group-raise win))))
-    (add-hook 'after-move-hook (lambda (win)  (if (window-tabbed-p win) (tab-refresh-group win 'move))))
-    (add-hook 'after-resize-hook (lambda (win)  (if (window-tabbed-p win) (tab-refresh-group win 'resize))))
-    ;; only update tabs by move if opaque move mode (opaque = slow)
-    ;;
+    (add-hook 'focus-in-hook (lambda (win) (if tab-raise-on-hover (tab-group-raise win))))
     (when (eq move-outline-mode 'opaque)
-      (add-hook 'while-moving-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'move))))
-      )
-    (add-hook 'window-resized-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'resize))))
+      (add-hook 'before-move-hook (lambda (win) (if (window-tabbed-p win) (before-move-resize win)))))
+    (add-hook 'after-move-hook  (lambda (win) (after-move-resize win)))
+    (when (eq resize-outline-mode 'opaque)
+      (add-hook 'before-resize-hook (lambda (win) (if (window-tabbed-p win) (before-move-resize win)))))
+    (add-hook 'after-resize-hook  (lambda (win) (after-move-resize win)))
     (add-hook 'shade-window-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'shade))))
     (add-hook 'unshade-window-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'unshade))))
     (add-hook 'iconify-window-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'iconify))))



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