Search code examples
cuser-interfacex11xlib

Managing window title buttons in Linux via X11 API


Currently I am trying to make a sort of distro-independent message box (similar to all those modal popup windows, but which can work without the explicitly specified parent window) for Linux, which can run on any desktop environment (with any window manager). I am using C language for this.

I found the Nuklear library, which is rather powerful. But I am going to embed it into my application, since I am strictly limited in application size and third-party dependencies (libraries other than Xlib and XCB, like GTK or Qt, are not an option as well). So, looks like my the only option is use it's Xlib backend. There is a nice demo for X11.

Trying to make a message box according to the demo, I could not disable resizing (fixed size is needed) or disable minimize (iconify) and maximize buttons. I looked in the Xlib docs and X11 EWMH, but did not find any explicit info concerning this. Is it really impossible to disable resizing and these buttons? If so, can there be any workaround?

Thanks in advance!


Solution

  • The first thing you must understand:

    <span voice="Captain Jack Sparrow"> The EMWH are more like guidelines… </span>

    Basically you set the EWMH flags on the WM_TRANSIENT_FOR, WM_HINTS, WM_NORMAL_HINTS, WM_PROTOCOLS and _NET_WM_ALLOWED_ACTIONS window atom properties to make your window fixed size, modal-transient and and then cross your fingers, that the window manager will respect those.

    The window manager is perfectly capable and allowed to completely disregard all of this and just do whatever it wants.

    There's no standard protocol that gives information on what UI elements the window manager may put into the non client decoration area. You can derive some guesstimates from the relative location of "your" window within the stacking toplevel window the WM creates and reparents your window into. But that's about it.

    If you really want to override that, you can set the Override Redirect flag in the window creation attributes and take the window manager out of the loop. You'll have to do everything yourself then. Also you might **** *** a whole bunch of users by doing that, who really, really take a dislike in programs pulling such stunts, just in order to mess with the decorations and/or window manager behavior (FYI: I'm one of those people).