00001 #include "kde.h"
00002
00003 #if defined(GLUTM_SAVER) && defined(GLT_UNIX)
00004
00005 #define LONG64
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <klocale.h>
00016 #include <kdebug.h>
00017 #include <kglobal.h>
00018 #include <kconfig.h>
00019
00020 #include <qcolor.h>
00021
00022 #include <X11/Intrinsic.h>
00023 #include <GL/glx.h>
00024
00025 #include <cmath>
00026
00027 #include <glt/gl.h>
00028 #include <glt/glu.h>
00029
00030
00031 Display *dsp = NULL;
00032 int screen = 0;
00033 bool mono = false;
00034
00035
00036 void
00037 drawmorph3d(Window window)
00038 {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 }
00052
00053 static void
00054 reshape(int width, int height)
00055 {
00056
00057
00058
00059
00060
00061
00062
00063 }
00064
00065 #define MAXSCREENS 1
00066
00067 static XVisualInfo *glVis[MAXSCREENS];
00068
00069 int
00070 getVisual(XVisualInfo * wantVis, int visual_count)
00071 {
00072 Display *display = dsp;
00073 static int first;
00074 int i;
00075
00076 if (first) {
00077 for (screen = 0; screen < MAXSCREENS; screen++)
00078 glVis[screen] = NULL;
00079 }
00080
00081 if (!glVis[screen]) {
00082 if (mono) {
00083
00084 int attribList[] = {GLX_DOUBLEBUFFER, None};
00085
00086 glVis[screen] = glXChooseVisual(display, screen, attribList);
00087 } else {
00088 int attribList[] =
00089 {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 1, None};
00090
00091 glVis[screen] = glXChooseVisual(display, screen, attribList);
00092 }
00093 }
00094
00095 if (!glVis[screen]) {
00096 return (0);
00097 }
00098
00099
00100 for(i=0;i<visual_count;i++)
00101 if ( (glVis[screen]->visual == (wantVis+i)->visual) )
00102 return (1);
00103
00104
00105 return (0);
00106 }
00107
00108
00109
00110
00111
00112
00113 GlutMasterKdeSaver::GlutMasterKdeSaver( Drawable drawable )
00114 : QObject()
00115 {
00116 Window root;
00117 int ai;
00118 unsigned int au;
00119
00120 _mDrawable = drawable;
00121 _mGc = XCreateGC(qt_xdisplay(), _mDrawable, 0, 0);
00122 XGetGeometry(qt_xdisplay(), _mDrawable, &root, &ai, &ai,
00123 &_mWidth, &_mHeight, &au, &au);
00124
00125 readSettings();
00126
00127
00128 XSetWindowBackground(qt_xdisplay(), _mDrawable,BlackPixel(qt_xdisplay(), qt_xscreen()));
00129
00130 _colorContext = QColor::enterAllocContext();
00131
00132
00133
00134
00135
00136
00137
00138 _timer.start(100);
00139 connect(&_timer, SIGNAL( timeout() ), SLOT( slotTimeout() ) );
00140 }
00141
00142 GlutMasterKdeSaver::~GlutMasterKdeSaver()
00143 {
00144 XFreeGC(qt_xdisplay(), _mGc);
00145 _timer.stop();
00146
00147 QColor::leaveAllocContext();
00148 QColor::destroyAllocContext(_colorContext);
00149 }
00150
00151 void GlutMasterKdeSaver::readSettings()
00152 {
00153 KConfig *config = klock_config();
00154 config->setGroup( "Settings" );
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 delete config;
00169 }
00170
00171 void GlutMasterKdeSaver::slotTimeout()
00172 {
00173
00174 }
00175
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 #include <kapplication.h>
00190 #include <kcmdlineargs.h>
00191 #include <kcrash.h>
00192
00193
00194
00195
00196
00197 static const char *appName = "klock";
00198
00199 static const char *description = I18N_NOOP("KDE Screen Lock / Saver");
00200
00201 static const char *version = "2.0.0";
00202
00203 static const KCmdLineOptions options[] =
00204 {
00205 { "setup", I18N_NOOP("Setup screen saver."), 0 },
00206 { "window-id wid", I18N_NOOP("Run in the specified XWindow."), 0 },
00207 { "root", I18N_NOOP("Run in the root XWindow."), 0 },
00208 { "demo", I18N_NOOP("Start screen saver in demo mode."), "default"},
00209 { 0,0,0 }
00210 };
00211
00212 static void crashHandler( int sig )
00213 {
00214 #ifdef SIGABRT
00215 signal ( SIGABRT, SIG_DFL );
00216 #endif
00217 abort();
00218 }
00219
00220
00221
00222 static const char *appName = "klock";
00223
00224 static const char *description = I18N_NOOP("KDE Screen Lock / Saver");
00225
00226 static const char *version = "2.0.0";
00227
00228 static const KCmdLineOptions options[] =
00229 {
00230 { "setup", I18N_NOOP("Setup screen saver."), 0 },
00231 { "window-id wid", I18N_NOOP("Run in the specified XWindow."), 0 },
00232 { "root", I18N_NOOP("Run in the root XWindow."), 0 },
00233 { "demo", I18N_NOOP("Start screen saver in demo mode."), "default"},
00234 { 0,0,0 }
00235 };
00236
00237 static void crashHandler( int sig )
00238 {
00239 #ifdef SIGABRT
00240 signal ( SIGABRT, SIG_DFL );
00241 #endif
00242 abort();
00243 }
00244
00245 int main(int argc, char *argv[])
00246 {
00247 KCmdLineArgs::init(argc, argv, appName, description, version);
00248 KCmdLineArgs::addCmdLineOptions(options);
00249 KApplication app;
00250 KCrash::setCrashHandler( crashHandler );
00251
00252
00253
00254 Window saveWin = 0;
00255 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00256
00257 if (args->isSet("setup"))
00258 {
00259 setupScreenSaver();
00260 exit(0);
00261 }
00262
00263 if (args->isSet("window-id"))
00264 {
00265 saveWin = atol(args->getOption("window-id"));
00266 }
00267
00268 if (args->isSet("root"))
00269 {
00270 saveWin = RootWindow(qt_xdisplay(), qt_xscreen());
00271 }
00272
00273 if (args->isSet("demo"))
00274 {
00275 saveWin = 0;
00276 }
00277
00278 if (saveWin == 0)
00279 {
00280 demoWidget = new DemoWindow();
00281 demoWidget->setBackgroundMode(QWidget::NoBackground);
00282
00283 demoWidget->show();
00284 saveWin = demoWidget->winId();
00285 app.setMainWidget(demoWidget);
00286 app.processEvents();
00287 }
00288
00289 startScreenSaver(saveWin);
00290 app.exec();
00291 stopScreenSaver();
00292
00293 if (demoWidget)
00294 {
00295 delete demoWidget;
00296 }
00297
00298 return 0;
00299 }
00300
00301
00302 #endif