Greetings,
Thanks so much for creating SDL… truly a wonderful gift to the linux
community.
Thanks.
One question (from a linux/X11 coding novice)… Is there a way to turn
off all window decorations in my SDL-created windows? I would like to have
a window that displays streaming video in a box with.no
border/title/handles/scrollar, etc etc? I’d appreciate any information you
could provide.
Well, SDL doesn’t provide a way to do it, but it does provide a way to get
at the insides so you can do it yourself. (Code for the latest CVS snapshot,
dated April 7, 1999)
#include “SDL.h”
#include “SDL_syswm.h”
void sdl_RemoveTitleBar(void)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) ) {
#ifdef unix
if ( info.subsystem == SDL_SYSWM_X11 ) {
Atom WM_HINTS;
Display *display;
Window window;
XSetWindowAttributes attributes;
info.info.x11.lock_func();
display = info.info.x11.display;
window = info.info.x11.window;
/* First try to set MWM hints */
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
if ( WM_HINTS != None ) {
define MWM_HINTS_DECORATIONS (1L << 1)
struct {
Sint32 flags;
Sint32 functions;
Sint32 decorations;
Sint32 inputMode;
Sint32 unknown;
} MWMHints = { MWM_HINTS_DECORATIONS, 0, 0, 0, 0 };
XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
PropModeReplace, (unsigned char *)&MWMHints,
sizeof(MWMHints)/4);
}
/* 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);
}
#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
}
}
Keep in mind that when you do this, the user can’t generally move the window
or iconify it.
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/