Create window without title bar

前端 未结 2 2008
伪装坚强ぢ
伪装坚强ぢ 2021-01-15 18:03

I am trying to create a simple panel for Openbox in Arch Linux using c++, but I cannot figure out how to remove the title bar from a window.

I am creating the window

相关标签:
2条回答
  • 2021-01-15 18:38

    Since I found the solution, I figured I'd post the solution here if anyone else needs it.

    As @JoachimPileborg mentioned, I needed to alter the Openbox settings in ~/.config/openbox/rc.xml. Inside the <applications> tag, I added the following code:

    <application class="*">
      <decor>no</decor>
      <position force="no"></position>
    </application>
    

    The class="*" means that all applications will follow these rules, you could fill in the class name of the application instead. The <decor>no</decor> removes the title bar, and <position force="no"></position> ensures that my own script is able to handle the positioning. You could also add another <application> tag after this one to make exceptions to this rule.

    Also, the window_attributes.override_redirect = True; is not needed anymore.

    0 讨论(0)
  • 2021-01-15 18:44

    A more correct way is to use the Extended Window Manager Hints.

    The idea is that you don't tell the window manager how to decorate or not your window, you just indicate the window type with _NET_WM_WINDOW_TYPE :

    Atom window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
    long value = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DOCK", False);
    XChangeProperty(display, your_window, window_type,
       XA_ATOM, 32, PropModeReplace, (unsigned char *) &value,1 );
    

    "Dock" is the type for panels and taskbar. Usually they are undecorated and appear on all desktops. As written on the documentation, previously the _MOTIF_WM_HINTS property was used to define the appearance and decorations of the window. Window managers still support it, but _NET_WM_WINDOW_TYPE is prefered as it describe the function and let the window manager (and user) decide on the appearance and behavior of that type of window.

    Another interesting property for a panel is _NET_WM_STRUT_PARTIAL, to "reserve" space.

    0 讨论(0)
提交回复
热议问题