Borderless Windows on Linux

Borderless windows on Linux

Using Xlib and old _MOTIF_WM_HINTS:

struct MwmHints {
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
};
enum {
MWM_HINTS_FUNCTIONS = (1L << 0),
MWM_HINTS_DECORATIONS = (1L << 1),

MWM_FUNC_ALL = (1L << 0),
MWM_FUNC_RESIZE = (1L << 1),
MWM_FUNC_MOVE = (1L << 2),
MWM_FUNC_MINIMIZE = (1L << 3),
MWM_FUNC_MAXIMIZE = (1L << 4),
MWM_FUNC_CLOSE = (1L << 5)
};

Atom mwmHintsProperty = XInternAtom(display, "_MOTIF_WM_HINTS", 0);
struct MwmHints hints;
hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = 0;
XChangeProperty(display, window, mwmHintsProperty, mwmHintsProperty, 32,
PropModeReplace, (unsigned char *)&hints, 5);

These days NetWM/EWMH hints are preferred, but as far as I know all modern window managers still support this.

Why window without borders is always on top

That's how override-redirect windows are meant to behave. They are designed for implementing pop-up menus and similar windows which are transient and stay above other windows.

If that's not what you want, do not use override-redirect flag. Instead, use WM hints. See here for the full list of hints. You want to tell your WM which window type you have (_NET_WM_WINDOW_TYPE_TOOLBAR etc), not how it's decorated. See here for a usage example.

If that's still not what you want, use the (somewhat outdated) Motif WM hints. See for example here.

How to make transparent window on linux

This is definitely something that you will want to offload to the GPU. I would not recommend directly using the X11 lib for performance reasons. Let OpenGL do it. I did find the following link for glXChooseVisual.

Also, here is another S.O. question that may be helpful.

Furthermore, this is for windows, but it should still apply.

Create Linux XCB Frameless Window

If you want your override-redirect window to have the input focus, you have to explicitly xcb_set_input_focus(connection, window);. Since the input focus can only be given to viewable windows, this has to be done after you mapped your window.

In X11, keyboard events are (basically) send to the window that currently has the input focus. Normally, the input focus is managed by the window manager. Since you are creating an override-redirect window, the window manager does not see your window and cannot focus it. Thus, you have to focus your window yourself. Note that the WM can still give the focus to other windows and thus your window loses focus.

I am not actually sure what the correct/right way to focus your window per ICCCM is. I did not find a relevant section with a quick search for "override-redirect" or "focus".

My gut feeling is that the right way to handle this issue is to not use an override-redirect window.



Related Topics



Leave a reply



Submit