summaryrefslogtreecommitdiffstats
path: root/kdesktop/lock
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-01 22:09:20 -0500
committerSlávek Banko <slavek.banko@axis.cz>2013-05-05 05:09:55 +0200
commitefcc206a33efd167cabec2610e906e923cff66eb (patch)
tree32e4a671e164a98c5e76ebaeecdaa53e5509d9c8 /kdesktop/lock
parent1f3e144261a1715b4fbec072d9b4b57aeabddbf1 (diff)
downloadtdebase-efcc206a33efd167cabec2610e906e923cff66eb.tar.gz
tdebase-efcc206a33efd167cabec2610e906e923cff66eb.zip
Properly acquire a 32-bit ARGB visual when GL screen saver is requested
(cherry picked from commit 5908f01581521714faf27a93cfac9bfb207ec6b8)
Diffstat (limited to 'kdesktop/lock')
-rw-r--r--kdesktop/lock/lockprocess.cc73
1 files changed, 54 insertions, 19 deletions
diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc
index 578cabc44..a0d8b781e 100644
--- a/kdesktop/lock/lockprocess.cc
+++ b/kdesktop/lock/lockprocess.cc
@@ -938,6 +938,7 @@ void LockProcess::createSaverWindow()
{
Visual* visual = CopyFromParent;
XSetWindowAttributes attrs;
+ XVisualInfo* info = NULL;
int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect;
#ifdef HAVE_GLXCHOOSEVISUAL
if( mOpenGLVisual )
@@ -963,23 +964,41 @@ void LockProcess::createSaverWindow()
#undef G
#undef B
};
- for( unsigned int i = 0;
- i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
- ++i )
- {
- if( XVisualInfo* info = glXChooseVisual( x11Display(), x11Screen(), attribs[ i ] ))
- {
- visual = info->visual;
- static Colormap colormap = 0;
- if( colormap != 0 )
- XFreeColormap( x11Display(), colormap );
- colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
- attrs.colormap = colormap;
- flags |= CWColormap;
- XFree( info );
+ for( unsigned int i = 0; i < sizeof( attribs ) / sizeof( attribs[ 0 ] ); ++i ) {
+ int n_glxfb_configs;
+ GLXFBConfig *fbc = glXChooseFBConfig( x11Display(), x11Screen(), attribs[ i ], &n_glxfb_configs);
+ if (!fbc) {
+ n_glxfb_configs = 0;
+ }
+ for( int j = 0; j < n_glxfb_configs; j++ ) {
+ info = glXGetVisualFromFBConfig(x11Display(), fbc[j]);
+ if( info ) {
+ if (argb_visual) {
+ if (info->depth < 32) {
+ XFree( info );
+ info = NULL;
+ continue;
+ }
+ }
+ visual = info->visual;
+ static Colormap colormap = 0;
+ if( colormap != 0 ) {
+ XFreeColormap( x11Display(), colormap );
+ }
+ colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
+ attrs.colormap = colormap;
+ flags |= CWColormap;
+ break;
+ }
+ }
+ if (flags & CWColormap) {
break;
}
}
+ if ( !info )
+ {
+ printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n");
+ }
}
#endif
@@ -987,22 +1006,38 @@ void LockProcess::createSaverWindow()
hide();
if (argb_visual) {
+ // The GL visual selection can return a visual with invalid depth
+ // Check for this and use a fallback visual if needed
+ if (info && (info->depth < 32)) {
+ printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n");
+ XFree( info );
+ info = NULL;
+ flags &= ~CWColormap;
+ }
+
attrs.background_pixel = 0;
attrs.border_pixel = 0;
flags |= CWBackPixel;
flags |= CWBorderPixel;
if (!(flags & CWColormap)) {
- XVisualInfo vinfo;
- if (!XMatchVisualInfo( x11Display(), x11Screen(), 32, TrueColor, &vinfo )) {
- printf("[ERROR] Unable to locate matching X11 Visual; this application will not function correctly!\n\r");
+ if (!info) {
+ info = new XVisualInfo;
+ if (!XMatchVisualInfo( x11Display(), x11Screen(), 32, TrueColor, info )) {
+ printf("[ERROR] Unable to locate matching X11 Visual; this application will not function correctly!\n");
+ free(info);
+ info = NULL;
+ }
}
- else {
- visual = vinfo.visual;
+ if (info) {
+ visual = info->visual;
attrs.colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
flags |= CWColormap;
}
}
}
+ if (info) {
+ XFree( info );
+ }
Window w = XCreateWindow( x11Display(), RootWindow( x11Display(), x11Screen()), x(), y(), width(), height(), 0, x11Depth(), InputOutput, visual, flags, &attrs );
create( w );