add more spacing
[personal-kdebase.git] / workspace / krunner / lock / lockprocess.h
blob23643b71d65e6c14ebf06df216227d40a262c64d
1 //===========================================================================
2 //
3 // This file is part of the KDE project
4 //
5 // Copyright 1999 Martin R. Jones <mjones@kde.org>
6 // Copyright 2003 Oswald Buddenhagen <ossi@kde.org>
7 // Copyright 2008 Chani Armitage <chanika@gmail.com>
8 //
10 #ifndef LOCKPROCESS_H
11 #define LOCKPROCESS_H
13 #include <KProcess>
15 #include <QWidget>
16 #include <QTimer>
17 #include <QStack>
18 #include <QList>
19 #include <QHash>
20 #include <QMessageBox>
21 #include <QPixmap>
23 #include <X11/Xlib.h>
24 #include <fixx11h.h>
26 #include "plasmaapp_interface.h"
28 class KLibrary;
30 struct KGreeterPluginInfo;
32 struct GreeterPluginHandle {
33 KLibrary *library;
34 KGreeterPluginInfo *info;
37 const int TIMEOUT_CODE = 2; //from PasswordDlg
40 //===========================================================================
42 // Screen saver handling process. Handles screensaver window,
43 // starting screensaver hacks, and password entry.
45 class LockProcess
46 : public QWidget
48 Q_OBJECT
49 Q_CLASSINFO("D-Bus Interface", "org.kde.screenlocker.LockProcess")
50 public:
51 explicit LockProcess(bool child_saver = false, bool useBlankOnly = false);
52 ~LockProcess();
54 /**
55 * start the screensaver locked
57 bool lock();
59 /**
60 * start the screensaver unlocked
62 bool defaultSave();
64 /**
65 * start the screensaver in plasma setup mode
66 * if plasma is disabled this just acts like defaultSave
68 bool startSetup();
70 /**
71 * start the screensaver unlocked, and *never* automatically lock it
73 bool dontLock();
75 void setChildren(QList<int> children) { child_sockets = children; }
76 void setParent(int fd) { mParent = fd; }
78 void msgBox( QWidget *parent, QMessageBox::Icon type, const QString &txt );
79 int execDialog( QDialog* dlg );
81 public Q_SLOTS:
82 void quitSaver();
83 void preparePopup();
84 void cleanupPopup();
85 //dbus methods
86 /**
87 * bring up the password dialog with @param reason displayed instead of the usual "this session
88 * is locked" message.
89 * @return true if the password was entered correctly
90 * if this returns true, it will also unlock the screensaver without quitting.
91 * it will re-lock after the lock timeout in the settings
93 Q_SCRIPTABLE bool checkPass(const QString &reason);
94 /**
95 * this will unlock and quit the screensaver, asking for a password first if necessary
97 Q_SCRIPTABLE void quit();
98 /**
99 * immediately lock the screen; it will now require a password to unlock.
101 Q_SCRIPTABLE bool startLock();
103 protected:
104 virtual bool x11Event(XEvent *);
105 virtual void timerEvent(QTimerEvent *);
106 virtual bool eventFilter(QObject *o, QEvent *e);
108 private Q_SLOTS:
109 void hackExited();
110 void signalPipeSignal();
111 void suspend();
112 void checkDPMSActive();
113 void slotDeadTimePassed();
115 * check that plasma started properly (used for timeout)
116 * and disable it if it failed
118 void checkPlasma();
120 * a new dbus service has come in
122 void newService(QString name, QString oldOwner, QString newOwner);
124 * tell plasma we're in idle mode
126 void deactivatePlasma();
127 void lockPlasma();
129 * immediately un-suppress the password dialog
130 * FIXME need a better name
132 void unSuppressUnlock();
134 private:
135 void configure();
136 void readSaver();
137 void createSaverWindow();
138 void hideSaverWindow();
139 void saveVRoot();
140 void setVRoot(Window win, Window rw);
141 void removeVRoot(Window win);
142 bool grabKeyboard();
143 bool grabMouse();
144 bool grabInput();
145 void ungrabInput();
146 void cantLock(const QString &reason);
147 bool startSaver();
148 void stopSaver();
149 bool startHack();
150 void stopHack();
151 bool startPlasma();
152 void stopPlasma();
153 void setupSignals();
155 * exec the password dialog
156 * @return true iff the password was checked and is valid
158 bool checkPass();
160 * returns true if plasma is up and the dbus interface is valid
162 bool isPlasmaValid();
164 * give up on plasma, probably because it crashed.
165 * this does *not* tell plasma to quit. it just stops using it.
167 void disablePlasma();
169 * give a fakefocusin to the right window
171 void updateFocus();
172 void stayOnTop();
173 void lockXF86();
174 void unlockXF86();
175 void resume( bool force );
176 enum WindowType { IgnoreWindow = 0 /** regular window to be left below the saver */,
177 SimpleWindow = 1 /** simple popup that can't handle direct input */,
178 InputWindow = 2 /** annoying dialog that needs direct input */,
179 DefaultWindow = 6/** input window that's also the plasma view */
182 * @return the type of window, based on its X property
184 WindowType windowType(WId id);
186 static QVariant getConf(void *ctx, const char *key, const QVariant &dflt);
187 bool loadGreetPlugin();
189 bool mLocked;
190 int mLockGrace;
191 int mPriority;
192 bool mBusy;
193 KProcess mHackProc;
194 org::kde::plasmaoverlay::App *mPlasmaDBus;
195 bool mPlasmaEnabled;
196 bool mSetupMode;
197 QString mSaverExec;
198 QString mSaver;
199 bool mOpenGLVisual;
200 bool child_saver;
201 QList<int> child_sockets;
202 int mParent;
203 bool mUseBlankOnly;
204 bool mSuspended;
205 QTimer mSuspendTimer;
206 bool mVisibility;
207 bool mDPMSDepend;
208 QTimer mCheckDPMS;
209 QStack< QWidget* > mDialogs;
210 QHash< QWidget*, QWidget* > mFrames;
211 bool mRestoreXF86Lock;
212 bool mForbidden;
213 QStringList mPlugins, mPluginOptions;
214 QString mMethod;
215 GreeterPluginHandle greetPlugin;
216 QPixmap mSavedScreen;
217 int mAutoLogoutTimerId;
218 int mAutoLogoutTimeout;
219 QTimer mSuppressUnlock;
220 int mSuppressUnlockTimeout;
221 QList<WId> mForeignWindows;
222 QList<WId> mForeignInputWindows;
225 #endif