[sawfish] Functions of "resize-window-to-preset-size" family are defined, based on "resize-window-to-dimension



commit 2ce4a53391aa2b89da3bd9782148e6e57ea51ef1
Author: Teika kazura <teika lavabit com>
Date:   Tue Mar 1 13:06:56 2011 +0900

    Functions of "resize-window-to-preset-size" family are defined, based on "resize-window-to-dimension".
    
    * Remane "resize-window-to-dimension" -> "resize-window-to-preset-size"
    * New functions "resize-window-to-preset-height" & "-width".
    * News and documents.

 lisp/sawfish/wm/commands/move-resize.jl |   56 ++++++++++++++++++++++++-------
 man/news.texi                           |    7 ++++
 man/sawfish.texi                        |    8 ++++
 3 files changed, 59 insertions(+), 12 deletions(-)
---
diff --git a/lisp/sawfish/wm/commands/move-resize.jl b/lisp/sawfish/wm/commands/move-resize.jl
index f2c0c9f..28a112e 100644
--- a/lisp/sawfish/wm/commands/move-resize.jl
+++ b/lisp/sawfish/wm/commands/move-resize.jl
@@ -22,7 +22,6 @@
 
     (export move-window-interactively
 	    resize-window-interactively
-	    resize-window-to-dimensions
 	    move-selected-window
 	    resize-selected-window
 	    double-window-size
@@ -562,12 +561,6 @@ its edges with an edge of another window.")
     (unless (window-get w 'fixed-size)
       (do-move-resize w 'resize)))
 
-  (define (resize-window-to-dimensions x y #!key window)
-    "Resize the current window to the specified dimensions"
-    (if window
-        (resize-window-with-hints* window x y)
-      (resize-window-with-hints* (current-event-window) x y)))
-
   (define (move-selected-window)
     "Wait for the user to select a window, then interactively move
 that window."
@@ -591,6 +584,50 @@ that window."
                     (quotient (- (screen-height)
                                  (cdr (window-frame-dimensions w))) 2)))
 
+  ;; resize-to-preset-size family
+  (define (resize-window-to-preset-size x y)
+    ;; The size is set beforehand in the configurator.
+    (let ((w (current-event-window)))
+      (when (or (null w) (eq w 'root))
+	(setq w (input-focus)))
+      (resize-window-with-hints* w x y)))
+
+  (define-command 'resize-window-to-preset-size
+    resize-window-to-preset-size
+    #:spec "NNew width:\nNNew height:"
+    #:doc "Resize a window to the size you specify here."
+    #:type '(and (labelled "New width:" (number 10))
+		 (labelled "New height:" (number 10)))
+    )
+
+  (define (resize-window-to-preset-width x)
+    ;; The width is set beforehand in the configurator.
+    (let ((w (current-event-window)))
+      (when (or (null w) (eq w 'root))
+	(setq w (input-focus)))
+      (resize-window-with-hints* w x
+				 (cdr (window-dimensions w)))))
+  (define-command 'resize-window-to-preset-width
+    resize-window-to-preset-width
+    #:doc "Resize a window to the width you specify here."
+    #:spec "NNew width:"
+    #:type `(and (labelled "New width:" (number 10)))
+    )
+
+  (define (resize-window-to-preset-height y)
+    ;; The height is set beforehand in the configurator.
+    (let ((w (current-event-window)))
+      (when (or (null w) (eq w 'root))
+	(setq w (input-focus)))
+      (resize-window-with-hints* w
+				 (car (window-dimensions w)) y)))
+  (define-command 'resize-window-to-preset-height
+    resize-window-to-preset-height
+    #:doc "Resive a window to the height you specify here."
+    #:spec "NNew height:"
+    #:type '(and (labelled "New height:" (number 10)))
+    )
+
   ;;###autoload
   (define-command 'move-window-center
     move-window-center #:spec "%W")
@@ -598,11 +635,6 @@ that window."
     move-window-interactively #:spec "%W")
   (define-command 'resize-window-interactively
     resize-window-interactively #:spec "%W")
-  (define-command 'resize-window-to-dimensions
-    resize-window-to-dimensions
-    #:spec "NNew width:\nNNew height:"
-    #:type '(and (labelled "New width:" (number 100))
-		 (labelled "New height:" (number 100))))
   (define-command 'move-selected-window
     move-selected-window)
   (define-command 'resize-selected-window
diff --git a/man/news.texi b/man/news.texi
index 52d3283..afbb145 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -234,6 +234,13 @@ For the details, see @xref{Window Attributes}, and @xref{Getting Windows}.
 @item Added functions @code{window-role} and @code{get-window-by-role} (return NET_WM_ROLE) 
 @item Deleted @code{get-window-by-name-re} and @code{get-window-by-class-re}. Use instead @code{get-window-by-name} or @code{get-window-by-class} with the new boolean option @code{#:regex}. (The old name is still supported.)
 @item added @code{#:icon} switch to @code{get-window-by-name} to get a window via NET_WM_ICON_NAME (can be used with #:regex switch, too)
+
+ item Commands to resize a window to preset dimensions [Christopher Bratusek]
+
+For the new command @code{resize-window-to-preset-size}, first you
+specify a size in the configurator. The focused window will be resized
+to that preset size on invocation. There're also commands to change
+only one of the height and width.
 @end itemize
 
 @item Window-operation menu improvements [Christopher Bratusek]
diff --git a/man/sawfish.texi b/man/sawfish.texi
index 12f19c7..ce35619 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -1976,6 +1976,14 @@ the mouse pointer gives the direction to resize in. If the pointer is
 in the central rectangle the bottom and right edges are moved.
 @end deffn
 
+ deffn Command resize-window-to-preset-size
+ deffnx Command resize-window-to-preset-height
+ deffnx Command resize-window-to-preset-width
+For these commands, first you specify a window dimension(s) in the
+configurator. The focused window will be resized to that preset size
+on invocation.
+ end deffn
+
 @deffn Function move-selected-window
 @deffnx Command move-selected-window
 Wait for the user to select a window using the mouse, then



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