1 #include <config-screensaver.h>
7 #ifdef HAVE_GLXCHOOSEVISUAL
11 KSWidget::KSWidget( QWidget
* parent
, Qt::WindowFlags wf
)
12 : QWidget( parent
, wf
), colormap( None
)
14 // use visual with support for double-buffering, for opengl
15 // this code is (partially) duplicated in kdebase/workspace/krunner/lock/
16 #ifdef HAVE_GLXCHOOSEVISUAL
17 Visual
* visual
= CopyFromParent
;
18 int depth
= CopyFromParent
;
19 XSetWindowAttributes attrs
;
20 int flags
= parentWidget() ? 0 : CWOverrideRedirect
;
21 if( true /*mOpenGLVisual*/ )
23 static int attribs
[][ 15 ] =
25 #define R GLX_RED_SIZE
26 #define G GLX_GREEN_SIZE
27 #define B GLX_BLUE_SIZE
28 { GLX_RGBA
, R
, 8, G
, 8, B
, 8, GLX_DEPTH_SIZE
, 8, GLX_DOUBLEBUFFER
, GLX_STENCIL_SIZE
, 1, None
},
29 { GLX_RGBA
, R
, 4, G
, 4, B
, 4, GLX_DEPTH_SIZE
, 4, GLX_DOUBLEBUFFER
, GLX_STENCIL_SIZE
, 1, None
},
30 { GLX_RGBA
, R
, 8, G
, 8, B
, 8, GLX_DEPTH_SIZE
, 8, GLX_DOUBLEBUFFER
, None
},
31 { GLX_RGBA
, R
, 4, G
, 4, B
, 4, GLX_DEPTH_SIZE
, 4, GLX_DOUBLEBUFFER
, None
},
32 { GLX_RGBA
, R
, 8, G
, 8, B
, 8, GLX_DEPTH_SIZE
, 8, GLX_STENCIL_SIZE
, 1, None
},
33 { GLX_RGBA
, R
, 4, G
, 4, B
, 4, GLX_DEPTH_SIZE
, 4, GLX_STENCIL_SIZE
, 1, None
},
34 { GLX_RGBA
, R
, 8, G
, 8, B
, 8, GLX_DEPTH_SIZE
, 8, None
},
35 { GLX_RGBA
, R
, 4, G
, 4, B
, 4, GLX_DEPTH_SIZE
, 4, None
},
36 { GLX_RGBA
, GLX_DEPTH_SIZE
, 8, GLX_DOUBLEBUFFER
, GLX_STENCIL_SIZE
, 1, None
},
37 { GLX_RGBA
, GLX_DEPTH_SIZE
, 8, GLX_DOUBLEBUFFER
, None
},
38 { GLX_RGBA
, GLX_DEPTH_SIZE
, 8, GLX_STENCIL_SIZE
, 1, None
},
39 { GLX_RGBA
, GLX_DEPTH_SIZE
, 8, None
}
44 for( unsigned int i
= 0;
45 i
< sizeof( attribs
) / sizeof( attribs
[ 0 ] );
48 if( XVisualInfo
* info
= glXChooseVisual( x11Info().display(), x11Info().screen(), attribs
[ i
] ))
50 visual
= info
->visual
;
52 colormap
= XCreateColormap( x11Info().display(), RootWindow( x11Info().display(), x11Info().screen()), visual
, AllocNone
);
53 attrs
.colormap
= colormap
;
60 attrs
.override_redirect
= 1;
61 Window w
= XCreateWindow( x11Info().display(), RootWindow( x11Info().display(), x11Info().screen()),
62 x(), y(), width(), height(), 0, depth
, InputOutput
, visual
, flags
, &attrs
);
64 XReparentWindow( x11Info().display(), w
, parentWidget()->winId(), 0, 0 );
65 create( w
, false, true );
71 #ifdef HAVE_GLXCHOOSEVISUAL
72 if( colormap
!= None
)
73 XFreeColormap( x11Info().display(), colormap
);
77 #include "kswidget.moc"