[sawfish] StyleTab: Improved tabbar-rotating commands definition. This may be incompatible.



commit a955e0ea79d45c6baabacdc0ee74effb3189af99
Author: Teika kazura <teika lavabit com>
Date:   Fri Feb 11 17:24:55 2011 +0900

    StyleTab: Improved tabbar-rotating commands definition. This may be incompatible.
    
    You may have to delete styletab-related parts in ~/.sawfish/custom.
    
    Definitions are now collected into one function.
    For users, tooltip is shown for tab-rotating button.
    Keybinding is changed a bit.

 themes/StyleTab/theme.jl |  357 ++++++++++++++--------------------------------
 1 files changed, 106 insertions(+), 251 deletions(-)
---
diff --git a/themes/StyleTab/theme.jl b/themes/StyleTab/theme.jl
index 640baa8..ba57751 100644
--- a/themes/StyleTab/theme.jl
+++ b/themes/StyleTab/theme.jl
@@ -467,260 +467,115 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; frame-class, keys bindings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; frame-class, keys bindings
+
+(define (rotate-tab src dest)
+  (let ((w (current-event-window))
+	pos-x pos-y fdim framew framehigh dim-x dim-y current-title)
+    (if (not (window-get w 'title-position))
+	(case styletab:titlebar-place
+	  ((top) (setq current-title 'top))
+	  ((bottom) (setq current-title 'bottom))
+	  ((left) (setq current-title 'left))
+	  ((right) (setq current-title 'right)))
+      (setq current-title (window-get w 'title-position)))
+    (unshade-window w)
+    (setq pos-x (car (window-position w)))
+    (setq pos-y (cdr (window-position w)))
+    (setq dim-x (car (window-dimensions w)))
+    (setq dim-y (cdr (window-dimensions w)))
+    (setq fdim (window-frame-dimensions w))
+    (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
+
+    (if (eq src 'horiz)
+	(if (eq dest 'opposite)
+	    (progn
+	      (if (eq current-title 'top)
+		  (setq dest 'bottom)
+		(setq dest 'top))
+	      (when (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
+		(setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
+	      (when (<= pos-y 0) (setq pos-y 0)))
+	  ;; Toleft or right
+	  (if (or (eq (window-get w 'type) 'default)
+		  (eq (window-get w 'type) 'transient))
+	      (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew))
+	    (setq framehigh (+ styletab:title-dimension framew)))
+	  (setq dim-x (- dim-x framehigh))
+	  (setq dim-y (+ dim-y framehigh))
+	  (when (and (eq dest 'left) (<= pos-x 0))
+	    (setq pos-x 0))
+	  (when (and (eq dest 'right)
+		     (>= (+ pos-x dim-x framehigh framew framew) (screen-width)))
+	    (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew))))
+      ;; vert
+      (if (eq dest 'opposite)
+	  (progn
+	    (if (eq current-title 'left)
+		(progn
+		  (setq dest 'right)
+		  (when (>= (+ pos-x dim-x) (screen-width))
+		    (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew))))
+	      (setq dest 'left)
+	      (when (<= pos-x 0) (setq pos-x 0))))
+	;; To top or bottom
+	(if (or (eq (window-get w 'type) 'default)
+		(eq (window-get w 'type) 'transient))
+	    (setq framehigh (- styletab:title-dimension (* styletab:borders-dimension 2)))
+	  (setq framehigh styletab:title-dimension))
+	(setq dim-x (+ dim-x framehigh framew))
+	(setq dim-y (- dim-y framehigh framew))
+	(when (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
+	  (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
+	(when (<= pos-y 0) (setq pos-y 0))))
+    
+    (window-put w 'title-position dest)
+    (tab-refresh-group w 'title-position)
+    (call-window-hook 'window-state-change-hook w (list '(title-position)))
+    (tab-refresh-group w 'reframe)
+    (move-window-to w pos-x pos-y)
+    (resize-window-to w dim-x dim-y)))
+
+(define (horiz-button1)
+  "To left, move tab-bar."
+  (rotate-tab 'horiz 'left))
+(define (horiz-button2)
+  "To opposite, move tab-bar. (Swap top & bottom)"
+  (rotate-tab 'horiz 'opposite))
+(define (horiz-button3)
+  "To right, move tab-bar."
+  (rotate-tab 'horiz 'right))
+
+(define (vert-button1)
+  "To top, move tab-bar."
+  (rotate-tab 'vert 'top))
+(define (vert-button2)
+  "To opposite, move tab-bar. (Swap left & right)"
+  (rotate-tab 'vert 'opposite))
+(define (vert-button3)
+  "To bottom, move tab-bar."
+  (rotate-tab 'vert 'bottom))
+
+(define-command-gaol 'horiz-button1 horiz-button1)
+(define-command-gaol 'horiz-button2 horiz-button2)
+(define-command-gaol 'horiz-button3 horiz-button3)
+(define-command-gaol 'vert-button1 vert-button1)
+(define-command-gaol 'vert-button2 vert-button2)
+(define-command-gaol 'vert-button3 vert-button3)
+
 (def-frame-class tabbar-horizontal-left-edge ()
-  (bind-keys
-   tabbar-horizontal-left-edge-keymap "Button1-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim (window-dimensions w))
-       (setq fdim (window-frame-dimensions w))
-       (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ (car dim) (cdr dim) styletab:title-dimension)) 3))
-       (if (eq current-title 'right)
-           (setq framehigh 0)
-         (if (or (eq (window-get w
-                                 'type) 'default)
-                 (eq (window-get w
-                                 'type) 'transient))
-             (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew))
-           (setq framehigh (+ styletab:title-dimension framew))))
-       (setq dim-x (- (car (window-dimensions w))
-                      framehigh))
-       (setq dim-y (+ (cdr (window-dimensions w))
-                      framehigh))
-       (if (<= pos-x 0) (setq pos-x 0))
-       (window-put w 'title-position 'left)
-       (tab-refresh-group w 'title-position)
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y))))
-  (bind-keys
-   tabbar-horizontal-left-edge-keymap "Button2-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim-x (car (window-dimensions w)))
-       (setq dim-y (cdr (window-dimensions w)))
-       (setq fdim (window-frame-dimensions w))
-       (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
-       (setq type (window-get w 'type))
-       (if (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-           (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
-       (if (<= pos-y 0) (setq pos-y 0))
-       (if (eq current-title 'top)
-           (window-put w 'title-position 'bottom)      
-         (window-put w 'title-position 'top))
-       (if (eq current-title 'top)
-           (tab-refresh-group w 'title-position)
-         (tab-refresh-group w 'title-position))
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y))))
-  (bind-keys
-   tabbar-horizontal-left-edge-keymap "Button3-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim (window-dimensions w))
-       (setq fdim (window-frame-dimensions w))
-       (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ (car dim) (cdr dim) styletab:title-dimension)) 3))
-       (if (eq current-title 'left)
-           (setq framehigh 0)
-         (if (or (eq (window-get w
-                                 'type) 'default)
-                 (eq (window-get w
-                                 'type) 'transient))
-             (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew))
-           (setq framehigh (+ styletab:title-dimension framew))))
-       (setq dim-x (- (car (window-dimensions w))
-                      framehigh))
-       (setq dim-y (+ (cdr (window-dimensions w))
-                      framehigh))
-       (if (>= (+ pos-x dim-x framehigh framew framew) (screen-width))
-           (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew)))
-       (window-put w 'title-position 'right)
-       (tab-refresh-group w 'title-position)
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y)))))
+  (bind-keys tabbar-horizontal-left-edge-keymap
+	     "Button1-Off" 'horiz-button1
+	     "Button2-Off" 'horiz-button2
+	     "Button3-Off" 'horiz-button3))
 
 (def-frame-class tabbar-vertical-top-edge ()
-  (bind-keys
-   tabbar-vertical-top-edge-keymap "Button1-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim-x (car (window-dimensions w)))
-       (setq dim-y (cdr (window-dimensions w)))
-       (setq dim (window-dimensions w))
-       (setq fdim (window-frame-dimensions w))
-       (when (not (eq current-title 'left))
-         (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ (car dim) (cdr dim) styletab:title-dimension)) 3))
-         (if (eq current-title 'right)
-             (setq framehigh 0)
-           (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew)))
-         (setq dim-x (- (car (window-dimensions w))
-                        framehigh))
-         (setq dim-y (+ (cdr (window-dimensions w))
-                        framehigh))
-         (if (<= pos-x 0) (setq pos-x 0))
-         (window-put w 'title-position 'left)
-         (tab-refresh-group w 'title-position))
-       (when (eq current-title 'left)
-         (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
-         (if (or (eq (window-get w
-                                 'type) 'default)
-                 (eq (window-get w
-                                 'type) 'transient))
-             (setq framehigh (- styletab:title-dimension (* styletab:borders-dimension 2)))
-           (setq framehigh styletab:title-dimension))
-         (setq dim-x (+ dim-x framehigh framew))
-         (setq dim-y (- dim-y framehigh framew))
-         (if (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-             (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
-         (if (<= pos-y 0) (setq pos-y 0))
-         (window-put w 'title-position 'bottom)
-         (tab-refresh-group w 'title-position))
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y))))
-  (bind-keys
-   tabbar-vertical-top-edge-keymap "Button2-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim-x (car (window-dimensions w)))
-       (setq dim-y (cdr (window-dimensions w)))
-       (setq fdim (window-frame-dimensions w))
-       (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
-       (if (or (eq (window-get w
-                               'type) 'default)
-               (eq (window-get w
-                               'type) 'transient))
-           (setq framehigh (- styletab:title-dimension (* styletab:borders-dimension 2)))
-         (setq framehigh styletab:title-dimension))
-       (setq dim-x (+ dim-x framehigh framew))
-       (setq dim-y (- dim-y framehigh framew))
-       (if (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-           (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
-       (if (<= pos-y 0) (setq pos-y 0))
-       (window-put w 'title-position 'top)
-       (tab-refresh-group w 'title-position)
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y))))
-  (bind-keys
-   tabbar-vertical-top-edge-keymap "Button3-Off"
-   '(call-command
-     (lambda ()
-       (require 'sawfish.wm.tabs.tabgroup)
-       (setq w (current-event-window))
-       (if (not (window-get w 'title-position))
-           (case styletab:titlebar-place
-                 ((top) (setq current-title 'top))
-                 ((bottom) (setq current-title 'bottom))
-                 ((left) (setq current-title 'left))
-                 ((right) (setq current-title 'right)))
-         (setq current-title (window-get w 'title-position)))
-       (unshade-window w)
-       (setq pos-x (car (window-position w)))
-       (setq pos-y (cdr (window-position w)))
-       (setq dim-x (car (window-dimensions w)))
-       (setq dim-y (cdr (window-dimensions w)))
-       (setq dim (window-dimensions w))
-       (setq fdim (window-frame-dimensions w))
-       (when (not (eq current-title 'right))
-         (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ (car dim) (cdr dim) styletab:title-dimension)) 3))
-         (if (eq current-title 'left)
-             (setq framehigh 0)
-           (setq framehigh (+ (- styletab:title-dimension (* styletab:borders-dimension 2)) framew)))
-         (setq dim-x (- (car (window-dimensions w))
-                        framehigh))
-         (setq dim-y (+ (cdr (window-dimensions w))
-                        framehigh))
-         (if (>= (+ pos-x dim-x) (screen-width))
-             (setq pos-x (- (screen-width) dim-x styletab:title-dimension framew)))
-         (window-put w 'title-position 'right)
-         (tab-refresh-group w 'title-position))
-       (when (eq current-title 'right)
-         (setq framew (/ (- (+ (car fdim) (cdr fdim)) (+ dim-x dim-y styletab:title-dimension)) 3))
-         (if (or (eq (window-get w
-                                 'type) 'default)
-                 (eq (window-get w
-                                 'type) 'transient))
-             (setq framehigh (- styletab:title-dimension (* styletab:borders-dimension 2)))
-           (setq framehigh styletab:title-dimension))
-         (setq dim-x (+ dim-x framehigh framew))
-         (setq dim-y (- dim-y framehigh framew))
-         (if (>= (+ pos-y dim-y styletab:title-dimension framew) (screen-height))
-             (setq pos-y (- (screen-height) dim-y styletab:title-dimension framew)))
-         (if (<= pos-y 0) (setq pos-y 0))
-         (window-put w 'title-position 'bottom)
-         (tab-refresh-group w 'title-position))
-       (call-window-hook 'window-state-change-hook w (list '(title-position)))
-       (tab-refresh-group w 'reframe)
-       (move-window-to w pos-x pos-y)
-       (resize-window-to w dim-x dim-y)))))
+  (bind-keys tabbar-vertical-top-edge-keymap
+	     "Button1-Off" 'vert-button1
+	     "Button2-Off" 'vert-button2
+	     "Button3-Off" 'vert-button3))
 
 (defvar prev-button-keymap
   (bind-keys (make-keymap)



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