Popup/splash screen in linux


how can I create a non-border, non-maximize/minimize/close window ( for a splash screen ) in linux to initialize OpenGL???.

I use the glXCreateWindow/glXCreateSimpleWindow and got OpenGL well initialized, but the window has border and also the minimize/maximize/close buttons that I dont want…

I think I have to use a thing called “decorators” but can’t use Motif/other thing… must be XLib-pure code…


you have to set the override_redirect member of the XSetWindowAttributes struct to True and use CWOverrideRedirect in the XCreateWindow call.

try this:


Display                 *dpy;
Window                  root, win;
GLint                   att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
Colormap                cmap;
XVisualInfo             *vi;
GLXContext              glc;

int main(int argc, char *argv[]) {
 XEvent                 xev;
 XWindowAttributes      gwa;
 XSetWindowAttributes   swa;
 int                    cw_mask = CWEventMask | CWColormap | CWOverrideRedirect;

 dpy    = XOpenDisplay(NULL);
 root   = DefaultRootWindow(dpy);
 vi     = glXChooseVisual(dpy, 0, att);
 cmap   = XCreateColormap(dpy, root, vi->visual, AllocNone);
 glc    = glXCreateContext(dpy, vi, NULL, GL_TRUE);

 swa.override_redirect = True;
 swa.event_mask = ExposureMask;
 swa.colormap = cmap;

 win = XCreateWindow(dpy, root, 200, 200, 400, 400, 0, vi->depth, InputOutput, vi->visual, cw_mask, &swa);

 XMapWindow(dpy, win);
 glXMakeCurrent(dpy, win, glc);

 while(1) {
        XNextEvent(dpy, &xev);

        if(xev.type == Expose) {
                XGetWindowAttributes(dpy, win, &gwa);
                glViewport(0, 0, gwa.width, gwa.height);
                glClearColor(0.3, 1.0, 0.3, 1.0);
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

                glXSwapBuffers(dpy, win); } } }
//      gcc -o borderless borderless.cc -lX11 -lGL -lGLU

much thx Rigid!

Much thx! Just the last question… How can get rid of any of the minimize/maximize buttons please? I tryed to google it but couldn’t find anything 8((

err…are they still there? actually they shouldn’t. the above code should create a borderless window without title bar and without any other decoration.

what exactly does your window look like- can you link a screenshot? and maybe some information about your system could help. which linux distribution, kde or gnome etc…

I want something like this ( not for the splash btw, your code worked perfectly thx… It’s for other window this time hehe ):

A window without minimize button, with title, with close button and with maximize button like this:

Also one only with close button with title but only with close button like this:

I use Ubuntu 6.06 with ATI drivers and Gnome last version desktop.

In general… what controls the presence of these maximize/minimize/close button decorators using Xlib?


i’m sorry to say that my wisdom ends here…all i can say is that window decorations are managed by the window manager- unless you set the override_redirect flag to override the window manager, as shown above.

well, maybe you could just try to find a small linux app with modified window decorations, download the source code and try to find out how it is done. and, of course, when you have found out: post the answer here. i’ve always wanted to know how to do that :wink:

Perhaps look at the source to wxWidgets? I know their window creation code allows you to specify what boxes you want displayed. (at least on windows it works - so I imagine they have code to do the same thing for linux)

maybe you want to try this:

//      defined in MwmUtil.h
#define MWM_HINTS_FUNCTIONS     (1L << 0)
#define MWM_HINTS_DECORATIONS   (1L << 1)
#define MWM_HINTS_INPUT_MODE    (1L << 2)
#define MWM_HINTS_STATUS        (1L << 3)

#define MWM_FUNC_ALL            (1L << 0)
#define MWM_FUNC_RESIZE         (1L << 1)
#define MWM_FUNC_MOVE           (1L << 2)
#define MWM_FUNC_MINIMIZE       (1L << 3)
#define MWM_FUNC_MAXIMIZE       (1L << 4)
#define MWM_FUNC_CLOSE          (1L << 5)

#define MWM_DECOR_ALL           (1L << 0)
#define MWM_DECOR_BORDER        (1L << 1)
#define MWM_DECOR_RESIZEH       (1L << 2)
#define MWM_DECOR_TITLE         (1L << 3)
#define MWM_DECOR_MENU          (1L << 4)
#define MWM_DECOR_MINIMIZE      (1L << 5)
#define MWM_DECOR_MAXIMIZE      (1L << 6)
//      defined in MwmUtil.h
 typedef struct {
        long    flags;
        long    functions;
        long    decorations;
        long    input_mode;
        long    status; } MotifWmHints;

 MotifWmHints   mwm_hints;
 Atom           MotifHints;

 Display *dpy = XOpenDisplay(...);
 Window   win = XCreateWindow(...);

 MotifHints = XInternAtom(dpy, "_MOTIF_WM_HINTS", 0);

 mwm_hints.flags = MWM_HINTS_FUNCTIONS;
 mwm_hints.functions=  MWM_FUNC_MOVE;

 XMapWindow(dpy, win);
 XChangeProperty(dpy, win, MotifHints, MotifHints, 32, PropModeReplace, (unsigned char *)&mwm_hints, 5);

the above code removes the minimize/maximize decorations; the close button is still there but doesn’t have an effect. i found something similar somewhere in the web and modified it; now it seems to work but i have to admit that i still don’t completely understand it :stuck_out_tongue:

the #defines and the MotifWmHints structure are usually included in MwmUtil.h, which comes with motif or lesstif, so you might not have have it.

it seems to be important that you call XInternAtom before the window is mapped with XMapWindow.

well, that’s all i know. play around with it; i hope you get what you want :wink:

(maybe you’ll find more answers here )

That sounds promising, Rigid!!!. Very good link, thx!
However, I don’t want to use Motif/OpenMotif/Lesstif libraries 8( Need, if possible, pure Xlib code.

I will try to see some source code to discover how to to this … but I suspect is not going to be easy because the window manager places the decorations like it wants and you can only set “hints” which probably will be ignored 8(

Originally posted by santyhammer:
However, I don’t want to use Motif/OpenMotif/Lesstif libraries 8( Need, if possible, pure Xlib code.
well, you don’t :wink:

XInternAtom and XChangeProperty are Xlib functions. the #defines and the MotifWmHints structure are taken from a lesstif header file, not from a library. if you define them in your source code the way i did, you don’t even need that header file.

just try it…after you have compiled the source, use ‘ldd’ on the binary executable. ldd prints the libraries which will be loaded when you start the executable, and you will see that libXm.so (for motif/lesstif) is not in the list.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.