proper interface name here too (is this an ok name? I'm just making stuff up...)
[kdebase.git] / workspace / krunner / lock / lockprocess.h
blob68bd67aaeea7f8bf6a21ae55a8118b26f7146df6
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 class QDBusInterface;
27 class KLibrary;
29 struct KGreeterPluginInfo;
31 struct GreeterPluginHandle {
32 KLibrary *library;
33 KGreeterPluginInfo *info;
36 //===========================================================================
38 // Screen saver handling process. Handles screensaver window,
39 // starting screensaver hacks, and password entry.
41 class LockProcess
42 : public QWidget
44 Q_OBJECT
45 Q_CLASSINFO("D-Bus Interface", "org.kde.krunner_lock.LockProcess")
46 public:
47 explicit LockProcess(bool child_saver = false, bool useBlankOnly = false);
48 ~LockProcess();
50 /**
51 * start the screensaver locked
53 bool lock();
55 /**
56 * start the screensaver unlocked
58 bool defaultSave();
60 /**
61 * start the screensaver in plasma setup mode
62 * if plasma is disabled this just acts like defaultSave
64 bool startSetup();
66 /**
67 * start the screensaver unlocked, and *never* automatically lock it
69 bool dontLock();
71 void setChildren(QList<int> children) { child_sockets = children; }
72 void setParent(int fd) { mParent = fd; }
74 void msgBox( QWidget *parent, QMessageBox::Icon type, const QString &txt );
75 int execDialog( QDialog* dlg );
77 public Q_SLOTS:
78 void quitSaver();
79 void preparePopup();
80 void cleanupPopup();
81 //dbus methods
82 /**
83 * bring up the password dialog with @param reason displayed instead of the usual "this session
84 * is locked" message.
85 * @return true if the password was entered correctly
86 * if this returns true, it will also unlock the screensaver without quitting.
87 * it will re-lock after the lock timeout in the settings
89 Q_SCRIPTABLE bool checkPass(const QString &reason);
90 /**
91 * this will unlock and quit the screensaver, asking for a password first if necessary
93 Q_SCRIPTABLE void quit();
94 /**
95 * immediately lock the screen; it will now require a password to unlock.
97 Q_SCRIPTABLE bool startLock();
99 protected:
100 virtual bool x11Event(XEvent *);
101 virtual void timerEvent(QTimerEvent *);
102 virtual bool eventFilter(QObject *o, QEvent *e);
104 private Q_SLOTS:
105 void hackExited();
106 void signalPipeSignal();
107 void suspend();
108 void checkDPMSActive();
109 void slotDeadTimePassed();
111 * a new dbus service has come in
113 void newService(QString name);
115 * set the winid of plasma's view
116 * so that we can control it
118 void setPlasmaView(uint id); //it's really a WId but qdbuscpp2xml is dumb
120 * tell plasma we're in idle mode
122 void deactivatePlasma();
123 void lockPlasma();
125 * immediately un-suppress the password dialog
126 * FIXME need a better name
128 void unSuppressUnlock();
130 private:
131 void configure();
132 void readSaver();
133 void createSaverWindow();
134 void hideSaverWindow();
135 void saveVRoot();
136 void setVRoot(Window win, Window rw);
137 void removeVRoot(Window win);
138 bool grabKeyboard();
139 bool grabMouse();
140 bool grabInput();
141 void ungrabInput();
142 void cantLock(const QString &reason);
143 bool startSaver();
144 void stopSaver();
145 bool startHack();
146 void stopHack();
147 bool startPlasma();
148 void stopPlasma();
149 void setupSignals();
151 * exec the password dialog
152 * @return true iff the password was checked and is valid
154 bool checkPass();
155 void stayOnTop();
156 void lockXF86();
157 void unlockXF86();
158 void resume( bool force );
159 enum WindowType { IgnoreWindow = 0 /** regular window to be left below the saver */,
160 SimpleWindow = 1 /** simple popup that can't handle direct input */,
161 InputWindow = 2 /** annoying dialog that needs direct input */,
162 DefaultWindow = 6/** input window that's also the plasma view */
165 * @return the type of window, based on its X property
167 WindowType windowType(WId id);
169 static QVariant getConf(void *ctx, const char *key, const QVariant &dflt);
170 bool loadGreetPlugin();
172 bool mLocked;
173 int mLockGrace;
174 int mPriority;
175 bool mBusy;
176 KProcess mHackProc;
177 KProcess mPlasmaProc;
178 QDBusInterface *mPlasmaDBus;
179 WId mPlasmaView;
180 bool mPlasmaEnabled;
181 bool mSetupMode;
182 QString mSaverExec;
183 QString mSaver;
184 bool mOpenGLVisual;
185 bool child_saver;
186 QList<int> child_sockets;
187 int mParent;
188 bool mUseBlankOnly;
189 bool mSuspended;
190 QTimer mSuspendTimer;
191 bool mVisibility;
192 bool mDPMSDepend;
193 QTimer mCheckDPMS;
194 QStack< QWidget* > mDialogs;
195 QHash< QWidget*, QWidget* > mFrames;
196 bool mRestoreXF86Lock;
197 bool mForbidden;
198 QStringList mPlugins, mPluginOptions;
199 QString mMethod;
200 GreeterPluginHandle greetPlugin;
201 QPixmap mSavedScreen;
202 int mAutoLogoutTimerId;
203 int mAutoLogoutTimeout;
204 bool mAutoLogout;
205 QTimer mSuppressUnlock;
206 int mSuppressUnlockTimeout;
207 QList<WId> mForeignWindows;
208 QList<WId> mForeignInputWindows;
211 #endif