glxgears: for fullscreen, disable window borders the right way
authorBrian Paul <brian.paul@tungstengraphics.com>
Thu, 16 Oct 2008 20:16:41 +0000 (14:16 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Thu, 16 Oct 2008 20:33:27 +0000 (14:33 -0600)
progs/xdemos/glxgears.c

index c98c3157b5d615a2c769ff9ade6108ad462f3f6c..8db717f1aa38a430b4f47f7c26cdb4f9fa5779a7 100644 (file)
@@ -419,6 +419,52 @@ init(void)
 }
 
 
+/**
+ * Remove window border/decorations.
+ */
+static void
+no_border( Display *dpy, Window w)
+{
+   static const unsigned MWM_HINTS_DECORATIONS = (1 << 1);
+   static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5;
+
+   typedef struct
+   {
+      unsigned long       flags;
+      unsigned long       functions;
+      unsigned long       decorations;
+      long                inputMode;
+      unsigned long       status;
+   } PropMotifWmHints;
+
+   PropMotifWmHints motif_hints;
+   Atom prop, proptype;
+   unsigned long flags = 0;
+
+   /* setup the property */
+   motif_hints.flags = MWM_HINTS_DECORATIONS;
+   motif_hints.decorations = flags;
+
+   /* get the atom for the property */
+   prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True );
+   if (!prop) {
+      /* something went wrong! */
+      return;
+   }
+
+   /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */
+   proptype = prop;
+
+   XChangeProperty( dpy, w,                         /* display, window */
+                    prop, proptype,                 /* property, type */
+                    32,                             /* format: 32-bit datums */
+                    PropModeReplace,                /* mode */
+                    (unsigned char *) &motif_hints, /* data */
+                    PROP_MOTIF_WM_HINTS_ELEMENTS    /* nelements */
+                  );
+}
+
+
 /*
  * Create an RGB, double-buffered window.
  * Return the window and context handles.
@@ -479,13 +525,15 @@ make_window( Display *dpy, const char *name,
    attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
    attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
    /* XXX this is a bad way to get a borderless window! */
-   attr.override_redirect = fullscreen;
-   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
 
    win = XCreateWindow( dpy, root, x, y, width, height,
                        0, visinfo->depth, InputOutput,
                        visinfo->visual, mask, &attr );
 
+   if (fullscreen)
+      no_border(dpy, win);
+
    /* set hints and properties */
    {
       XSizeHints sizehints;