[sawfish] 'display-window-position' command is implemented.



commit 9ec004089882e8d47adce6bf2e6c3a393004f43e
Author: Teika kazura <teika lavabit com>
Date:   Sat Mar 13 13:24:28 2010 +0900

    'display-window-position' command is implemented.

 lisp/sawfish/wm/util/display-wininfo.jl |   42 +++++++++++++++++++++++-------
 man/news.texi                           |    6 ++++
 man/sawfish.texi                        |   10 ++++++-
 3 files changed, 47 insertions(+), 11 deletions(-)
---
diff --git a/lisp/sawfish/wm/util/display-wininfo.jl b/lisp/sawfish/wm/util/display-wininfo.jl
index 6a31915..5da213d 100644
--- a/lisp/sawfish/wm/util/display-wininfo.jl
+++ b/lisp/sawfish/wm/util/display-wininfo.jl
@@ -42,9 +42,11 @@
 
   (defconst icon-size (32 . 32))
 
+  ;; Move this to x-cycle.jl, and add viewport. Leave this undocumented
+  ;; until that.
   (defvar display-wininfo-show-workspace nil)
 
-  ;; window currently displayed, or nil
+  ;; the popup window which currently shows wininfo, or nil
   (define info-window nil)
 
 ;;; utilities
@@ -78,7 +80,9 @@
 	(cons (quotient (- (screen-width) (car dims)) 2)
 	      (quotient (- (screen-height) (cdr dims)) 2)))))
 
-  ;; Returns a list of strings describing window W in some way
+  ;; Returns the list of *one* string which is made of
+  ;; * name, in brackets when iconified
+  ;: * workspace num like <2>, when display-wininfo-show-workspace in non-nil
   (define (window-info w)
     (list (concat (and (window-get w 'iconified) ?[)
                        (window-name w)
@@ -93,14 +97,10 @@
 
 ;;; entry point
 
-  ;; What must be shown?
-  ;;  * The window icon at left.
-  ;;  * At right, the window's title and (maybe) its class.
-
   (define (display-wininfo w)
-    "Shows window information about W. Includes at least window name and
-icon (if available). With a null W any displayed information is removed."
-
+    "Popups a small window with window's informations. It includes
+icon, name, and workspace if `display-wininfo-show-workspace' is non-nil.
+If W is nil previous window is removed."
     ;; if there's an old window, destroy it
     (when info-window
       (x-destroy-window info-window)
@@ -152,4 +152,26 @@ icon (if available). With a null W any displayed information is removed."
 			   `((background . ,(get-color "white"))
 			     (border-color . ,(get-color "black")))
 			   event-handler))
-	(x-map-window info-window)))))
+	(x-map-window info-window))))
+
+  (define (display-window-position #!optional w)
+    "Display window position and size in a popup."
+    (unless (windowp w)
+      (setq w (select-window)))
+    (let (
+	  (coord (window-position w))
+	  (size (window-dimensions w))
+	  str)
+      (setq str (concat "Name: " (window-name w) "\n\n"))
+      (setq str (format nil "%sTop left:     (%s, %s)\n" str
+			(car coord) (cdr coord)))
+      (setq str (format nil "%sRight bottom: (%s, %s)\n" str
+			(+ (car coord) (car size))
+			(+ (cdr coord) (cdr size))))
+      (setq str (format nil "%sSize: %s x %s\n" str
+			(car size) (cdr size)))
+      (display-message (concat str "\nClick to dismiss."))))
+  
+  (define-command 'display-window-position display-window-position
+    #:doc "Choose a window, and prints its position and size in a popup.")
+  )
diff --git a/man/news.texi b/man/news.texi
index 3ffa295..e407386 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -29,6 +29,12 @@ User can override system lisp files. For example, if there is
 was possible for some lisp files, but now it's guaranteed for all
 files.  Of course, you can define new modules, too.
 
+ item New command @code{display-window-position} [Teika kazura]
+
+User chooses a window by cursor and click, and it prints its position
+and size in a popup. Also available as a function, defined in
+ code{sawfish wm util display-wininfo} 
+
 @end itemize
 @item Bugfixes
 @itemize @minus
diff --git a/man/sawfish.texi b/man/sawfish.texi
index c2d6df2..a115841 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -676,7 +676,7 @@ client window associated with it.
 Basics:
 * Window Attributes::
 * Getting Windows:: Get window by name, class, all, etc.
-* Window Property Lists::
+* Window Property Lists:: Plist attached by Sawfish.
 * Window Types::  Some windows have type, like transient.
 * Input Focus::
 * X Properties::
@@ -767,6 +767,14 @@ Returns a cons-cell @code{(@var{x} . @var{y})} defining the position
 relative to the root window of @var{window}.
 @end defun
 
+ defun display-window-position #!optional window
+Display @var{window}'s position and size in a popup. If the argument
+is @code{nil} or called as a command, user chooses the window by cursor
+and click.
+
+This function is defined in @code{sawfish.wm.util.display-wininfo}.
+ end defun
+
 @defun get-window-wm-protocols window
 Return a list of symbols defining the X11 window manager protocols
 supported by client @var{window}.



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