[Xlib] Saving state before an unmap

Andrew Troschinetz ast at arlut.utexas.edu
Wed Feb 11 14:23:24 PST 2009


Hi all,

Basically I want to unmap a window, fiddle with it a bit (like  
removing the border, removing the maximize button, etc...) and then  
remap it. The problem I'm running into is that unmapping the window  
results in unintended side-effects. Take the _NET_WM_STATE property  
for example, it gets blown away if you unmap the window. This results  
in things like a window being kept-below before I fiddle with it, but  
then after I remap it, the window will no longer be kept-below anymore.

Is there a general Xlib idiom for saving all of a window's state  
before an unmap operation, and then restoring it after a subsequent re- 
map operation? The solution I came up with (no doubt sub-optimal) is  
this:

1. Get the current _NET_WM_STATE property.
2. unmap the window and fiddle with it.
3. re-map the window.
4. use XChangeProperty() to change _NET_WM_STATE back to what it was  
before, Atom by Atom (see next step as to why I do it Atom by Atom).
5. Send out an ClientMessage XEvent for every Atom we just changed in  
_NET_WM_STATE (I think this is necessary because the union we get for  
a ClientMessage isn't big enough for us to send notification of all  
changed Atoms if there are many multiple Atoms set for the  
_NET_WM_STATE property).

There has to be a better way, right?

Alternatively, if there is a way to remove the close/minimize/maximize  
buttons or window-decorations from a window w/o unmapping it (or w/o  
losing the window's current _NET_WM_STATE property) that'd be awesome.  
It has to work on an already mapped window, as that is my intended use  
case.

Essentially, I'm writing a "window-manager-lite on top of a real  
window manager" so that I can manipulate all the windows of all the  
disparate applications of the software suite I'm developing in various  
ways. It's a little complicated, but probably not as complicated as  
I'm making it sound. Essentially the use case is that the user may at  
any point command the window of another application to remove (or un- 
remove) its border/close-button/etc, and I need to respect as much of  
the current window state of the target window as possible (ie:  
_NET_WM_STATE and possibly other Extended Window Manager Hints  
properties that I haven't even thought of yet.)

Any ideas?

--
Andrew Troschinetz
Applied Research Laboratories




More information about the xorg mailing list