Displaying a window as dialog

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying a window as dialog

Stefan Reichör
Hi,

today I discovered wmjump (http://code.google.com/p/wmjump/). It allows
to jump to a window by pressing a hotkey. This is nice, however since I
am a programmer and an experienced emacs user, I want to do something
like this using an emacs frame.

Is there a way to display an emacs frame as dialog?

The difference is, that show window properties uses type :NORMAL for
emacs frames and type :DIALOG for wmjump:

,----
| class: Emacs
| instance: emacs
| type: :NORMAL
| role:
| title: emacs
`----

,----
| class: wmjump
| instance: wmjump
| type: :DIALOG
| role:
| title: wmjump
`----


The following page explains _NET_WM_WINDOW_TYPE:
http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html

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?


Stefan.

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Displaying a window as dialog

Servilio Afre Puentes-4
On Thu, 28 Jun 2012 13:55:10 +0200, Stefan Reichör <[hidden email]> wrote:
[...]
> The following page explains _NET_WM_WINDOW_TYPE:
> http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html
>
> 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

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Displaying a window as dialog

Stefan Reichör
Servilio Afre Puentes <[hidden email]> writes:

> On Thu, 28 Jun 2012 13:55:10 +0200, Stefan Reichör <[hidden email]> wrote:
> [...]
>> The following page explains _NET_WM_WINDOW_TYPE:
>> http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html
>>
>> 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 window.
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?

Stefan.


--- 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) +netwm-window-types+)
@@ -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)

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel