Hi,<br><br>I have the following problem:<br>I am sending _NET_WM_STATE messages to the root window in order to perform window state changes such as minimizing, maximizing, hiding and so forth. As far as I understand, the window manager is then supposed to apply these changes and set the according state flags on the target window. However, when re-reading these state flags immediately after I set them (or better: after the WM supposedly sets them), they are sometimes set, sometimes only partially set, and sometimes they aren't set at all (although the actual state change was successfully performed).
<br><br>In other words, my code works fine in the sense that when I issue a maximize, the window is correctly maximized, but the according flags are not set by the WM (or at least they don't appear in whatever XGetWindowProperty() returns for _NET_WM_STATE). That smells like a synchronization issue! However, calling XSync() at every point that even remotely makes sense to synchronize didn't help at all.
<br><br>Here is a code example where I set a window state:<br><br>int maximizeWindow(Window window)<br>{<br> unsigned long data[] = {<br> _NET_WM_STATE_ADD,<br> XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False),
<br> XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False),<br> 0, 0<br> };<br> Status status = sendClientMessage(window, "_NET_WM_STATE", data);<br> XSync(display, False);
<br> return status;<br>}<br><br>That code works just fine.<br><br>And here is the code I use to read these state flags again (I have "borrowed" most of that code from libwnck):<br clear="all"><br>bool getWindowStates(Window window, Atom atom, Atom **stateList, int *len)
<br>{<br> Atom type;<br> int format;<br> gulong nitems;<br> gulong bytes_after;<br> unsigned char *data;<br> int err, result;<br><br> *stateList = NULL;<br> *len = 0;<br><br> type = None;<br> result = XGetWindowProperty(display, window, atom, 0, G_MAXLONG,
<br> False, XA_ATOM, &type, &format, &nitems,<br> &bytes_after, &data);<br> XSync(display, False);<br><br> if (type != XA_ATOM)<br> {<br> std::cerr << "ERROR: Bad atom type" << std::endl;
<br> XFree (data);<br> return false;<br> }<br><br> *stateList = g_new (Atom, nitems);<br> memcpy (*stateList, data, sizeof (Atom) * nitems);<br> *len = nitems;<br><br> XFree (data);<br><br> return true;
<br>}<br><br>Now, calling maximizeWindow() and getWindowStates() immediately after does sometimes, but NOT ALWAYS yield the two atoms representing the two states that should be set for the given window.<br><br>Any help greatly appreciated!
<br><br>Best,<br>Matthias<br>