简体   繁体   中英

simple window without titlebar

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

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM