[Top][All Lists]

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

Re: [STUMP] Displaying a window as dialog

From: Stefan Reichör
Subject: Re: [STUMP] Displaying a window as dialog
Date: Thu, 05 Jul 2012 09:40:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Servilio Afre Puentes <address@hidden> writes:

> On Thu, 28 Jun 2012 13:55:10 +0200, Stefan Reichör <address@hidden> wrote:
> [...]
>> The following page explains _NET_WM_WINDOW_TYPE:
>> Is there a way to tell stumpwm to interpret an emacs window (with a
>> special title) as dialog?
>> Or is it possible to change the type of an already shown window somehow?
> If it is possible in the X protocol, it might be possible to do from
> within StumpWM. I'd check the CLX documentation first to see if it is
> possible.
> What I wonder is if StumpWM would pick up the change automatically, or
> if it would have to be notified of the change.
> Servilio

I have written a patch that allows to override the type that is used for a 
The user can define an override list, e.g.:
(setf *window-type-override-list* '((:dialog :instance "xterm1") (:dialog 
:title "My funky window")))

This tells StumpWM to display a window with the instance name "xterm1"
and windows with the title "My funky window" as dialog.
It could also be used to move a window in the :dock or to display a
dialog as a :normal window.

I think it is an useful addition for StumpWM.
Is there somebody willing to apply the patch?


--- a/window.lisp
+++ b/window.lisp
@@ -453,12 +453,41 @@ _NET_WM_STATE_DEMANDS_ATTENTION set"
                    (xlib:wm-size-hints-min-aspect hints)
                    (xlib:wm-size-hints-max-aspect hints)))))
+;; e.g.: (setf *window-type-override-list* '((:dialog :instance "xterm1") 
(:dialog :title "My funky window")))
+(defvar *window-type-override-list* nil
+"Allows to override the return value of xwin-type. It makes it e.g. possible 
to display a window as dialog.
+It is a list of possible overrides. The first entry in the list is the wanted 
return value, e.g. :dialog or :normal.
+The following are matchers like :class, :instance, :role, :title in any 
desired combination.")
+(defun xwin-matches-properties-p (xwin &key class instance type role title)
+  "Returns T if xwin matches all the given properties"
+  (and
+   (if class (string-match (xwin-class xwin) class) t)
+   (if instance (string-match (xwin-res-name xwin) instance) t)
+   ;; (if type (string-match (xwin-type xwin) type) t)
+   (if role (string-match (xwin-role xwin) role) t)
+   (if title (string-match (xwin-name xwin) title) t) t))
+(defun xwin-type-override (xwin)
+  "Return an overrided window type, see *window-type-override-list*"
+  (dolist (rule *window-type-override-list*)
+    (destructuring-bind (type &key class instance role title) rule
+      (when (xwin-matches-properties-p xwin
+                                       :class class
+                                       :instance instance
+                                       :role role
+                                       :title title
+                                       )
+        ;; (message "xwin-type-override matches: ~a ~a -> ~a" xwin rule type)
+        (return type)))))
 (defun xwin-type (win)
   "Return one of :desktop, :dock, :toolbar, :utility, :splash,
 :dialog, :transient, and :normal.  Right now
 only :dock, :dialog, :normal, and :transient are
 actually returned; see +NETWM-WINDOW-TYPES+."
-  (or (let ((net-wm-window-type (xlib:get-property win :_NET_WM_WINDOW_TYPE)))
+  (or (xwin-type-override win)
+      (let ((net-wm-window-type (xlib:get-property win :_NET_WM_WINDOW_TYPE)))
         (when net-wm-window-type
           (dolist (type-atom net-wm-window-type)
             (when (assoc (xlib:atom-name *display* type-atom) 
@@ -812,7 +841,7 @@ needed."
       (move-screen-to-head screen))
     (when last-win
       (update-decoration last-win))))
 (defmethod focus-window (window)
   "Make the window visible and give it keyboard focus."
   (dformat 3 "focus-window: ~s~%" window)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]