Re: [Sawfish] Patch to save memory and speed up StyleTab

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On Tue, 15 Apr 2014 20:27:58 +0200
wrote fuchur <flohtransporter@xxxxxxxxx>:

Three patches 06-tab-tiler-add.patch 07-tab-tiler-add.patch and 
08-tab-tiler-add.patch. Apply this patches after 04-tab-tiler-add.patch
and 05-tab-tiler-add.patch from this thread.

Changes:
Fix autoshade tabs if shade-hover is enable.
Fix wrong input-focus by enter-exit enter-only and enter-click with
tabs.

Enable Shade hover and Auto raise in sawfish-config.
Tabs now also use the timer set by shade-hover auto-raise.
Mouse pointer follow now the tab if you move a tab in the tabbar (only
by mouse click).
Change some default settings in compton module.
Change some default settings in Styletab.
 

- -- 
Regards,
Fuchur

GPG Fingerprint: CA3B 8204 5B3E 6D48 6D53  C116 E5BC 70D5 B8D7 B2B0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iEYEARECAAYFAlNS5OwACgkQ5bxw1bjXsrB2fwCfcu8Sc1hM9OaqM81gLwpi803t
8VgAnAtF8620yfigiHiz54ccWbrKiXru
=3X5i
-----END PGP SIGNATURE-----
diff -urNad lisp.orgi/sawfish/wm/autoload.jl lisp/sawfish/wm/autoload.jl
--- lisp.orgi/sawfish/wm/autoload.jl
+++ lisp/sawfish/wm/autoload.jl
@@ -128,6 +128,8 @@
 (autoload-command 'slide-group-down 'sawfish.wm.commands.slide-window)
 (defgroup gpsy "Grow, Pack, Shrink & Yank" :group move :require sawfish.wm..commands.grow-pack)
 (defgroup cycle "Window Cycling" :group focus :require sawfish.wm.commands..x-cycle)
+(defgroup shade-hover "Shade Hover" :group focus :require sawfish.wm.ext.shade-hover)
+(defgroup auto-raise "Auto-Raise" :group focus :require sawfish.wm.ext.auto-raise)
 (autoload-command 'cycle-windows 'sawfish.wm.commands.x-cycle)
 (autoload-command 'cycle-windows-backwards 'sawfish.wm.commands.x-cycle)
 (autoload-command 'cycle-group 'sawfish.wm.commands.x-cycle)
diff -urNad lisp.orgi/sawfish/wm/ext/auto-raise.jl lisp/sawfish/wm/ext/auto-raise.jl
--- lisp.orgi/sawfish/wm/ext/auto-raise.jl
+++ lisp/sawfish/wm/ext/auto-raise.jl
@@ -34,7 +34,7 @@
 
   (defgroup auto-raise "Auto-Raise" :group focus)
 
-  (defcustom raise-windows-on-focus nil
+  (defcustom raise-windows-on-focus t
     "Raise windows when they are focused."
     :type boolean
     :require sawfish.wm.ext.auto-raise
diff -urNad lisp.orgi/sawfish/wm/ext/shade-hover.jl lisp/sawfish/wm/ext/shade-hover.jl
--- lisp.orgi/sawfish/wm/ext/shade-hover.jl
+++ lisp/sawfish/wm/ext/shade-hover.jl
@@ -20,7 +20,7 @@
 
 (define-structure sawfish.wm.ext.shade-hover
 
-    (export )
+    (export clean-up)
 
     (open rep
           rep.system
diff -urNad lisp.orgi/sawfish/wm/tabs/tabgroup.jl lisp/sawfish/wm/tabs/tabgroup.jl
--- lisp.orgi/sawfish/wm/tabs/tabgroup.jl
+++ lisp/sawfish/wm/tabs/tabgroup.jl
@@ -38,6 +38,7 @@
 
     (open rep
           rep.system
+          rep.io.timers
           rep.data.records
           sawfish.wm.gaol
           sawfish.wm.misc
@@ -51,6 +52,8 @@
           sawfish.wm.stacking
           sawfish.wm.util.groups
           sawfish.wm.commands.groups
+          sawfish.wm.ext.auto-raise
+          sawfish.wm.ext.shade-hover
           sawfish.wm.workspace)
 
   (define-structure-alias tabgroup sawfish.wm.tabs.tabgroup)
@@ -317,6 +320,7 @@
              ;; adopt window settings for the new tab
              (group-frame-style (window-get win 'frame-style))
              (group-frame-type (window-get win 'type))
+             (group-frame-shade-hover (window-get win 'shade-hover))
              (group-frame-focus-mode (window-get win 'focus-mode))
              (group-frame-gravity (window-get win 'gravity))
              (group-frame-never-iconify (window-get win 'never-iconify))
@@ -349,6 +353,7 @@
           (if (window-get w 'shaded) (unshade-window w))
           (window-put w 'frame-style group-frame-style)
           (window-put w 'type group-frame-type)
+          (window-put w 'shade-hover group-frame-shade-hover)
           (window-put w 'focus-mode group-frame-focus-mode)
           (window-put w 'gravity group-frame-gravity)
           (window-put w 'title-position group-frame-title-position)
@@ -559,7 +564,8 @@
       (setq tab-refresh-lock t)
       (when (window-tabbed-p win)
         (tab-refresh-group win 'move)
-        (tab-refresh-group win 'frame))
+        (tab-refresh-group win 'frame)
+        (set-input-focus (nth 0 (tab-group-windows-stacking-order win))))
       (setq tab-move-resize-lock nil)))
 
   (define (unmap-id win)
@@ -586,6 +592,37 @@
     (when (window-get win 'tab-group)
       (setq in-tab-group-name (remove (assoc last-unmap-id in-tab-group-name) in-tab-group-name))))
 
+  (define timer-raise nil)
+  (define (focus-in-tab win)
+    (if (or shade-hover-mode (window-get win 'shade-hover))
+        (let ((timer-wait (if raise-windows-on-focus raise-window-timeout '500)))
+          (if (or (eq focus-mode 'click)
+                  (window-get win 'focus-mode 'click))
+              (setq timer-wait '1))
+          (setq timer-raise
+                (make-timer (lambda ()
+                              (raise-windows win (tab-group-windows-stacking-order win)))
+                            (quotient timer-wait 1000) (mod timer-wait 1000))))
+      (tab-refresh-group win 'raise)))
+
+  (define (focus-out-tab)
+    (when timer-raise
+      (delete-timer timer-raise)
+      (setq timer-raise nil)))
+
+  (define (unshade-tab win)
+    (let ((unshade-nil))
+      (when (window-get win 'shade-hover-unshaded)
+        (mapcar (lambda (w)
+                  (if (not (window-get w 'shaded)) (setq unshade-nil 't))) (remove win (tab-group-windows win)))
+        (when unshade-nil
+          (window-put win 'shade-hover-unshaded nil)
+          (clean-up)
+          (setq unshade-nil nil)
+          (mapcar (lambda (w)
+                    (shade-window w)) (remove win (tab-group-windows win))))
+        (set-input-focus win))))
+
   (unless batch-mode
     (add-hook 'after-add-window-hook in-tab-group)
     (add-hook 'unmap-notify-hook unmap-id)
@@ -616,7 +653,9 @@
     (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 'focus-in-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'raise))))
+    (add-hook 'focus-in-hook (lambda (win) (if (window-tabbed-p win) (focus-in-tab win))))
+    (add-hook 'focus-out-hook (lambda (win) (if (window-tabbed-p win) (focus-out-tab))))
+    (add-hook 'unshade-window-hook (lambda (win) (if (window-tabbed-p win) (unshade-tab win))))
     (add-hook 'iconify-window-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'iconify))))
     (add-hook 'uniconify-window-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'uniconify))))
     (add-hook 'window-maximized-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'maximized))))
diff -urNad lisp.orgi-1/sawfish/wm/prg/compton.jl lisp/sawfish/wm/prg/compton.jl
--- lisp.orgi-1/sawfish/wm/prg/compton.jl
+++ lisp/sawfish/wm/prg/compton.jl
@@ -54,7 +54,7 @@
       :type boolean
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom shadows-enable nil "Enabled client-side shadows on windows."
+    (defcustom shadows-enable t "Enabled client-side shadows on windows."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
@@ -66,7 +66,7 @@
       :type boolean
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom shadows-disable-shaped nil "Don't draw shadows on shaped windows."
+    (defcustom shadows-disable-shaped t "Don't draw shadows on shaped windows."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
@@ -84,7 +84,7 @@
       :type boolean
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom force-tabbed nil "Force shadows by tabbed windows."
+    (defcustom force-tabbed t "Force shadows by tabbed windows."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
@@ -110,7 +110,7 @@
       :options (25 20 15 10 5 0 -05 -10 -15 -20 -25 -30 -35 -40 -45 -50)
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom translucency 80 "The translucency for shadows (Default 80)."
+    (defcustom translucency 60 "The translucency for shadows (Default 80)."
       :depends opacity-enable
       :group (appearance window-effects)
       :type symbol
@@ -145,13 +145,13 @@
       :options (0 1 2 3 4 5 6 7 8 9 10)
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom avoid-shadows nil "Avoid drawing shadows on dock/panel windows."
+    (defcustom avoid-shadows t "Avoid drawing shadows on dock/panel windows."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom fade-enable nil "Fade windows in/out when opening/closing and when opacity changes."
+    (defcustom fade-enable t "Fade windows in/out when opening/closing and when opacity changes."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
@@ -178,7 +178,7 @@
       :options (0 2 4 6 8 10 12 14 16 18 20 25 30 35 40 45 50)
       :after-set (lambda () (switch-opacity)))
 
-    (defcustom zero-mask nil "Zero the part of the shadow's mask behind the window (experimental)."
+    (defcustom zero-mask t "Zero the part of the shadow's mask behind the window (experimental)."
       :depends opacity-enable
       :group (appearance window-effects)
       :type boolean
diff -urNad lisp.orgi-1/sawfish/wm/tabs/tab.jl lisp/sawfish/wm/tabs/tab.jl
--- lisp.orgi-1/sawfish/wm/tabs/tab.jl
+++ lisp/sawfish/wm/tabs/tab.jl
@@ -21,7 +21,12 @@
 
 (define-structure sawfish.wm.tabs.tab
 
-    (export set-tab-adjustments)
+    (export tab-pos 
+            tabbar-left-margin
+            tabbar-left-margin-transient
+            tabbar-right-margin
+            tabbar-right-margin-transient
+            set-tab-adjustments)
 
     (open rep
 	  rep.system
diff -urNad lisp.orgi-1/sawfish/wm/tabs/tabgroup.jl lisp/sawfish/wm/tabs/tabgroup.jl
--- lisp.orgi-1/sawfish/wm/tabs/tabgroup.jl
+++ lisp/sawfish/wm/tabs/tabgroup.jl
@@ -46,6 +46,8 @@
           sawfish.wm.commands
           sawfish.wm.windows
           sawfish.wm.frames
+          sawfish.wm.tabs.tab
+          sawfish.wm.events
           sawfish.wm.state.iconify
           sawfish.wm.state.shading
           sawfish.wm.commands.move-resize
@@ -67,6 +69,7 @@
   (define last-unmap-id nil)
   (define in-tab-group-name nil)
   (define tab-theme-name)
+  (define tab-theme-tabbars)
 
   (defvar tab-group-windows-hook '()
     "Tab-group-windows-hook called when changing or creating a tabgroup.
@@ -75,15 +78,22 @@
   (define (set-tab-theme-name #!key frame-style-supported-tabs)
     (setq tab-theme-name frame-style-supported-tabs))
 
-  (define (window-tabbed-p w)
-    (window-get w 'tabbed))
-
   (define (frame-style-tabs-support-p w)
     "Returns t if the framestyle from W supports tabs.
 Also need the currect settings in the theme.jl from the theme."
     (setq tab-theme-name nil)
     (call-window-hook 'window-state-change-hook w (list '(tab-theme-name)))
     (eq (window-get w 'current-frame-style) tab-theme-name))
+
+  (define (set-tab-theme-tabbars #!key frame-style-supported-tabbars)
+    (setq tab-theme-tabbars frame-style-supported-tabbars))
+
+  (define (frame-style-tabbars-support w)
+    "Returns a list with theme name and tabbars position if the framestyle from W 
+has multiple tabbars. Also need the currect settings in the theme.jl from the theme."
+    (setq tab-theme-tabbars nil)
+    (call-window-hook 'window-state-change-hook w (list '(tab-theme-tabbars)))
+    tab-theme-tabbars)
   
   (define (net-wm-window-type-normal-p w)
     "Returns t if _NET_WM_WINDOW_TYPE by W is true or W has window-property 'force-tab"
@@ -91,6 +101,9 @@
         (if (get-x-property w '_NET_WM_WINDOW_TYPE)
             (equal (aref (nth 2 (get-x-property w '_NET_WM_WINDOW_TYPE)) 0) '_NET_WM_WINDOW_TYPE_NORMAL))))
 
+  (define (window-tabbed-p w)
+    (window-get w 'tabbed))
+
   (define-record-type :tab-group
     (tab-build-group p d wl)
     tab-group?
@@ -473,14 +486,17 @@
             (setq all-wins (nthcdr 0 new-list))
             (after-move-resize w))))))
 
+  (define clicked-frame nil)
   (define (tab-move-to-right w)
     "Move tab to right in the tabbar."
+    (setq clicked-frame (clicked-frame-part))
     (move-tab w 'next))
 
   (define-command 'tab-move-to-right tab-move-to-right #:spec "%f")
 
   (define (tab-move-to-left w)
     "Move tab to left in the tabbar."
+    (setq clicked-frame (clicked-frame-part))
     (move-tab w 'prev))
   
   (define-command 'tab-move-to-left tab-move-to-left #:spec "%f")
@@ -497,12 +513,14 @@
 
   (define (tab-move-to-end w)
     "Move tab to the end in the tabbar."
+    (setq clicked-frame (clicked-frame-part))
     (move-tab-edge w 'end))
 
   (define-command 'tab-move-to-end tab-move-to-end #:spec "%f")
 
   (define (tab-move-to-beginning w)
     "Move tab to the beginning in the tabbar."
+    (setq clicked-frame (clicked-frame-part))
     (move-tab-edge w 'beg))
 
   (define-command 'tab-move-to-beginning tab-move-to-beginning #:spec "%f")
@@ -565,9 +583,42 @@
       (when (window-tabbed-p win)
         (tab-refresh-group win 'move)
         (tab-refresh-group win 'frame)
-        (set-input-focus (nth 0 (tab-group-windows-stacking-order win))))
+        (set-input-focus (nth 0 (tab-group-windows-stacking-order win)))
+        (when clicked-frame
+          (move-cursor-in-tabbar (input-focus))
+          (setq clicked-frame nil)))
       (setq tab-move-resize-lock nil)))
 
+  (define (move-cursor-in-tabbar win)
+    (let* ((group (tab-find-window win))
+           (tabnum (tab-rank win (tab-group-window-list group)))
+           (tab-pos-list (tab-pos group tabnum win))
+           (start-right
+            (if (or (eq (window-get win 'type) 'transient)
+                    (eq (window-get win 'type) 'shaped-transient))
+                tabbar-left-margin-transient
+              tabbar-left-margin)))
+      (if (not (eq (window-get win 'current-frame-style) (nth 0 (frame-style-tabbars-support win))))
+          (warp-cursor (+ (car (window-position win)) start-right (nth 4 tab-pos-list) (quotient (nth 6 tab-pos-list) 2))
+                       (+ (quotient (- (cdr (window-frame-dimensions win)) (cdr (window-dimensions win)) 2) 2) (cdr (window-position win))))
+        (let ((current-pos 
+               (if (window-get win 'title-position)
+                   (window-get win 'title-position)
+                 (nth 1 (frame-style-tabbars-support win)))))
+          (case current-pos
+                ((top) (warp-cursor (+ (car (window-position win)) start-right (nth 4 tab-pos-list) (quotient (nth 6 tab-pos-list) 2))
+                                    (+ (quotient (- (cdr (window-frame-dimensions win)) (cdr (window-dimensions win)) 2) 2) (cdr (window-position win)))))
+                ((bottom) (warp-cursor (+ (car (window-position win)) start-right (nth 4 tab-pos-list) (quotient (nth 6 tab-pos-list) 2))
+                                       (+ (quotient (- (cdr (window-frame-dimensions win)) (cdr (window-dimensions win))) 2) 
+                                          (cdr (window-position win)) (cdr (window-dimensions win)) 2)))
+                ((left) (warp-cursor (+ (quotient (- (car (window-frame-dimensions win)) (car (window-dimensions win)) 2) 2) (car (window-position win)))
+                                     (- (+ (cdr (window-position win)) (cdr (window-dimensions win))) start-right (nth 7 tab-pos-list) 
+                                        (quotient (nth 9 tab-pos-list) 2))))
+                ((right) (warp-cursor (+ (quotient (- (car (window-frame-dimensions win)) (car (window-dimensions win))) 2) 
+                                         (car (window-position win)) (car (window-dimensions win)) 2) 
+                                      (- (+ (cdr (window-position win)) (cdr (window-dimensions win))) start-right (nth 7 tab-pos-list) 
+                                         (quotient (nth 9 tab-pos-list) 2)))))))))
+
   (define (unmap-id win)
     (setq last-unmap-id (window-id win)))
 
@@ -594,16 +645,16 @@
 
   (define timer-raise nil)
   (define (focus-in-tab win)
-    (if (or shade-hover-mode (window-get win 'shade-hover))
-        (let ((timer-wait (if raise-windows-on-focus raise-window-timeout '500)))
-          (if (or (eq focus-mode 'click)
-                  (window-get win 'focus-mode 'click))
-              (setq timer-wait '1))
-          (setq timer-raise
-                (make-timer (lambda ()
-                              (raise-windows win (tab-group-windows-stacking-order win)))
-                            (quotient timer-wait 1000) (mod timer-wait 1000))))
-      (tab-refresh-group win 'raise)))
+    (let ((timer-wait (if raise-windows-on-focus raise-window-timeout '500)))
+      (if (or (eq focus-mode 'click)
+              (eq (window-get win 'focus-mode) 'click))
+          (setq timer-wait '1))
+      (setq timer-raise
+            (make-timer (lambda ()
+                          (if (or shade-hover-mode (window-get win 'shade-hover))
+                              (raise-windows win (tab-group-windows-stacking-order win))
+                            (tab-refresh-group win 'raise)))
+                        (quotient timer-wait 1000) (mod timer-wait 1000)))))
 
   (define (focus-out-tab)
     (when timer-raise
@@ -623,6 +674,7 @@
                     (shade-window w)) (remove win (tab-group-windows win))))
         (set-input-focus win))))
 
+
   (unless batch-mode
     (add-hook 'after-add-window-hook in-tab-group)
     (add-hook 'unmap-notify-hook unmap-id)
@@ -662,4 +714,4 @@
     (add-hook 'window-unmaximized-hook (lambda (win) (if (window-tabbed-p win) (tab-refresh-group win 'maximized))))
     (add-hook 'destroy-notify-hook tab-delete-window-from-tab-groups))
 
-  (gaol-add set-tab-theme-name tab-refresh-group tab-group-windows))
+  (gaol-add set-tab-theme-name set-tab-theme-tabbars tab-refresh-group tab-group-windows))
--- themes/StyleTab/theme.jl.orgi
+++ themes/StyleTab/theme.jl
@@ -52,12 +52,12 @@
 (defcustom styletab-c:styles 'Default "Frame and button style."
   :group (appearance StyleTab:group)
   :type symbol
-  :options (Default Reduce Glass WixDa Smoothly Flat))
+  :options (Default Glass Reduce WixDa Smoothly Flat))
 
-(defcustom styletab-c:proposals 'Pink "Color proposals."
+(defcustom styletab-c:proposals 'Default "Color proposals."
   :group (appearance StyleTab:group)
   :type symbol
-  :options (Default Reduce Glass WixDa Smoothly Flat Brown Darkblue Blue Pink Green)
+  :options (Default Glass Reduce WixDa Smoothly Flat Brown Darkblue Blue Pink Green)
   :after-set (lambda () (color-changed)))
 
 (defcustom styletab-c:tabbar-marked t "Colorize tab/titelbar if it is to be added as a tab."
@@ -65,7 +65,7 @@
   :type boolean
   :after-set (lambda () (botton-color-changed recolor-tab)))
 
-(defcustom styletab-c:tabbar-marked-color (get-color "#DF0000")
+(defcustom styletab-c:tabbar-marked-color (get-color "#010095")
   "Color of tab/titelbar when it was marked."
   :group (appearance StyleTab:group)
   :type color
@@ -2911,6 +2911,10 @@
   (when (eq (window-get w 'current-frame-style) theme-name)
     (set-tab-theme-name #:frame-style-supported-tabs theme-name)))
 
+(define (frame-style-tabbars w)
+  (when (eq (window-get w 'current-frame-style) theme-name)
+    (set-tab-theme-tabbars #:frame-style-supported-tabbars (list theme-name styletab-c:titlebar-place))))
+
 (define (get-frame w type)
   (let ((current-title
          (if (not (window-get w 'title-position))
@@ -2941,6 +2945,7 @@
 (add-frame-style theme-name get-frame)
 
 (call-after-state-changed '(tab-theme-name) frame-style-name)
+(call-after-state-changed '(tab-theme-tabbars) frame-style-tabbars)
 (call-after-state-changed '(marked) reframe-marked)
 (call-after-state-changed '(maximized sticky fixed-position stacking) reframe-one)
 (add-hook 'remove-from-workspace-hook reframe-one)


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/