Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / kcontrol / screensaver / kswidget.cpp
blob892a394e33677a7080df399444f4e189e1732a36
1 #include <config-screensaver.h>
3 #include "testwin.h"
5 #include <QX11Info>
7 #ifdef HAVE_GLXCHOOSEVISUAL
8 #include <GL/glx.h>
9 #endif
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 }
40 #undef R
41 #undef G
42 #undef B
44 for( unsigned int i = 0;
45 i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
46 ++i )
48 if( XVisualInfo* info = glXChooseVisual( x11Info().display(), x11Info().screen(), attribs[ i ] ))
50 visual = info->visual;
51 depth = info->depth;
52 colormap = XCreateColormap( x11Info().display(), RootWindow( x11Info().display(), x11Info().screen()), visual, AllocNone );
53 attrs.colormap = colormap;
54 flags |= CWColormap;
55 XFree( info );
56 break;
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 );
63 if( parentWidget())
64 XReparentWindow( x11Info().display(), w, parentWidget()->winId(), 0, 0 );
65 create( w, false, true );
66 #endif
69 KSWidget::~KSWidget()
71 #ifdef HAVE_GLXCHOOSEVISUAL
72 if( colormap != None )
73 XFreeColormap( x11Info().display(), colormap );
74 #endif
77 #include "kswidget.moc"