1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
//-----------------------------------------------------------------------------
//
// Screen savers for KDE
//
// Copyright (c) Martin R. Jones 1999
//
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <tqcolor.h>
#include <klocale.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kcrash.h>
#include "demowin.h"
#include "saver.h"
static const char appName[] = "klock";
static const char description[] = I18N_NOOP("KDE Screen Lock/Saver");
static const char version[] = "2.0.0";
static const KCmdLineOptions options[] =
{
{ "setup", I18N_NOOP("Setup screen saver"), 0 },
{ "window-id wid", I18N_NOOP("Run in the specified XWindow"), 0 },
{ "root", I18N_NOOP("Run in the root XWindow"), 0 },
{ "demo", I18N_NOOP("Start screen saver in demo mode"), "default"},
KCmdLineLastOption
};
static void crashHandler( int /*sig*/ )
{
#ifdef SIGABRT
signal ( SIGABRT, SIG_DFL );
#endif
abort();
}
//----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
KCmdLineArgs::init(argc, argv, appName, I18N_NOOP("KLock"), description, version);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCrash::setCrashHandler( crashHandler );
DemoWindow *demoWidget = 0;
Window saveWin = 0;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("setup"))
{
setupScreenSaver();
exit(0);
}
if (args->isSet("window-id"))
{
saveWin = atol(args->getOption("window-id"));
}
if (args->isSet("root"))
{
saveWin = TQApplication::desktop()->handle();
}
if (args->isSet("demo"))
{
saveWin = 0;
}
if (saveWin == 0)
{
demoWidget = new DemoWindow();
demoWidget->setBackgroundMode(TQWidget::NoBackground);
// demoWidget->setBackgroundColor(TQt::black);
demoWidget->show();
saveWin = demoWidget->winId();
app.setMainWidget(demoWidget);
app.processEvents();
}
startScreenSaver(saveWin);
app.exec();
stopScreenSaver();
if (demoWidget)
{
delete demoWidget;
}
return 0;
}
|