[sawfish/viewport] Bug fixes and doc improvements:



commit 52f6a8f667c6d5a354b13ba66d84624fe9456cc5
Author: Jeremy Hankins <nowan nowan org>
Date:   Wed Oct 21 09:07:07 2009 -0500

    Bug fixes and doc improvements:
    
    * viewport-window now gives the viewport where the majority of the
      window is found.
    
    * windows that were maximized both horizontally and vertically
      weren't being handled properly when they were not in viewport
      0,0.
    
    * infinite-desktop now checks viewport-honor-workspace-edges before
      allowing movement past virtual workspace boundaries.  Added
      documentation to sawfish.texi for the new viewport-honor-workspace-edges
      function.
    
    * Fixed a typo in window-outside-workspace-p; also fixed the docstring.
    
    * Made a note in news.texi about the default behavior of
      infinite-desktop changing.
    
    * New functions: rect-wholly-within-rect, viewport-at,
      rect-within-viewport-p, rect-within-head-p, window-head-any-viewport,
      viewport-honor-workspace-edges
    
    * New docs for sawfish.wm.util.rects.

 ChangeLog                               |   15 +++
 lisp/sawfish/wm/ext/infinite-desktop.jl |   14 +--
 lisp/sawfish/wm/state/maximize.jl       |   22 ++--
 lisp/sawfish/wm/util/compat.jl          |    3 +-
 lisp/sawfish/wm/util/rects.jl           |   10 +-
 lisp/sawfish/wm/util/workarea.jl        |   24 ++--
 lisp/sawfish/wm/viewport.jl             |   94 ++++++++++++++-
 man/news.texi                           |    4 +-
 man/sawfish.texi                        |  190 ++++++++++++++++++++++++++++++-
 9 files changed, 331 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e9618f8..ee6e2e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-10-21  Jeremy Hankins <nowan nowan org>
+	* lisp/sawfish/wm/state/maximize.jl
+	* lisp/sawfish/wm/util/compat.jl
+	* lisp/sawfish/wm/util/rects.jl
+	* lisp/sawfish/wm/util/workarea.jl
+	* lisp/sawfish/wm/viewport.jl
+	* man/news.texi: Fix bugs introduced by the recent changes to allow maximization outside of the current viewport:
+	                 - viewport-window now gives the viewport where most of the window is located.
+	                 - A few new functions for working with rectangles.
+
+	* lisp/sawfish/wm/ext/infinite-desktop.jl: infinite-desktop now checks viewport-honor-workspace-edges
+	                                           (in sawfish.wm.viewport) before allowing movement past workspace boundaries.
+
+	* man/sawfish.texi: Adjustments to viewport docs; new docs for sawfish.wm.util.rects.
+
 2009-10-11  Jeremy Hankins <nowan nowan org>
 	* lisp/sawfish/wm/ext/match-window.jl
 	* lisp/sawfish/wm/state/maximize.jl
diff --git a/lisp/sawfish/wm/ext/infinite-desktop.jl b/lisp/sawfish/wm/ext/infinite-desktop.jl
index 8f09b0d..ea3fcb6 100644
--- a/lisp/sawfish/wm/ext/infinite-desktop.jl
+++ b/lisp/sawfish/wm/ext/infinite-desktop.jl
@@ -65,12 +65,6 @@
     :type number
     :range (1 . nil))
 
-  (define (infinite-desktop.stop-at-workspace-borders)
-    "Whether or not to prevent the display from moving past the
-current viewport boundaries.  Returns true if `viewport-boundary-mode'
-is not set to 'dynamic."
-    (not (eq viewport-boundary-mode 'dynamic)))
-
   (define (infinite-desktop.move-right)
     "Shifts the display `infinite-desktop.move-distance' pixels to the
 right."
@@ -78,7 +72,7 @@ right."
           (cdist infinite-desktop.move-cursor-distance)
           (maxx (* (screen-width) (1- (car viewport-dimensions)))))
       (if
-          (and (infinite-desktop.stop-at-workspace-borders)
+          (and (viewport-honor-workspace-edges)
                (> (+ dist viewport-x-offset) maxx))
           (setq dist (- maxx viewport-x-offset)))
       (set-viewport (+ viewport-x-offset dist) viewport-y-offset)
@@ -91,7 +85,7 @@ left."
           (cdist (- infinite-desktop.move-cursor-distance))
           (minx 0))
       (if
-          (and (infinite-desktop.stop-at-workspace-borders)
+          (and (viewport-honor-workspace-edges)
                (< (+ viewport-x-offset dist) minx))
           (setq dist (- minx viewport-x-offset)))
       (set-viewport (+ viewport-x-offset dist) viewport-y-offset)
@@ -103,7 +97,7 @@ left."
           (cdist (- infinite-desktop.move-cursor-distance))
           (miny 0))
       (if
-          (and (infinite-desktop.stop-at-workspace-borders)
+          (and (viewport-honor-workspace-edges)
                (< (+ viewport-y-offset dist) miny))
           (setq dist (- miny viewport-y-offset)))
       (set-viewport viewport-x-offset (+ viewport-y-offset dist))
@@ -115,7 +109,7 @@ left."
           (cdist infinite-desktop.move-cursor-distance)
           (maxy (* (screen-height) (1- (cdr viewport-dimensions)))))
       (if
-          (and (infinite-desktop.stop-at-workspace-borders)
+          (and (viewport-honor-workspace-edges)
                (> (+ dist viewport-y-offset) maxy))
           (setq dist (- maxy viewport-y-offset)))
       (set-viewport viewport-x-offset (+ viewport-y-offset dist))
diff --git a/lisp/sawfish/wm/state/maximize.jl b/lisp/sawfish/wm/state/maximize.jl
index b6c98a0..63e547b 100644
--- a/lisp/sawfish/wm/state/maximize.jl
+++ b/lisp/sawfish/wm/state/maximize.jl
@@ -226,8 +226,9 @@ that dimension.")
 	  (cons perp-1 perp-2)))))
 
   (define (do-horizontal w edges coords dims fdims)
-    (let ((head-offset (current-head-offset w))
-	  (head-dims (current-head-dimensions w)))
+    (let* ((head (window-head-any-viewport w))
+           (head-offset (head-offset head))
+           (head-dims (head-dimensions head)))
       (let ((x-span (expand-edges (cdr coords) (+ (cdr coords) (cdr fdims))
 				  (car head-offset)
 				  (+ (car head-offset) (car head-dims))
@@ -239,8 +240,9 @@ that dimension.")
 	w)))
 
   (define (do-vertical w edges coords dims fdims)
-    (let ((head-offset (current-head-offset w))
-	  (head-dims (current-head-dimensions w)))
+    (let* ((head (window-head-any-viewport w))
+           (head-offset (head-offset head))
+           (head-dims (head-dimensions head)))
       (let ((y-span (expand-edges (car coords) (+ (car coords) (car fdims))
 				  (cdr head-offset)
 				  (+ (cdr head-offset) (cdr head-dims))
@@ -255,7 +257,9 @@ that dimension.")
 
   (define (do-both window avoided edges coords dims fdims)
     (let ((max-rect (largest-rectangle-from-edges
-		     edges #:avoided avoided #:head (current-head window))))
+		     edges
+                     #:avoided avoided
+                     #:head (window-head-any-viewport window))))
       (when max-rect
 	(rplaca coords (nth 0 max-rect))
 	(rplacd coords (nth 1 max-rect))
@@ -343,10 +347,8 @@ that dimension.")
     (when (window-maximized-fullscreen-p w)
       (maximize-window-fullscreen w nil))
     (let* ((viewport (window-viewport w))
-           (vp-offset (viewport-offset viewport))
            (coords (window-position w))
-           (head (find-head (- (car coords) (car vp-offset))
-                            (- (cdr coords) (cdr vp-offset))))
+           (head (window-head-any-viewport w))
            (dims (window-dimensions w))
            (fdims (window-frame-dimensions w))
            (hints (window-size-hints w))
@@ -532,9 +534,7 @@ unmaximized."
 	   (when (window-maximizable-p w)
              (let* ((viewport (window-viewport w))
                     (vp-offset (viewport-offset viewport))
-                    (coords (window-position w))
-                    (head (find-head (- (car coords) (car vp-offset))
-                                     (- (cdr coords) (cdr vp-offset))))
+                    (head (window-head-any-viewport w))
                     (head-offset (head-offset head))
                     (head-dims (head-dimensions head)))
 	       (save-unmaximized-geometry w)
diff --git a/lisp/sawfish/wm/util/compat.jl b/lisp/sawfish/wm/util/compat.jl
index a190cbe..b979c34 100644
--- a/lisp/sawfish/wm/util/compat.jl
+++ b/lisp/sawfish/wm/util/compat.jl
@@ -117,7 +117,8 @@
           nokogiri-user-level nokogiri-buttons workspace-boundary-mode
           workspace-send-boundary-mode lock-first-workspace
           ignore-window-input-hint workspace-geometry
-          pointer-motion-threshold ignore-program-positions))
+          pointer-motion-threshold ignore-program-positions
+          infinite-desktop.stop-at-workspace-borders))
 
 ;;; obsolete custom setters
 
diff --git a/lisp/sawfish/wm/util/rects.jl b/lisp/sawfish/wm/util/rects.jl
index 3ec8777..89c1a60 100644
--- a/lisp/sawfish/wm/util/rects.jl
+++ b/lisp/sawfish/wm/util/rects.jl
@@ -36,6 +36,7 @@
 	    rect-2d-overlap
 	    rect-2d-overlap*
 	    rect-total-overlap
+            rect-wholly-within-rect
 	    rect-wholly-visible-p
 	    rectangle-heads)
 
@@ -266,17 +267,20 @@ dimensions DIMS and origin POINT, while the other is defined by RECT."
   (define (rect-total-overlap dims point rects)
     "Returns the total area of the overlap between a rectangle defined by
 DIMS and POINT, and the list of rectangles RECTS when placed at POINT."
-
     (let ((total 0))
       (mapc (lambda (r)
 	      (setq total (+ total (rect-2d-overlap dims point r))))
 	    rects)
       total))
 
+  (define (rect-wholly-within-rect outer inner)
+    "Return t if INNER is completely inside the boundaries of OUTER."
+    (eq (rect-obscured inner outer) 'fully-obscured))
+
   (define (rect-wholly-visible-p rect)
     "Return t if RECT is completely inside the screen boundaries."
-    (and (>= (car rect) 0) (>= (nth 1 rect) 0)
-	 (<= (nth 2 rect) (screen-width)) (<= (nth 3 rect) (screen-height))))
+    (rect-wholly-within-rect (list 0 0 (screen-width) (screen-height))
+                             rect))
 
   (define (rectangle-heads rect)
     "Return the number of screen heads that rectangle RECT appears on."
diff --git a/lisp/sawfish/wm/util/workarea.jl b/lisp/sawfish/wm/util/workarea.jl
index b1a15c9..16edfc0 100644
--- a/lisp/sawfish/wm/util/workarea.jl
+++ b/lisp/sawfish/wm/util/workarea.jl
@@ -33,6 +33,7 @@
 	  sawfish.wm.util.rects
 	  sawfish.wm.windows
 	  sawfish.wm.workspace
+          sawfish.wm.viewport
 	  sawfish.wm.misc)
 
   (define (define-window-strut w left top right bottom)
@@ -66,29 +67,30 @@
       ;; or span multiple heads, or be on a different head
       ;; to that requested
       (let loop ((rest avoided))
-           (cond ((null rest) t)
-                 ((or (> (rect-2d-overlap
-                          (window-frame-dimensions (car rest))
-                          (window-position (car rest))
-                          rect) 0)
-                      (/= (rectangle-heads rect) 1)
-                      (and head (/= head (find-head (car rect) (cadr rect)))))
+           (cond ((null rest) (rect-within-head-p rect head))
+                 ((> (rect-2d-overlap
+                      (window-frame-dimensions (car rest))
+                      (window-position (car rest))
+                      rect)
+                     0)
                   nil)
                  (t (loop (cdr rest))))))
 
     (let* ((grid (grid-from-edges (car edges) (cdr edges)))
 	   ;; find all possible rectangles
-	   (rects (rectangles-from-grid
-		   (sort (car grid)) (sort (cdr grid)) pred)))
+           (rects (rectangles-from-grid (sort (car grid))
+                                        (sort (cdr grid))
+                                        pred)))
 
       ;; return the largest
       (let ((max-area 0)
 	    (max-rect nil))
 	(mapc (lambda (rect)
-		(when (and (rect-wholly-visible-p rect)
+		(when (and (rect-within-viewport-p rect)
 			   (> (rectangle-area rect) max-area))
 		  (setq max-area (rectangle-area rect))
-		  (setq max-rect rect))) rects)
+		  (setq max-rect rect)))
+              rects)
 	max-rect)))
 
   (define (calculate-workarea #!key window head)
diff --git a/lisp/sawfish/wm/viewport.jl b/lisp/sawfish/wm/viewport.jl
index 77c0909..68aa6d4 100644
--- a/lisp/sawfish/wm/viewport.jl
+++ b/lisp/sawfish/wm/viewport.jl
@@ -31,12 +31,17 @@
 	    move-window-to-current-viewport
 	    set-window-viewport
 	    move-window-viewport
+            viewport-at
 	    window-viewport
             viewport-offset
             window-relative-position
 	    window-absolute-position
 	    set-number-of-viewports
+            rect-within-viewport-p
+            rect-within-head-p
+            window-head-any-viewport
 	    viewport-minimum-size-changed
+            viewport-honor-workspace-edges
 	    viewport-windows)
 
     (open rep
@@ -47,6 +52,7 @@
 	  sawfish.wm.commands
 	  sawfish.wm.workspace
 	  sawfish.wm.custom
+          sawfish.wm.util.rects
 	  sawfish.wm.session.init)
 
   ;; Virtual workspaces are implemented by moving windows in and out of
@@ -91,6 +97,12 @@
   (defvar viewport-x-offset 0)
   (defvar viewport-y-offset 0)
 
+  (define (viewport-honor-workspace-edges)
+    "Whether or not to prevent the display from moving past the
+current viewport boundaries.  Returns true if `viewport-boundary-mode'
+is not set to 'dynamic."
+    (not (eq viewport-boundary-mode 'dynamic)))
+
   (define (warp-viewport x y)
     "Change view by incrementing the coordinates of the x,y position."
     (define (move-window w)
@@ -324,7 +336,7 @@ viewport."
 	  (<= (+ (cdr pos) (cdr dims)) top))))
 
   (define (window-outside-viewport-p window #!optional viewport)
-    "True if some part of `window' is inside the current viewport.  If
+    "True if no part of `window' is inside the current viewport.  If
 `viewport' is specified check against that viewport rather than the
 current one."
     (let* ((cur-vp (screen-viewport))
@@ -339,7 +351,7 @@ current one."
                       (* (- (cdr viewport) (cdr cur-vp))
                          height)
                     0))
-           (y-max (+ y-min width))
+           (y-max (+ y-min height))
            (pos (window-position window))
            (dims (window-frame-dimensions window)))
       (or (<= (+ (car pos) (car dims)) x-min)
@@ -372,12 +384,82 @@ current one."
 			   (+ (quotient (+ (cdr pos) viewport-y-offset)
 					(screen-height)) row))))
 
+  (define (viewport-at x y)
+    "Returns a cons cell consisting of the column and row of the
+viewport containing the specified coordinates."
+    (let ((x (+ x viewport-x-offset))
+          (y (+ y viewport-y-offset)))
+      ;; If x or y is negative the viewport must be adjusted by one.
+      (cons (- (quotient x (screen-width))
+               (if (< x 0)
+                   1
+                 0))
+	    (- (quotient y (screen-height))
+               (if (< y 0)
+                   1
+                 0)))))
+
   (define (window-viewport w)
     "Returns a cons cell consisting of the column and row of the
-viewport containing w."
-    (let ((position (window-position w)))
-      (cons (quotient (+ (car position) viewport-x-offset) (screen-width))
-	    (quotient (+ (cdr position) viewport-y-offset) (screen-height)))))
+viewport containing (or mostly containing) `w'."
+    (let* ((pos (window-position w))
+           (dims (window-dimensions w)))
+      (viewport-at (+ (car pos) (quotient (car dims) 2))
+                   (+ (cdr pos) (quotient (cdr dims) 2)))))
+
+  ;; From sawfish.wm.util.rects:
+  ;; A rectangle is (LEFT TOP RIGHT BOTTOM [WEIGHT])
+  ;; The left and top edges are considered part of the rectangle,
+  ;; the right and bottom edges are not.
+
+  (define (rect-within-viewport-p rect #!optional viewport)
+    "Return t if `rect' is entirely inside the screen boundaries for
+some viewport, regardless of whether it is the current viewport, or
+even if the viewport currently exists.  If `viewport' is specified
+check only against that viewport."
+    (let ((vp (viewport-at (car rect) (nth 1 rect))))
+      (when (or (null viewport) (equal vp viewport))
+        (let ((offset (viewport-offset vp)))
+          (rect-wholly-within-rect (list (car offset)
+                                         (cdr offset)
+                                         (+ (car offset) (screen-width))
+                                         (+ (cdr offset) (screen-height)))
+                                   rect)))))
+
+  ;; The next two functions should perhaps go in a "heads" module if
+  ;; there were one.  But what makes them interesting is that they
+  ;; must account for viewports, which is why I put them here.
+
+  (define (rect-within-head-p rect #!optional head)
+    "Return t if `rect' is entirely within some head on some
+viewport. If `head' is provided `rect' must be within that head on
+some viewport."
+    (let* ((offset (viewport-offset (viewport-at (car rect)
+                                                 (nth 1 rect))))
+           (left (- (car rect) (car offset)))
+           (top (- (nth 1 rect) (cdr offset)))
+           (right (- (nth 2 rect) (car offset)))
+           (bottom (- (nth 3 rect) (cdr offset)))
+           (head (or head (find-head left top)))
+           (head-pos (head-offset head))
+           (head-dims (head-dimensions head)))
+      (rect-wholly-within-rect (list (car head-pos)
+                                     (cdr head-pos)
+                                     (+ (car head-pos) (car head-dims))
+                                     (+ (cdr head-pos) (cdr head-dims)))
+                               (list left top right bottom))))
+
+  (define (window-head-any-viewport w)
+    "Return the id of the head that would contain `w', if the viewport
+`w' occupies were visible."
+    (let* ((coords (window-position w))
+           (dims (window-dimensions w))
+           (center (cons (+ (car coords) (quotient (car dims) 2))
+                         (+ (cdr coords) (quotient (cdr dims) 2))))
+           (vp-offset (viewport-offset (viewport-at (car center)
+                                                    (cdr center)))))
+      (find-head (- (car center) (car vp-offset))
+                 (- (cdr center) (cdr vp-offset)))))
 
   (define (viewport-offset vp)
     "`vp' is (column . row) of a viewport (whether or not that
diff --git a/man/news.texi b/man/news.texi
index d6bb389..dab6bcc 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -32,7 +32,9 @@ they occurred between. For more detailed information see the
 @item In @code{infinite-desktop} there is no longer any option to
 prevent the viewport from going beyond the edge of the workspace.
 Instead it is prevented if and only if @code{viewport-boundary-mode} is
-not set to @code{'dynamic}.
+not set to @code{'dynamic}.  This means that the default behavior is now
+to stop at workspace boundaries; to acheive the previous behavior set
+ code{viewport-boundary-mode} to @code{'dynamic}.
 
 @item Sawfish now got an implementation of the FDO (freedesktop.org) application menu, it is
 beeing generated, if there's no customized apps-menu
diff --git a/man/sawfish.texi b/man/sawfish.texi
index d69702b..0f366ba 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -3949,6 +3949,19 @@ specified by @code{viewport-minimum-dimensions}.  Defaults to
 @code{wrap-around}.
 @end defvar
 
+ defun viewport-honor-workspace-edges
+Whether or not the display is permitted to move past the current
+viewport boundaries.  It returns true if @code{viewport-boundary-mode}
+is not set to @code{dynamic}.
+ end defun
+
+ defun viewport-at x y
+Returns a cons cell consisting of @code{(column . row)} of the viewport
+containing the specified @code{x} and @code{y} coordinates.  The
+coordinates are specified relative to the current viewport, so
+ code{(viewport-at 0 0)} is equivalent to @code{(screen-viewport)}.
+ end defun
+
 @defun warp-viewport x y
 Change the position of the physical display, such that location
 @code{(@var{x}, @var{y})} is at the top-left of the display.  The
@@ -4500,6 +4513,13 @@ window.  If @var{window} is supplied and @var{nil}, return
 @code{(pointer-head)}.
 @end defun
 
+ defun window-head-any-viewport window
+Like @code{current-head}, this will return the ID of the heand
+containing the specified window.  But unlike @code{current-head},
+ code{window-head-any-viewport} returns the head that the window would
+be in if its viewport were the visible viewport.
+ end defun
+
 @defun current-head-dimensions &optional window
 Return a cons-cell defining the size in pixels of the current head
 (that containing the window @var{window}, or the pointer if
@@ -5530,6 +5550,7 @@ Returns the number of X events waiting to be handled.
 * Pointer Functions::
 * Grab Functions::
 * Display Functions::
+* Rectangle Functions::
 * Gradient Functions::
 * Other Functions::
 @end menu
@@ -5704,7 +5725,7 @@ called.
 @end defun
 
 
- node Display Functions, Gradient Functions, Grab Functions, Miscellaneous Functions
+ node Display Functions, Rectangle Functions, Grab Functions, Miscellaneous Functions
 @section Display Functions
 @cindex Display functions
 @cindex Functions, display
@@ -5788,7 +5809,172 @@ has the input focus.
 @end defun
 
 
- node Gradient Functions, Other Functions, Display Functions, Miscellaneous Functions
+ node Rectangle Functions, Gradient Functions, Display Functions, Miscellaneous Functions
+ section Rectangle Functions
+ cindex Rectangle functions
+ cindex Functions, rectangle
+
+Rectangles define a region of the display.  A rectangle is a list of
+values: @code{(left top right bottom [weight])}.  @code{left} and
+ code{top} are the @code{x} and @code{y} coordinates of the upper left
+corner, @code{right} and @code{bottom} are the coordinates for the lower
+right corner.  @code{weight} is an integer.  The bulk of the rectangle
+management functions are in sawfish.wm.util.rects.
+
+ defun rect-left rect
+The x-axis value of the left side of the rectangle.  Equivalent to
+ code{car}
+ end defun
+
+ defun rect-top rect
+The y-axis value of the top of the rectangle.  Equivalent to
+ code{cadr}
+ end defun
+
+ defun rect-right rect
+The x-axis value of the right side of the rectangle.  Equivalent to
+ code{caddr}
+ end defun
+
+ defun rect-bottom rect
+The y-axis value of the bottom of the rectangle.  Equivalent to
+ code{cadddr}
+ end defun
+
+ defun rect-obscured r by
+Check whether the rectangle @code{r} is wholly or partially contained in
+rectangle @code{by}.  Returns one of the symbols @code{unobscured},
+ code{partially-obscured}, or @code{fully-obscured}.
+ end defun
+
+ defun rect-minus r s &optional tail
+Return a list of rectangles whose union is the part of rectangle
+ code{r} not contained in rectangle @code{s}.  If @code{tail} is given,
+the result is prepended to it.
+ end defun
+
+ defun rectangles-from-grid x-points y-poinst &optional pred
+The two lists of integers @code{x-points} and @code{y-points} define a
+rectangular grid. Return the complete list of rectangles formed by the
+intersections of the grid.
+
+If @code{pred} is defined it is called for each rectangle and only those
+for which it returns @code{t} are added to the returned list.
+
+Assumes that @code{x-points} and @code{y-points} are both sorted
+smallest->largest.
+ end defun
+
+ defun rectangles-from-windows windows &optional weight-fun
+Returns a list of rectangle objects representing the list of window
+objects @code{windows}.
+
+If @code{weight-fun} is defined, it is a function to call on each window
+to return the weight for that window. If not defined, the window's
+ code{weight} property is used instead.
+ end defun
+
+ defun grid-from-rectangles rects &optional with-root
+Given a list of rectangles @code{rects} return a cons cell
+ code{(x-points . y-points)} defining the grid they represent.
+
+If @code{with-root} is non-nil, then add the root window boundaries to
+the grid.
+ end defun
+
+ defun rectangle-area rect
+Returns the area of the specified rectangle.
+ end defun
+
+ defun rectangle-from-coords point dims
+Return the rectangle object with origin @code{point} and dimensions
+ code{dims} 
+ end defun
+
+ defun rectangle-corners
+Return a list of four cons cells representing the coordinates of the
+corners of the rectangle @code{rect}.
+ end defun
+
+ defun rectangle-center rect
+Returns a cons cell of the (approximate, to the nearest integer)
+coordinates of the center of the rectangle @code{rect}.
+ end defun
+
+ defun rectangle-center* point dims
+The same as @code{rectangle-center} except that the rectangle is
+specified via the x,y coordinates @code{point} and the dimensions
+ code{dims} 
+ end defun
+
+ defun rectangle-union rect1 rect2
+Gives the smallest rectangle containing both @code{rect1} and
+ code{rect2}   The weight of the resulting rectangle is the weight of
+ code{rect1} 
+ end defun
+
+ defun rectangle-intersection rect1 rect2
+Gives the intersection of the two rectangles @code{rect1} and
+ code{rect2}   The weigth of the resultant rectangle is the weight of
+ code{rect1}   Returns @code{nil} if there the two rectangles do not
+intersect.
+ end defun
+
+ defun rect-1d-overlap a-1 a-2 b-1 b-2
+ code{a-1} to @code{a-2} indicates one line segment and @code{b-1} to
+ code{b-2} indicates another.  Returns the overlap between the two line
+segments.
+ end defun
+
+ defun rect-2d-overlap dims point rect
+Returns the overlap between two rectangles, one with dimensions
+ code{dims} and upper-left corner at @code{point}; the other is defined
+by @code{rect}.
+ end defun
+
+ defun rect-2d-overlap* rect1 rect2
+Like @code{rect-2d-overlap}, except that the rectangles are
+ code{rect1} and @code{rect2}.
+ end defun
+
+ defun rect-total-overlap dims point rects
+Returns the total area of the overlap between a rectangle defined by
+ code{dims} and @code{point}, and the list of rectangles @code{rects}
+when placed at @code{point}.
+ end defun
+
+ defun rect-wholly-within-rect outer inner
+Returns @code{t} if @code{inner} is completely within the boundaries of
+ code{outer} 
+ end defun
+
+ defun rect-wholly-visible-p
+Returns @code{t} if @code{rect} is completely inside the screen
+boundaries.
+ end defun
+
+ defun rectangle-heads
+Returns the number of screen heads that the rectangle @code{rect}
+appears on.
+ end defun
+
+These functions are found in sawfish.wm.viewport:
+
+ defun rect-within-viewport-p rect &optional viewport
+Return @code{t} if @code{rect} is entirely inside the screen boundaries
+for some viewport, regardless of whether it is the current viewport, or
+even if the viewport currently exists.  If @code{viewport} is specified
+check only against that viewport.
+ end defun
+
+ defun rect-within-head-p rect &optional head
+Return @code{t} if @code{rect} is entirely within some head on some
+viewport. If @code{head} is provided @code{rect} must be within that
+head on some viewport.
+ end defun
+
+
+ node Gradient Functions, Other Functions, Rectangle Functions, Miscellaneous Functions
 @section Gradient Functions
 @cindex Gradient functions
 @cindex Functions, gradients



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