From b35ae0b4c99051c8bbab6a110f068ec6be80078d Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Tue, 25 May 2010 18:38:49 -0400 Subject: [PATCH] glxgears: Add option to enable override redirect. This is useful for testing fullscreen rendering without requiring window manager support. We also update the init code to query the window attributes for the initial viewport size, otherwise we'll be stuck with 300x300 gears even if we use -fullscreen. Signed-off-by: Nick Bowler --- src/xdemos/glxgears.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c index 92c75ca..81c32b2 100644 --- a/src/xdemos/glxgears.c +++ b/src/xdemos/glxgears.c @@ -101,6 +101,7 @@ static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ +static GLboolean override = GL_FALSE; /* Override redirect. */ static GLboolean stereo = GL_FALSE; /* Enable stereo. */ static GLboolean animate = GL_TRUE; /* Animation */ static GLfloat eyesep = 5.0; /* Eye separation. */ @@ -494,7 +495,7 @@ make_window( Display *dpy, const char *name, None }; int scrnum; XSetWindowAttributes attr; - unsigned long mask; + unsigned long mask = 0; Window root; Window win; GLXContext ctx; @@ -509,6 +510,11 @@ make_window( Display *dpy, const char *name, height = DisplayHeight( dpy, scrnum ); } + if (override) { + attr.override_redirect = True; + mask = CWOverrideRedirect; + } + if (stereo) visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs ); else @@ -528,7 +534,7 @@ 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! */ - mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + mask |= CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; win = XCreateWindow( dpy, root, x, y, width, height, 0, visinfo->depth, InputOutput, @@ -705,6 +711,7 @@ usage(void) printf(" -display set the display to run on\n"); printf(" -stereo run in stereo mode\n"); printf(" -fullscreen run in fullscreen mode\n"); + printf(" -override override redirect\n"); printf(" -info display OpenGL renderer info\n"); printf(" -geometry WxH+X+Y window geometry\n"); } @@ -718,6 +725,7 @@ main(int argc, char *argv[]) Display *dpy; Window win; GLXContext ctx; + XWindowAttributes attrs; char *dpyName = NULL; GLboolean printInfo = GL_FALSE; int i; @@ -736,6 +744,9 @@ main(int argc, char *argv[]) else if (strcmp(argv[i], "-fullscreen") == 0) { fullscreen = GL_TRUE; } + else if (strcmp(argv[i], "-override") == 0) { + override = GL_TRUE; + } else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) { XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight); i++; @@ -771,7 +782,8 @@ main(int argc, char *argv[]) * We can't be sure we'll get a ConfigureNotify event when the window * first appears. */ - reshape(winWidth, winHeight); + XGetWindowAttributes(dpy, win, &attrs); + reshape(attrs.width, attrs.height); event_loop(dpy, win); -- 1.6.4.4