What would the chance of having a function added to the Window Manager
hints to ask for a decorationless window. I know it’s possible in
Linux (XMMS) and Windows (Winamp) at least. I think it would be a
very useful capability and I have’nt seen a cross platform kit that
allows it yet.
Any particular reason you need it?
Here is code for SDL 1.0.1 and earlier. It’s more complicated for SDL
1.0.2, but if you need it to emulate fullscreen mode, the real fullscreen
code should work much better.
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
-------------- next part --------------
/********************************************************************/
/ Old and obsolete functions /
/********************************************************************/
#if 0 /* Obsolete by SDL 1.0.2 (now three windows involved) */
typedef struct {
Sint32 flags;
Sint32 functions;
Sint32 decorations;
Sint32 inputMode;
Sint32 unknown;
} MWM_Hints;
static enum { No_WM, Motif_WM, KDE_WM, GNOME_WM } wm_type;
void sdl_RemoveTitleBar(void)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) > 0 ) {
#ifdef unix
if ( info.subsystem == SDL_SYSWM_X11 ) {
Atom WM_HINTS;
Display *display;
Window window;
info.info.x11.lock_func();
display = info.info.x11.display;
window = info.info.x11.window;
/* This happens in SDL 1.1 */
if ( window == 0 ) {
info.info.x11.unlock_func();
printf("FIXME: SDL 1.1 - Can't remove the titlebar yet\n");
return;
}
#if 1
/* First try to set MWM hints */
WM_HINTS = XInternAtom(display, “_MOTIF_WM_HINTS”, True);
if ( WM_HINTS != None ) {
define MWM_HINTS_DECORATIONS (1L << 1)
MWM_Hints MWMHints = { MWM_HINTS_DECORATIONS, 0, 0, 0, 0 };
XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
PropModeReplace, (unsigned char *)&MWMHints,
sizeof(MWMHints)/4);
wm_type = Motif_WM;
}
/* Now try to set KWM hints */
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
if ( WM_HINTS != None ) {
long KWMHints = 0;
XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
PropModeReplace, (unsigned char *)&KWMHints,
sizeof(KWMHints)/4);
wm_type = KDE_WM;
}
/* Now try to set GNOME hints */
WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
if ( WM_HINTS != None ) {
long GNOMEHints = 0;
XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
PropModeReplace, (unsigned char *)&GNOMEHints,
sizeof(GNOMEHints)/4);
wm_type = GNOME_WM;
}
#endif
#if 0 /* The Butcher way of removing window decorations – not polite */
attributes.override_redirect = True;
XChangeWindowAttributes(info.info.x11.display, info.info.x11.window,
CWOverrideRedirect, &attributes);
#endif
info.info.x11.unlock_func();
}
#else
#error Need to implement these functions for other systems
#endif // unix
}
}
/* Looks like deleting the WM properties does the job */
void sdl_RestoreTitleBar(void)
{
SDL_SysWMinfo info;
if(!wm_type)
return;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) > 0 ) {
if ( info.subsystem == SDL_SYSWM_X11 ) {
Atom WM_HINTS;
Display *display;
Window window;
info.info.x11.lock_func();
display = info.info.x11.display;
window = info.info.x11.window;
switch(wm_type){
case No_WM:
case GNOME_WM:
case Motif_WM:
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
break;
case KDE_WM:
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
break;
}
XDeleteProperty(display,window,WM_HINTS);
info.info.x11.unlock_func();
}
}
}
void sdl_RemapWindow(void)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) > 0 ) {
if ( info.subsystem == SDL_SYSWM_X11 ) {
Display *display;
Window window;
XEvent event;
info.info.x11.lock_func();
display = info.info.x11.display;
window = info.info.x11.window;
XUnmapWindow(display,window);
XMapRaised(display,window);
do {
XNextEvent(display, &event);
} while ( event.type != MapNotify );
XSetInputFocus(display, window, RevertToPointerRoot, CurrentTime);
info.info.x11.unlock_func();
}
}
}
#endif /* Obsolete by SDL 1.0.2 */