• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdescreensaver
 

libtdescreensaver

  • libtdescreensaver
main.cpp
1 /* This file is part of the KDE libraries
2 
3  Copyright (c) 2001 Martin R. Jones <mjones@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #include <config.h>
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <signal.h>
25 
26 #include <tqdialog.h>
27 #include <tdelocale.h>
28 #include <tdeglobal.h>
29 #include <kdebug.h>
30 #include <tdecmdlineargs.h>
31 #include <tdeapplication.h>
32 #include <kcrash.h>
33 
34 #include "tdescreensaver.h"
35 #include "tdescreensaver_vroot.h"
36 
37 bool argb_visual = FALSE;
38 
39 extern "C"
40 {
41  extern const char *kss_applicationName;
42  extern const char *kss_description;
43  extern const char *kss_version;
44  KScreenSaver *kss_create( WId d );
45  TQDialog *kss_setup();
46 }
47 
48 static const TDECmdLineOptions options[] =
49 {
50  { "setup", I18N_NOOP("Setup screen saver"), 0 },
51  { "window-id wid", I18N_NOOP("Run in the specified XWindow"), 0 },
52  { "root", I18N_NOOP("Run in the root XWindow"), 0 },
53  { "demo", I18N_NOOP("Start screen saver in demo mode"), "default"},
54  TDECmdLineLastOption
55 };
56 
57 static void crashHandler( int )
58 {
59 #ifdef SIGABRT
60  signal (SIGABRT, SIG_DFL);
61 #endif
62  abort();
63 }
64 
65 //----------------------------------------------------------------------------
66 
67 class DemoWindow : public TQWidget
68 {
69 public:
70  DemoWindow() : TQWidget()
71  {
72  setFixedSize(600, 420);
73  }
74 
75 protected:
76  virtual void keyPressEvent(TQKeyEvent *e)
77  {
78  if (e->ascii() == 'q')
79  {
80  kapp->quit();
81  }
82  }
83 
84  virtual void closeEvent( TQCloseEvent * )
85  {
86  kapp->quit();
87  }
88 };
89 
90 
91 //----------------------------------------------------------------------------
92 #if defined(Q_WS_QWS) || defined(Q_WS_MACX)
93 typedef WId Window;
94 #endif
95 
96 KDE_EXPORT int main(int argc, char *argv[])
97 {
98  TDELocale::setMainCatalogue("libtdescreensaver");
99  TDECmdLineArgs::init(argc, argv, kss_applicationName, kss_description, kss_version);
100 
101  TDECmdLineArgs::addCmdLineOptions(options);
102 
103 #ifdef HAVE_XCOMPOSITE
104  TDEApplication app(TDEApplication::openX11RGBADisplay());
105  argb_visual = app.isX11CompositionAvailable();
106 #else
107  TDEApplication app;
108 #endif
109 
110  TDECrash::setCrashHandler( crashHandler );
111  TDEGlobal::locale()->insertCatalogue("klock");
112  TDEGlobal::locale()->insertCatalogue("tdescreensaver");
113 
114  DemoWindow *demoWidget = 0;
115  Window saveWin = 0;
116  KScreenSaver *target;
117 
118  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
119 
120  if (args->isSet("setup"))
121  {
122  TQDialog *dlg = kss_setup();
123  args->clear();
124  dlg->exec();
125  delete dlg;
126  exit(0);
127  }
128 
129  if (args->isSet("window-id"))
130  {
131  saveWin = atol(args->getOption("window-id"));
132  }
133 
134 #ifdef Q_WS_X11 //FIXME
135  if (args->isSet("root"))
136  {
137  saveWin = RootWindow(tqt_xdisplay(), tqt_xscreen());
138  }
139 #endif
140 
141  if (args->isSet("demo"))
142  {
143  saveWin = 0;
144  }
145 
146  if (saveWin == 0)
147  {
148  demoWidget = new DemoWindow();
149  demoWidget->setBackgroundMode(TQWidget::NoBackground);
150  saveWin = demoWidget->winId();
151  app.setMainWidget(demoWidget);
152  app.processEvents();
153  }
154 
155  target = kss_create( saveWin );
156 
157  if ( demoWidget )
158  {
159  demoWidget->setFixedSize( 600, 420 );
160  demoWidget->show();
161  }
162  args->clear();
163  app.exec();
164 
165  delete target;
166  delete demoWidget;
167 
168  return 0;
169 }
170 
KScreenSaver
Provides a TQWidget for a screensaver to draw into.
Definition: tdescreensaver.h:59

libtdescreensaver

Skip menu "libtdescreensaver"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

libtdescreensaver

Skip menu "libtdescreensaver"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for libtdescreensaver by doxygen 1.8.8
This website is maintained by Timothy Pearson.