check for plasma-overlay going away
[kdebase.git] / workspace / krunner / lock / lockprocess.h
blob14c3a695e143132e133803cf11fdfd76f05c3926
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 //===========================================================================
39 // Screen saver handling process. Handles screensaver window,
40 // starting screensaver hacks, and password entry.
42 class LockProcess
43 : public QWidget
45 Q_OBJECT
46 Q_CLASSINFO("D-Bus Interface", "org.kde.krunner_lock.LockProcess")
47 public:
48 explicit LockProcess(bool child_saver = false, bool useBlankOnly = false);
49 ~LockProcess();
51 /**
52 * start the screensaver locked
54 bool lock();
56 /**
57 * start the screensaver unlocked
59 bool defaultSave();
61 /**
62 * start the screensaver in plasma setup mode
63 * if plasma is disabled this just acts like defaultSave
65 bool startSetup();
67 /**
68 * start the screensaver unlocked, and *never* automatically lock it
70 bool dontLock();
72 void setChildren(QList<int> children) { child_sockets = children; }
73 void setParent(int fd) { mParent = fd; }
75 void msgBox( QWidget *parent, QMessageBox::Icon type, const QString &txt );
76 int execDialog( QDialog* dlg );
78 public Q_SLOTS:
79 void quitSaver();
80 void preparePopup();
81 void cleanupPopup();
82 //dbus methods
83 /**
84 * bring up the password dialog with @param reason displayed instead of the usual "this session
85 * is locked" message.
86 * @return true if the password was entered correctly
87 * if this returns true, it will also unlock the screensaver without quitting.
88 * it will re-lock after the lock timeout in the settings
90 Q_SCRIPTABLE bool checkPass(const QString &reason);
91 /**
92 * this will unlock and quit the screensaver, asking for a password first if necessary
94 Q_SCRIPTABLE void quit();
95 /**
96 * immediately lock the screen; it will now require a password to unlock.
98 Q_SCRIPTABLE bool startLock();
100 protected:
101 virtual bool x11Event(XEvent *);
102 virtual void timerEvent(QTimerEvent *);
103 virtual bool eventFilter(QObject *o, QEvent *e);
105 private Q_SLOTS:
106 void hackExited();
107 void signalPipeSignal();
108 void suspend();
109 void checkDPMSActive();
110 void slotDeadTimePassed();
112 * check that plasma started properly (used for timeout)
113 * and disable it if it failed
115 void checkPlasma();
117 * a new dbus service has come in
119 void newService(QString name, QString oldOwner, QString newOwner);
121 * tell plasma we're in idle mode
123 void deactivatePlasma();
124 void lockPlasma();
126 * immediately un-suppress the password dialog
127 * FIXME need a better name
129 void unSuppressUnlock();
131 private:
132 void configure();
133 void readSaver();
134 void createSaverWindow();
135 void hideSaverWindow();
136 void saveVRoot();
137 void setVRoot(Window win, Window rw);
138 void removeVRoot(Window win);
139 bool grabKeyboard();
140 bool grabMouse();
141 bool grabInput();
142 void ungrabInput();
143 void cantLock(const QString &reason);
144 bool startSaver();
145 void stopSaver();
146 bool startHack();
147 void stopHack();
148 bool startPlasma();
149 void stopPlasma();
150 void setupSignals();
152 * exec the password dialog
153 * @return true iff the password was checked and is valid
155 bool checkPass();
157 * returns true if plasma is up and the dbus interface is valid
159 bool isPlasmaValid();
161 * give up on plasma, probably because it crashed.
162 * this does *not* tell plasma to quit. it just stops using it.
164 void disablePlasma();
166 * give a fakefocusin to the right window
168 void updateFocus();
169 void stayOnTop();
170 void lockXF86();
171 void unlockXF86();
172 void resume( bool force );
173 enum WindowType { IgnoreWindow = 0 /** regular window to be left below the saver */,
174 SimpleWindow = 1 /** simple popup that can't handle direct input */,
175 InputWindow = 2 /** annoying dialog that needs direct input */,
176 DefaultWindow = 6/** input window that's also the plasma view */
179 * @return the type of window, based on its X property
181 WindowType windowType(WId id);
183 static QVariant getConf(void *ctx, const char *key, const QVariant &dflt);
184 bool loadGreetPlugin();
186 bool mLocked;
187 int mLockGrace;
188 int mPriority;
189 bool mBusy;
190 KProcess mHackProc;
191 KProcess mPlasmaProc;
192 org::kde::plasmaoverlay::App *mPlasmaDBus;
193 bool mPlasmaEnabled;
194 bool mSetupMode;
195 QString mSaverExec;
196 QString mSaver;
197 bool mOpenGLVisual;
198 bool child_saver;
199 QList<int> child_sockets;
200 int mParent;
201 bool mUseBlankOnly;
202 bool mSuspended;
203 QTimer mSuspendTimer;
204 bool mVisibility;
205 bool mDPMSDepend;
206 QTimer mCheckDPMS;
207 QStack< QWidget* > mDialogs;
208 QHash< QWidget*, QWidget* > mFrames;
209 bool mRestoreXF86Lock;
210 bool mForbidden;
211 QStringList mPlugins, mPluginOptions;
212 QString mMethod;
213 GreeterPluginHandle greetPlugin;
214 QPixmap mSavedScreen;
215 int mAutoLogoutTimerId;
216 int mAutoLogoutTimeout;
217 QTimer mSuppressUnlock;
218 int mSuppressUnlockTimeout;
219 QList<WId> mForeignWindows;
220 QList<WId> mForeignInputWindows;
223 #endif