[sawfish] Improved position matcher
- From: Christopher Bratusek <chrisb src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [sawfish] Improved position matcher
- Date: Sat, 29 Aug 2009 18:17:46 +0000 (UTC)
commit 86d34bb4dcd098616081b3e82122226714180eaf
Author: chrisb <zanghar freenet de>
Date: Sat Aug 29 20:16:38 2009 +0200
Improved position matcher
ChangeLog | 6 +++++
lisp/sawfish/wm/ext/match-window.jl | 38 ++++++++++++++++++++++++++++------
man/news.texi | 2 +
3 files changed, 39 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 758b37c..0af6e43 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,12 @@
* lisp/sawfish/wm/user.jl: rename .sawmillrc to .sawfishrc if the former exists, but the later not
+ * lisp/sawfish/wm/ext/match-window.jl: improve position matcher to bind a window to a position
+ either center north north-east north-west east south south-east
+ south-west west OR to a user-given position for the former
+ it will also set the gravity of the window to that position
+ -- [Jeremy Hankins]
+
* man/news.texi: updated
* man/sawfish.texi: added halve/double-window-size
diff --git a/lisp/sawfish/wm/ext/match-window.jl b/lisp/sawfish/wm/ext/match-window.jl
index 5cd8432..ff815f5 100644
--- a/lisp/sawfish/wm/ext/match-window.jl
+++ b/lisp/sawfish/wm/ext/match-window.jl
@@ -73,7 +73,7 @@
`((placement ,(_ "Placement")
(ignore-program-position boolean)
(place-mode ,(lambda () `(choice ,@placement-modes)))
- (position (pair (number 0) (number 0)))
+ (position (or (pair (number 0) (number 0)) (choice center north north-east north-west east south-east south-west west)))
(dimensions (pair (number 1) (number 1)))
(workspace (number 1))
(viewport (pair (number 1) (number 1)))
@@ -346,14 +346,38 @@
(define-match-window-setter 'position
(lambda (w prop value)
(declare (unused prop))
- (let ((x (car value))
- (y (cdr value)))
+ (let* ((size (window-frame-dimensions w))
+ (x (if (symbolp value)
+ (cond ((memq value '(east south-east north-east))
+ (- (screen-width) (car size)))
+ ((memq value '(north center south))
+ (- (quotient (screen-width) 2)
+ (quotient (car size) 2)))
+ (t 0))
+ (car value)))
+ (y (if (symbolp value)
+ (cond ((memq value '(south south-east south-west))
+ (- (screen-height) (cdr size)))
+ ((memq value '(east center west))
+ (- (quotient (screen-height) 2)
+ (quotient (cdr size) 2)))
+ (t 0))
+ (cdr value)))
+ (gravity (cond ((symbolp value)
+ value)
+ ((and (< x 0) (< y 0))
+ 'south-east)
+ ((< x 0)
+ 'north-east)
+ ((< y 0)
+ 'south-west)
+ (t nil))))
+ (when gravity
+ (window-put w 'gravity gravity))
(when (< x 0)
- ;; XXX should change placement gravity
- (setq x (+ (screen-width) x)))
+ (setq x (+ (- (screen-width) (car size)) x)))
(when (< y 0)
- ;; XXX should change placement gravity
- (setq y (+ (screen-height) y)))
+ (setq y (+ (- (screen-height) (cdr size)) y)))
(move-window-to w x y))))
(define-match-window-setter 'dimensions
diff --git a/man/news.texi b/man/news.texi
index d4aa447..7960671 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -62,6 +62,8 @@ they occurred between. For more detailed information see the
@item Added viewport-boundary-mode dynamic (creates a new viewport then hitting the screen-edge) [Jeremy Hankins]
+ item Improve position matcher to bind a window to a position (either center north north-east north-west east south south-east south-west west) OR to a user-given position [Jeremy Hankins]
+
@item When GNOME Integration is loaded, the apps menu now shows the content of the GNOME Menu (uncategorized atm) [Christopher Bratusek]
@item When GNOME Integration is loaded, don't remove quit and restart entries from menu [Christopher Bratusek]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]