[sawfish] New command 'maximize-discard'. Don't treat window as maximized any more, keeping the size and the p



commit ee6f3fb8444cb73cb33c3e4b88693965c8898b87
Author: Teika kazura <teika lavabit com>
Date:   Sat Jan 9 21:59:49 2010 +0900

    New command 'maximize-discard'.
    Don't treat window as maximized any more, keeping the size and the
    position. You'll be able to move and resize, but won't be able to unmaximize.
    
    The function 'maximize-discard' has existed, but it's now exported,
    and documented. The grammar has changed, but since it was internal,
    it doesn't affect the world.
    
    Some document improvements in maximization are done.
    In maximize.jl, some related codes are collected.

 lisp/sawfish/wm/state/maximize.jl |   55 +++++++++++++++++++++++++++----------
 man/news.texi                     |   19 +++++++++++++
 man/sawfish.texi                  |   40 +++++++++++++++++++--------
 3 files changed, 87 insertions(+), 27 deletions(-)
---
diff --git a/lisp/sawfish/wm/state/maximize.jl b/lisp/sawfish/wm/state/maximize.jl
index c55ff3a..8fe1a2e 100644
--- a/lisp/sawfish/wm/state/maximize.jl
+++ b/lisp/sawfish/wm/state/maximize.jl
@@ -48,7 +48,8 @@
 	    maximize-window-fullscreen
 	    maximize-window-fullscreen-toggle
 	    maximize-window-fullxinerama
-	    maximize-window-fullxinerama-toggle)
+	    maximize-window-fullxinerama-toggle
+	    maximize-discard)
 
     (open rep
 	  rep.system
@@ -88,7 +89,8 @@ that dimension.")
   (defcustom move-lock-when-maximized t
     "Lock position and size while windows are maximized."
     :type boolean
-    :group min-max)
+    :group min-max
+    :tooltip "Remember that after you resize a maximized window, you can't unmaximize it any more.")
 
   ;; called when a window is maximized, args (W #!optional DIRECTION)
   (defvar window-maximized-hook nil)
@@ -110,6 +112,7 @@ that dimension.")
   (define (window-maximized-vertically-p w)
     (window-get w 'maximized-vertically))
 
+;;; States before maximization
   (define (window-unmaximized-position w)
     (let ((coords (window-position w))
 	  (old-geom (unmaximized-geometry w)))
@@ -137,17 +140,24 @@ that dimension.")
 	(window-put w 'unmaximized-geometry (list (car coords) (cdr coords)
 						  (car dims) (cdr dims))))))
 
+  ;; Returns (x y width height)
+  (define (unmaximized-geometry w)
+    (window-get w 'unmaximized-geometry))
+
+;;; Discard states before maximization
   (define (discard-unmaximized-geometry w)
     (window-put w 'unmaximized-geometry nil)
     (pop-window-type w 'sawfish.wm.state.maximize))
 
-  (define (unmaximized-geometry w)
-    (window-get w 'unmaximized-geometry))
-
-  (define (maximize-discard w #!optional horizontally vertically)
-    (when horizontally
+  (define (maximize-discard w #!optional direction)
+    "Don't treat window as maximized any more, keeping the size and the
+position. You'll be able to move and resize, but won't be able to unmaximize.
+ If the optional argument `direction' is `vertical' or `horizontal', then
+only that direction is unmaximized.
+ If the window is not maximized, nothing happens."
+    (unless (eq direction 'vertical)
       (window-put w 'maximized-horizontally nil))
-    (when vertically
+    (unless (eq direction 'horizontal)
       (window-put w 'maximized-vertically nil))
     (let ((dims (window-dimensions w))
 	  (coords (window-absolute-position w t))
@@ -163,15 +173,35 @@ that dimension.")
 		 (not (window-maximized-horizontally-p w)))
 	(discard-unmaximized-geometry w))))
 
+  (define-command 'maximize-discard maximize-discard
+    #:spec "%W"
+    #:doc "Don't treat window as maximized any more, keeping the size and the position. You'll be able to move and resize, but won't be able to unmaximize."
+    )
+
+  #|
   (define (maximize-discard-move w directions #!key successful)
     (when successful
       (maximize-discard w (memq 'horizontal directions)
 			(memq 'vertical directions))))
 
+  ;; This is now disabled - it doesn't really make sense for moving..
+  ;; (add-hook 'after-move-hook maximize-discard-move)
+  |#
+
   (define (maximize-discard-resize w edges #!key successful)
     (when successful
-      (maximize-discard w (or (memq 'left edges) (memq 'right edges))
-			(or (memq 'top edges) (memq 'bottom edges)))))
+      (let ((horiz (or (memq 'left edges) (memq 'right edges)))
+	    (vert (or (memq 'top edges) (memq 'bottom edges))))
+	(cond
+	 ((and horiz (not vert))
+	  (maximize-discard w 'horizontal))
+	 ((and vert (not horiz))
+	  (maximize-discard w 'vertical))
+	 (t
+	  (maximize-discard w))))))
+
+  ;; After the window is resized, then the original size is meaningless.
+  (add-hook 'after-resize-hook maximize-discard-resize)
 
 ;;; 1D packing
 
@@ -675,10 +705,5 @@ t")
    'unmaximized-geometry 'maximized-vertically
    'maximized-horizontally 'maximized-fullscreen)
 
-  ;; This is now disabled - it doesn't really make sense for moving..
-  ;; (add-hook 'after-move-hook maximize-discard-move)
-
-  (add-hook 'after-resize-hook maximize-discard-resize)
-
   (gaol-add window-maximized-p window-maximized-horizontally-p
 	    window-maximized-vertically-p))
diff --git a/man/news.texi b/man/news.texi
index 8826c5f..24fab59 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -7,6 +7,25 @@ they occurred between. For more detailed information see the
 @file{ChangeLog} file in the Sawfish source tree, or git log.
 (See Wiki page for how to access git repository.)
 
+ heading 1.6.2
+
+ itemize @bullet
+
+ item The 1.6.2 release has some improvements.
+
+ item New features
+ itemize @minus
+ item New command @code{maximize-discard} [Teika kazura]
+
+The command @code{maximize-discard} stops a maximized window to be
+treated as maximized any more, so that you can move and resize the
+window.
+
+The functinon @code{maximize-discard} has existed, and now it's
+exported.
+ end itemize
+ end itemize
+
 @heading 1.6.1 "Astral"
 
 @itemize @bullet
diff --git a/man/sawfish.texi b/man/sawfish.texi
index d5468e8..cdce01b 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -2203,11 +2203,13 @@ Return @code{t} when @var{window} is maximized in any direction.
 @end defun
 
 @defun window-maximized-vertically-p window
-Return @code{t} when @var{window} is vertically maximized.
+Return @code{t} when @var{window} is vertically maximized, regardless
+if it's horizontally maximized or not.
 @end defun
 
 @defun window-maximized-horizontally-p window
-Return @code{t} when @var{window} is horizontally maximized.
+Return @code{t} when @var{window} is horizontally maximized, regardless
+if it's vertically maximized or not.
 @end defun
 
 @menu
@@ -2273,6 +2275,9 @@ the windows along their maximized axes.
 
 For example, a vertically maximized window is vertically locked, so a
 user can slide it left and right, but cannot move it up or down.
+
+If you set this to @code{nil} and resize a maximized window, then
+you can't unmaximize it any more.
 @end defvr
 
 @defun window-locked-vertically-p window
@@ -2426,11 +2431,11 @@ maximization.
 Restore the position and dimensions of @var{window} to their original,
 unmaximized, states.
 
-Positions and dimensions that were not maximized are not affected by
-unmaximizing.
+If the window is maximized for example vertically but not
+horizontally, then only vertical position and dimension are restored.
 
 If defined, @var{direction} is a symbol, either @code{vertical} or
- code{horizontal}, and maximization will only occur for that
+ code{horizontal}, and unmaximization will only occur for that
 direction.
 @end deffn
 
@@ -2438,18 +2443,29 @@ direction.
 Returns a cons-cell @code{(@var{x} . @var{y})} indicating the position
 that the @code{window} would unmaximize to.
 
-Sawfish preserves the positions of maximized axes only, so a
-vertically maximized window will be restored to its original @var{y}
-coordinate, but its @var{x} coordinate may have changed.
+If the window is maximized for example vertically but not
+horizontally, then @var{y} is the y coordinate before maximization,
+but @var{x} is the window's current x coordinate.
 @end defun
 
 @defun window-unmaximized-dimensions window
 Returns a cons-cell @code{(@var{w} . @var{h})} indicating the
 dimensions that @code{window} would unmaximize to.
 
-Sawfish preserves the dimensions of maximized axes only, so a
-vertically maximized window will be restored to its original @var{h}
-dimension, but its @var{w} coordinate may have changed.
+If the window is maximized for example vertically but not
+horizontally, then @var{y} is the height before maximization, but
+ var{x} is the window's current width.
+ end defun
+
+ defun maximize-discard window &optional direction
+Don't treat window as maximized any more, keeping the size and the
+position. You'll be able to move and resize, but won't be able to
+unmaximize.
+
+If the optional argument `direction' is `vertical' or `horizontal',
+then only that direction is unmaximized.
+
+When @var{window} is not maximized, nothing happens.
 @end defun
 
 @node Cycling Between Windows, Window Rules by Matching, Maximizing Windows, Windows
@@ -6387,7 +6403,7 @@ defined by the variable as follows:
 @item @code{hibernate} @tab @code{hibernate-command}
 @end multitable
 
-When @var{action} is @code{reboot} or @code{halt}, 
+When @var{action} is @code{reboot} or @code{halt},
 @code{before-exit-hook} is called, and @code{delete-windows} is
 applied to each window to ensure we safely quit the current session.
 @end defun



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