clinuxxlibxorgxserver

Xlib hide and then show a window in its original state


I noticed that if I unmap a window, when I map it back, it's maximized state along with the restore-to size and position are all lost (Ubuntu 10). Is there a way to get the normal size/pos so I can put it back before mapping? Or do I have to track it myself through resize events (if that's even possible)?

Thanks.


Solution

  • This came up on a search when I noticed the same thing... so I'm not sure my answer is the best, but after looking at my window manager's source code and as many docs as I could (Xlib man pages, the ICCCM, EWMH spec), I couldn't find anything that did it automatically. XWithdrawWindow does basically the same thing as XUnmapWindow in my experiments and in my window manager's source and it was my best bet.

    Looking at Qt's source code, it also has calls to adjust size when you call the show() method. So it must be necessary in at least some cases, if not all.

    Sooo I think the answer is you need to track it yourself. ConfigureNotify events will tell you when you've been resized and I believe moved. You can watch for other properties like maximized through events too. If you keep track of these, you can move your window back.

    Or you could ask for the size with XGetGeometry (and again other atom states too) before you do the unmapping.