Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info. |
How to XCreateWindow() with no window manager decorations
Is it possible, from an XLib program, to tell the window manager not to put any decorations around your top level window? The Xt manual talks about a _MOTIF_WM_HINTS property, but I cant find any information on using it in an XLib program. I know how to do it from my .Xdefaults: 4Dwm*myprog.clientDecoration: none. What I want to know is how to hardcode it, for a program whose whole purpose in life is to play fullscreen videos. The old version of this program used IrisGL's noborders() function, but this is no longer an option.
When doing XCreateWindow, you can set the override_redirect flag to TRUE inthe XSetWindowAttributes.
The OpenGL FAQ calls this a sledgehammer approach - if anyone has any better ways of doing this without needing Motif - I would love to hear them.
For really hardcore windows, you can set OverrideDirect=true when you can XCreateWindow(). This does have some drawbacks, like:
- you should define your own cursor (otherwise and X shaped cursor will be used)
- the keys for Raise and Lower window don't work (this is Window Manager stuff)
- No X resource manager; no Motif
This works for me... this is an extracted and edited from a larger chunk of code, so bear with any typos etc. ;)
Display *display; Window window; MwmHints hints, *hp; Atom hintsAtom, typeAtom; unsigned long nItems, bytesAfter; int fmt; . . . /* * Set border and decorations */ hintsAtom = XInternAtom( display, "_MOTIF_WM_HINTS", False ); XGetWindowProperty( display, window, hintsAtom, 0, 4, False, hintsAtom, &typeAtom, &fmt, &nItems, &bytesAfter, (unsigned char**)&hp ); if ( NULL != hp ) { hints = *hp; XFree( (void*)hp ); } else memset( &hints, 0, sizeof(hints) ); if ( border ) hints.decorations = MWM_DECOR_ALL; /* Use 0 for no decorations */ else hints.decorations = 0x0; hints.flags |= MWM_HINTS_DECORATIONS; XChangeProperty( display, window, hintsAtom, hintsAtom, 32, PropModeReplace, (unsigned char *)&hints, 4 ); XFlush( display ); XMapWindow( display, window );