I'm writing some low level window code for a window in X (in C++), and I want to prevent the user from either maximising or minimising the window. I don't mind whether this is done by rejecting the request to resize, or by removing the buttons themselves. However, I am tied to X and can't use Qt or other higher-level libraries which I know provide this functionality.
At the moment, all I have managed to do is intercept the ResizeRequest
event and then set the window size back using XResizeWindow
, but this causes the window to momentarily maximise and then return to its original state. Is there a way to directly reject a ResizeRequest
? That would seem to be the proper way to handle this, but a fair bit of googling and document trawling has not come up with a solution.
You can't.
Essentially, you would fight like hell against the window manager (and against the user in the end). For example, you could watch PropertyNotify
events to check if your window (or rather the window your window is attached to (provided by the window manager)) gets minimized, and then you unminimize it. And then the user minimizes it, or the window manager. Technically, you can fight against it, but I would strongly advise against it.
That said, you can try to give the window manager some hints about what you think is appropriate for the window. see http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html#id2523223.
_NET_WM_ALLOWED_ACTIONS
is a property the window manager manages per window (to tell other tools what is possible with that window). One of such actions is
_NET_WM_ACTION_RESIZE indicates that the window may be resized.
(Implementation note: Window Managers can identify a non-resizable window because its minimum and maximum size in WM_NORMAL_HINTS will be the same.)
So, if your users are using a window manager which interprets WM_NORMAL_HINTS
correctly and drops any resizing, maximizing, minimizing, then you can feel lucky.
What do you really want to achieve? Some kind of kiosk-mode? Some kind of fair-trade mode where people walking by cannot "shutdown", close, resize, fiddle around with the app you are presenting?
If so, consider running a xsession without any window manager involved at all. Just start your app as big as you need it and done.