simple window without titlebar
Asked Answered
L

1

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

Leaven answered 11/7, 2015 at 21:6 Comment(4)
There is also the old _MOTIF_WM_HINTS. Which window manager are you using ?Seigniory
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?Leaven
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 ? :)Seigniory
Sorry Leiaz, I must have worked too much today. I got it now, thanks! :)Leaven
O
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;
}
Optician answered 11/7, 2015 at 22:10 Comment(2)
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?Leaven
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 jobFaveolate

© 2022 - 2024 — McMap. All rights reserved.