maximized state and normal frame size lost after hide/show

Cosmin Apreutesei cosmin.apreutesei at gmail.com
Fri Aug 14 09:00:52 PDT 2015


> You'd have to store the geometry before the window gets maximized

Actually, there is no event that would give me the normal rect
_before_ the window gets maximized. At the time PropertyNotify /
_NET_WM_STATE is sent, the normal geometry is already lost.

So it seems that I have to track geometry in ConfigureNotify and make
an exception and _not track it_ when _NET_WM_STATE_MAXIMIZED_HORZ is
set.

> But again: for actual un/mapping this should no way be required.

Well, I'm using XWithdrawWindow() if it makes any difference, because
XUnmapWindow() doesn't properly hide minimized windows (it doesn't
send UnmapNotify).

The fact that you're skeptical of this makes me think this is a bug in
Unity. Anyway, the sequence is the following:

0. Create and map a normal window
1. XSendClientMessage with _NET_WM_STATE with atoms
_NET_WM_STATE_MAXIMIZED_HORZ and _NET_WM_STATE_MAXIMIZED_VERT
2. XWithdrawWindow
3. XMapWindow

with 1 second of polling between the steps just in case.

The result is a window with maximized size/pos but not maximized
state. After UnmapNotify, all PropertyNotify of _NET_WM_STATE show
zero atoms set so clearly the property is unset (not by me) and never
set back. If I set the property back myself before mapping I do get a
window in maximized state but it restores to the same maximized size
so the restore size is clearly lost.


<rant>
X11 is probably the most hostile API I've ever encountered in 20 years
of programming. I mean cocoa and winapi are horrible in many ways and
buggy and ridiculous but X is The Castle + 1984 combined. It's almost
a month since I'm trying to put together a basic window state API
(show/hide/minimize/maximize/restore/shownormal + events with some
degree of predictability + querying the state at any time) and the
unit tests explode all over the place (same unit tests that pass
without issues on osx and windows backends).

Btw, I see Wayland touting async behavior and inability to query state
as some kind of feature. You need to provide __non-failing blocking
APIs__ folks like winapi, cocoa (and yes, even Mir) otherwise how am I
suppose to implement the following?

function restore()
   if minimized() then
      unminimize()
   elseif maximized() then
      unmaximize()
   end
end

If that's not provided by the API already, how can I possibly
implement the above with an async API? Set flags and chase them around
in event handlers? Poll for a specific event on a timeout and hope
that the WM doesn't forget to send me the event thus blocking my app
forever? Make a command queue for such basic functionality? Shouldn't
we be past piling up hacks to get simple things done?
</rant>


More information about the xorg mailing list