From 387117c2446a397a42698e9d8cfdf9ff1f371c96 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 19 Apr 2010 02:33:38 +0000 Subject: Enhanced Compiz support Added preliminary ability for allowing specific hotkeys to execute global shortcut actions while the desktop lock is active. The primary use for this is to switch monitors while the screen is still locked (with the switch-monitor hotkey) so that the user can login. git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1116279 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdesktop/lock/lockprocess.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++ kdesktop/lock/lockprocess.h | 1 + 2 files changed, 53 insertions(+) (limited to 'kdesktop/lock') diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index 2664c1c24..1e4e64940 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -25,6 +25,7 @@ #include "kdesktopsettings.h" #include +#include #include #include @@ -100,6 +101,12 @@ Status DPMSInfo ( Display *, CARD16 *, BOOL * ); #define LOCK_GRACE_DEFAULT 5000 #define AUTOLOGOUT_DEFAULT 600 +// These lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special multimedia keys +#define XF86XK_AudioMute 0x1008FF12 +#define XF86XK_AudioRaiseVolume 0x1008FF13 +#define XF86XK_AudioLowerVolume 0x1008FF +#define XF86XK_Display 0x1008FF59 + static Window gVRoot = 0; static Window gVRootData = 0; static Atom gXA_VROOT; @@ -194,6 +201,10 @@ LockProcess::LockProcess(bool child, bool useBlankOnly) } #endif +#if (QT_VERSION-0 >= 0x030200) // XRANDR support + connect( kapp->desktop(), SIGNAL( resized( int )), SLOT( desktopResized())); +#endif + greetPlugin.library = 0; } @@ -625,6 +636,27 @@ void LockProcess::createSaverWindow() kdDebug(1204) << "Saver window Id: " << winId() << endl; } +void LockProcess::desktopResized() +{ + // Get root window size + XWindowAttributes rootAttr; + XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(), + qt_xscreen()), &rootAttr); + mRootWidth = rootAttr.width; + mRootHeight = rootAttr.height; + + setGeometry(0, 0, mRootWidth, mRootHeight); + + // Restart the hack as the window size is now different + stopHack(); + startHack(); + + if (currentDialog != NULL) { + mForceReject = true; + currentDialog->close(); + } +} + //--------------------------------------------------------------------------- // // Hide the screensaver window @@ -1134,6 +1166,26 @@ void LockProcess::cleanupPopup() // bool LockProcess::x11Event(XEvent *event) { + // Allow certain very specific keypresses through + // Key: Reason: + // XF86Display You need to be able to see the screen when unlocking your computer + // XF86AudioMute Would be nice to be able to shut your computer up in an emergency while it is locked + // XF86AudioRaiseVolume Ditto + // XF86AudioLowerVolume Ditto + // + //if ((event->type == KeyPress) || (event->type == KeyRelease)) { + if (event->type == KeyPress) { + if ((event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_Display)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioMute)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioRaiseVolume)) || \ + (event->xkey.keycode == XKeysymToKeycode(event->xkey.display, XF86XK_AudioLowerVolume))) { + XEvent ev2 = *event; + DCOPRef ref( "*", "MainApplication-Interface"); + ref.send("sendFakeKey", DCOPArg( ev2.xkey.keycode, "unsigned int")); + return true; + } + } + switch (event->type) { case KeyPress: diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h index eed5f92b9..ee1621bc8 100644 --- a/kdesktop/lock/lockprocess.h +++ b/kdesktop/lock/lockprocess.h @@ -64,6 +64,7 @@ public slots: void preparePopup(); void cleanupPopup(); void checkPipe(); + void desktopResized(); protected: virtual bool x11Event(XEvent *); -- cgit v1.2.1