[sawfish] 'window-relative-position' is unified to 'window-absolute-position'
- From: Christopher Bratusek <chrisb src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sawfish] 'window-relative-position' is unified to 'window-absolute-position'
- Date: Tue, 15 Dec 2009 20:48:03 +0000 (UTC)
commit 48b45037fdcbef10b92db2ac95aa8817266bd0dd
Author: Teika kazura <teika lavabit com>
Date: Sun Dec 13 21:43:11 2009 +0900
'window-relative-position' is unified to 'window-absolute-position'
These two functions are similar, but not identical. The former is
recently introduced, so I chose to make the old one remain, and
merged the newer to the older.
Yet, I don't understand the exact difference under the real world use.
Improvements in documentation is desired.
lisp/sawfish/wm/state/maximize.jl | 4 +-
lisp/sawfish/wm/viewport.jl | 41 ++++++++++++++++++++++--------------
man/news.texi | 2 +-
man/sawfish.texi | 5 ----
4 files changed, 28 insertions(+), 24 deletions(-)
---
diff --git a/lisp/sawfish/wm/state/maximize.jl b/lisp/sawfish/wm/state/maximize.jl
index 4c58956..c55ff3a 100644
--- a/lisp/sawfish/wm/state/maximize.jl
+++ b/lisp/sawfish/wm/state/maximize.jl
@@ -132,7 +132,7 @@ that dimension.")
;; currently maximize window to `(X Y W H)', the saved geometry.
(define (save-unmaximized-geometry w)
(unless (window-get w 'unmaximized-geometry)
- (let* ((coords (window-relative-position w))
+ (let* ((coords (window-absolute-position w t))
(dims (window-dimensions w)))
(window-put w 'unmaximized-geometry (list (car coords) (cdr coords)
(car dims) (cdr dims))))))
@@ -150,7 +150,7 @@ that dimension.")
(when vertically
(window-put w 'maximized-vertically nil))
(let ((dims (window-dimensions w))
- (coords (window-relative-position w))
+ (coords (window-absolute-position w t))
(saved (unmaximized-geometry w)))
(when saved
(unless (window-maximized-horizontally-p w)
diff --git a/lisp/sawfish/wm/viewport.jl b/lisp/sawfish/wm/viewport.jl
index ac0959f..2f41f84 100644
--- a/lisp/sawfish/wm/viewport.jl
+++ b/lisp/sawfish/wm/viewport.jl
@@ -34,7 +34,6 @@
viewport-at
window-viewport
viewport-offset-coord
- window-relative-position
window-absolute-position
set-number-of-viewports
rect-within-viewport-p
@@ -484,26 +483,36 @@ understood as the current viewport, i.e., (0 . 0) will be returned."
(* (- (cdr vp) (cdr cur-vp)) (screen-height))))
'(0 . 0)))
- (define (window-relative-position w)
- "Returns a cons cell with the coordinates of the window relative
-to the viewport it occupies."
- (let ((offset (viewport-offset-coord (window-viewport w)))
- (coords (window-position w)))
- (cons
- (- (car coords) (car offset))
- (- (cdr coords) (cdr offset)))))
-
- (define (window-absolute-position w)
+ (define (window-absolute-position w #!optional disambiguate)
"Returns the coordinates of the window as if the window's viewport
is selected. The return value is the cons cell (x . y)."
;; So, ignoring the side effect, it's roughly equal to
;; (set-screen-viewport (window-viewport w))
;; (window-position w)
- (let ((position (window-position w)))
- (if (window-outside-viewport-p w)
- (cons (mod (+ (car position) viewport-x-offset) (screen-width))
- (mod (+ (cdr position) viewport-y-offset) (screen-height)))
- position)))
+ ;; The correct name should be "window-position-in-viewport".
+
+ ;; The temporary hack 'disambiguate' is introduced in Sawfish 1.6.
+ ;; It will be removed.
+
+ ;; Two methods differ if the window lies across several vp slots.
+ ;; Maybe both are necessary.
+ (if disambiguate
+ ;; method 1: always returns the same value.
+ ;; This is introduced in 1.6.
+ (let ((offset (viewport-offset-coord (window-viewport w)))
+ (coords (window-position w)))
+ (cons
+ (- (car coords) (car offset))
+ (- (cdr coords) (cdr offset))))
+ ;; method 2: If the window is visible from the current viewport,
+ ;; then simply window-position is returned.
+ ;; Else, the viewport where the window's top-left lies is used.
+ ;; This has existed for long time.
+ (let ((position (window-position w)))
+ (if (window-outside-viewport-p w)
+ (cons (mod (+ (car position) viewport-x-offset) (screen-width))
+ (mod (+ (cdr position) viewport-y-offset) (screen-height)))
+ position))))
(define (viewport-size-changed #!optional force)
;; This is called when the user requests a change (e.g., from the
diff --git a/man/news.texi b/man/news.texi
index 07a9c1e..eb47c11 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -71,7 +71,7 @@ only if the @file{~/.sawfishrc} lacks. Now, it is always read, so you
don't have to @code{require} it. It sets up GNOME and KDE support if
they run, and does @code{(require 'sawfish.wm.ext.error-handler)}.
-Since Sawfish 1.5 @code{~/.sawmillrc} is no longer a valid resoucefil.
+Since Sawfish 1.5 @code{~/.sawmillrc} is no longer valid.
From this version on, Sawfish will rename @code{~/.sawmillrc} to
@code{~/.sawfishrc}, if the former does exist on your system, but the
latter doesn't.
diff --git a/man/sawfish.texi b/man/sawfish.texi
index f84b603..cfdff2b 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -4201,11 +4201,6 @@ Returns a cons cell @code{(@var{col} . @var{row})} of the viewport
holding the top-left corner of @var{window}.
@end defun
- defun window-relative-position w
-Returns in a cons cell the coodinates of the window relative to the
-viewport it occupies.
- end defun
-
@defun window-outside-viewport-p window &optional viewport
Returns true if @var{window} is completely outside the current
viewport in any direction. If @var{viewport} is specified check against
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]