2

Good afternoon everyone! I have been working on a project that requires a basic window without a titlebar. After browsing a bit on the web I came across this post create window without titlebar with a reply mentioning the use of the "_NET_WM_WINDOW_TYPE_DOCK" atom. I attempted to create one in my project using the following code:

Display* d = fl_display;
XWindow w = XCreateSimpleWindow(d, RootWindow(d, fl_screen),
    0, 0,
    400, 100,
    0,
    0x000000, 0x000000);

Atom window_type = XInternAtom(d, "_NET_WM_WINDOW_TYPE", False);
long value = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(d, w, window_type, XA_ATOM, 32, PropModeReplace, (uchar*) &value, 1);

The window does show, but it still has a titlebar. I have found several other resources around the web, but I can't get this to stop showing the titlebar. I do realize that the referenced post is using XCreateWindow, but shouldn't atoms work on XCreateSimpleWindow too. Any help would be appreciated!

Thanks

Community
  • 1
  • 1
user1646428
  • 179
  • 2
  • 12
  • There is also the old [`_MOTIF_WM_HINTS`](http://stackoverflow.com/questions/5134297/xlib-how-does-this-removing-window-decoration-work). Which window manager are you using ? – Leiaz Jul 11 '15 at 21:57
  • The project is actually the WM :) I'm trying to build an alt-tab window to show the running windows. I think the DOCK would be more suited to that task right? – user1646428 Jul 11 '15 at 22:03
  • So ... you are drawing that titlebar on your window ? Modify your WM so that it will honor the `_NET_WM_WINDOW_TYPE` hint and not draw that titlebar ? :) – Leiaz Jul 11 '15 at 22:16
  • Sorry Leiaz, I must have worked too much today. I got it now, thanks! :) – user1646428 Jul 11 '15 at 22:39

1 Answers1

3

I have extended your example a bit to be able to test it out, and it works for me - see if there are any meaningful differences to your code.

#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>

int main(int argc, char **argv) {
  Display* d = XOpenDisplay(NULL);
  int s = DefaultScreen(d);
  Window w = XCreateSimpleWindow(d, RootWindow(d, s), 100, 100, 400, 100, 1,
                                 BlackPixel(d, s), WhitePixel(d, s));
  Atom window_type = XInternAtom(d, "_NET_WM_WINDOW_TYPE", False);
  long value = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);
  XEvent e;
  XChangeProperty(d, w, window_type, XA_ATOM, 32, PropModeReplace, (unsigned char *) &value, 1);
  XMapWindow(d, w);
  while (1) {
    XNextEvent(d, &e);
    if (e.type == Expose) {
      XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
    }
    if (e.type == KeyPress)
      break;
  }
  XCloseDisplay(d);
  return 0;
}
vukung
  • 1,824
  • 10
  • 23
  • Thanks for the help vukung! My demo has two other traditional test windows (titlebars, buttons, etc), and if I implement your code, all the dressings disappear from the other windows and it appears to lock things up. The additional window does appear to show though. I am using different values for the 'd' and 's' variables. Thoughts? – user1646428 Jul 11 '15 at 22:28
  • Doesn't work for me on Ubuntu 19.04 with KDE Plasma 5.14.1 nor default WM. And "_MOTIF_WM_HINTS" surprisingly did the job – Ihor Baklykov Sep 03 '19 at 11:53