[sawfish] Implemented 'spec' option for window-class.



commit 31f5f7372e3344f43a066da51e12ea5917a534cd
Author: Teika kazura <teika lavabit com>
Date:   Sat Mar 20 13:41:22 2010 +0900

    Implemented 'spec' option for window-class.

 lisp/sawfish/wm/windows.jl |   19 +++++++++++++++----
 man/news.texi              |    6 ++++++
 man/sawfish.texi           |   33 ++++++++++++++++++++-------------
 3 files changed, 41 insertions(+), 17 deletions(-)
---
diff --git a/lisp/sawfish/wm/windows.jl b/lisp/sawfish/wm/windows.jl
index 81d08d7..266512f 100644
--- a/lisp/sawfish/wm/windows.jl
+++ b/lisp/sawfish/wm/windows.jl
@@ -210,11 +210,22 @@ windows."
 	 (not (or (and (not ignore-cycle-skip) (window-get w 'cycle-skip))
 		  (desktop-window-p w)))))
 
-  (define (window-class w)
-    "Return the class that window W belongs to, as a string. Returns `nil' if W
-has no associated class."
+  (define (window-class w #!optional spec)
+    "If SPEC is nil, return the class that window W belongs to,
+as a string. Returns `nil' if W has no associated class.
+
+If SPEC is 'cons, then cons (Instance . Class) is returned.
+If SPEC is 'configurator, then the string of the form \"Instance/Class\"
+is returned."
     (let ((prop (get-x-text-property w 'WM_CLASS)))
-      (and prop (> (length prop) 1) (aref prop 1))))
+      (when (and prop (> (length prop) 1))
+	(case spec
+	  ((cons)
+	   (cons (aref prop 0) (aref prop 1)))
+	  ((configurator)
+	   (concat (aref prop 1) "/" (aref prop 0)))
+	  (t
+	   (and prop (> (length prop) 1) (aref prop 1)))))))
 
   (define (get-window-wm-protocols w)
     "Return a list of symbols defining the X11 window manager protocols
diff --git a/man/news.texi b/man/news.texi
index ff5ec88..05c250b 100644
--- a/man/news.texi
+++ b/man/news.texi
@@ -35,6 +35,12 @@ 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}.
 
+ item Window instance name is accessible [Teika kazura]
+
+Technically, the window class consists of ``instance'' and ``class'',
+but only the latter was returned previously by the function
+ code{window-class}  Now with the new optional argument, the instance
+is returned too. (@pxref{Window Attributes})
 @end itemize
 @item Bugfixes
 @itemize @minus
diff --git a/man/sawfish.texi b/man/sawfish.texi
index a115841..7db917c 100644
--- a/man/sawfish.texi
+++ b/man/sawfish.texi
@@ -743,9 +743,16 @@ Change the window's name to @var{name}. This works in practice, but
 technically ICCCM doesn't suppose window name changes.
 @end defun
 
- defun window-class window
-Return the class that @var{window} belongs to as a string, or nil if
- var{window} has no associated class.
+ defun window-class window #!optional spec
+If the optional argument @var{spec} is @code{nil}, returns the class
+that @var{window} belongs to as a string, or nil if @var{window} has
+no associated class.
+
+ICCCM class consists of ``Instance'' and ``Class''. If @var{spec} is
+the symbol @code{cons}, then the cons of the form
+ code{(@var{instance} . @var{class})} is returned. If @var{spec} is
+the symbol @code{configurator}, then the string of the form
+`` var{instance}/@var{class}'' is returned.
 @end defun
 
 @defun window-id window
@@ -842,22 +849,22 @@ Return a window object with id @var{xid}, or @code{nil}.
 @end defun
 
 @defun get-window-by-name name
-Return a window object with name @var{name}, or @code{nil}.
+Return a window object with name @var{name}, or @code{nil}.  Even if
+multiple windows are matched, one of them is returned.
 @end defun
 
 @defun get-window-by-name-re name
 Return a window object with name matching regular expression
- var{name}, or @code{nil}.
- end defun
-
- defun get-window-by-class class
-Return a window object with class @var{class}, or @code{nil}.
+ var{name}, or @code{nil}. Even if multiple windows are matched,
+one of them is returned.
 @end defun
 
- defun get-window-by-class-re class
-Return a window object with class matching regular expression
- var{class}, or @code{nil}.
- end defun
+ deffn Function: get-window-by-class class
+ deffnx Function: get-window-by-class-re class
+Same as the above, but the match is done against the window class.
+Here, the class does not include the ``instance''. (See @code{window-class} in
+ xref{Window Attributes}.)
+ end deffn
 
 @defun filter-windows pred
 Return the list of windows (mapped or unmapped) that match the



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