diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-02-07 03:19:33 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2012-06-03 03:26:51 +0200 |
commit | 62a9582844524025136e3e595625c98dacc1e69f (patch) | |
tree | 32aad0ad5cfdf5e10483ac0d38e2118bab2fd7e2 /kdesktop/lock | |
parent | cf85ef952c224946891b27d4aec0b1fe3f722d6d (diff) | |
download | tdebase-62a9582844524025136e3e595625c98dacc1e69f.tar.gz tdebase-62a9582844524025136e3e595625c98dacc1e69f.zip |
Allow minimal managed window interaction inside the lock process
This closes Bug 810
(cherry picked from commit 678bea5ba74b3b39981e482e188c61fdd37786f0)
Diffstat (limited to 'kdesktop/lock')
-rw-r--r-- | kdesktop/lock/lockprocess.cc | 73 | ||||
-rw-r--r-- | kdesktop/lock/lockprocess.h | 7 | ||||
-rw-r--r-- | kdesktop/lock/main.h | 1 |
3 files changed, 78 insertions, 3 deletions
diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index e438f06ea..d3087e24d 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -111,8 +111,8 @@ Status DPMSInfo ( Display *, CARD16 *, BOOL * ); #define LOCK_GRACE_DEFAULT 5000 #define AUTOLOGOUT_DEFAULT 600 -// FIXME -// This should be defined if Qt 3.4.0 or higher is in use +// Setting this define is INSECURE +// Use it for debugging purposes ONLY // #define KEEP_MOUSE_UNGRABBED 1 // These lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special multimedia keys @@ -185,7 +185,12 @@ LockProcess::LockProcess(bool child, bool useBlankOnly) mHackStartupEnabled(true), m_rootPixmap(NULL), mBackingStartupDelayTimer(0), - m_startupStatusDialog(NULL) + m_startupStatusDialog(NULL), + m_mouseDown(0), + m_mousePrevX(0), + m_mousePrevY(0), + m_dialogPrevX(0), + m_dialogPrevY(0) { #ifdef KEEP_MOUSE_UNGRABBED setNFlags(WX11DisableMove|WX11DisableClose|WX11DisableShade|WX11DisableMinimize|WX11DisableMaximize); @@ -208,6 +213,8 @@ LockProcess::LockProcess(bool child, bool useBlankOnly) mEnsureVRootWindowSecurityTimer = new TQTimer( this ); connect( mEnsureVRootWindowSecurityTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(repaintRootWindowIfNeeded()) ); + connect(tqApp, TQT_SIGNAL(mouseInteraction(XEvent *)), TQT_SLOT(slotMouseActivity(XEvent *))); + mHackDelayStartupTimeout = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::timeout()*1000:10*1000; mHackStartupEnabled = trinity_desktop_lock_delay_screensaver_start?KDesktopSettings::screenSaverEnabled():true; @@ -2200,4 +2207,64 @@ void LockProcess::sendVkbdFocusInOut( WId window, Time t ) } } +void LockProcess::slotMouseActivity(XEvent *event) +{ + bool inFrame = 0; + bool inDialog = 0; + XButtonEvent *be = (XButtonEvent *) event; + XMotionEvent *me = (XMotionEvent *) event; + if (event->type == ButtonPress) { + // Get geometry including window frame/titlebar + TQRect fgeom = mDialogs.first()->frameGeometry(); + TQRect wgeom = mDialogs.first()->geometry(); + + if (((be->x_root > fgeom.x()) && (be->y_root > fgeom.y())) && ((be->x_root < (fgeom.x()+fgeom.width())) && (be->y_root < (fgeom.y()+fgeom.height())))) { + inFrame = 1; + } + if (((be->x_root > wgeom.x()) && (be->y_root > wgeom.y())) && ((be->x_root < (wgeom.x()+wgeom.width())) && (be->y_root < (wgeom.y()+wgeom.height())))) { + inDialog = 1; + } + + // Clicked inside dialog; set focus + if (inFrame == TRUE) { + WId window = mDialogs.first()->winId(); + XSetInputFocus(qt_xdisplay(), window, RevertToParent, CurrentTime); + fakeFocusIn(window); + // Why this needs to be repeated I have no idea... + XSetInputFocus(qt_xdisplay(), window, RevertToParent, CurrentTime); + fakeFocusIn(window); + } + + // Clicked inside window handle (or border); drag window + if ((inFrame == TRUE) && (inDialog == FALSE)) { + TQPoint oldPoint = mDialogs.first()->pos(); + m_mouseDown = 1; + m_dialogPrevX = oldPoint.x(); + m_dialogPrevY = oldPoint.y(); + m_mousePrevX = be->x_root; + m_mousePrevY = be->y_root; + XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, TQCursor(tqsizeAllCursor).handle(), CurrentTime); + } + } + + // Drag the window... + if (event->type == MotionNotify) { + if (m_mouseDown == TRUE) { + int deltaX = me->x_root - m_mousePrevX; + int deltaY = me->y_root - m_mousePrevY; + m_dialogPrevX = m_dialogPrevX + deltaX; + m_dialogPrevY = m_dialogPrevY + deltaY; + mDialogs.first()->move(m_dialogPrevX, m_dialogPrevY); + + m_mousePrevX = me->x_root; + m_mousePrevY = me->y_root; + } + } + + if (event->type == ButtonRelease) { + m_mouseDown = 0; + XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime); + } +} + #include "lockprocess.moc" diff --git a/kdesktop/lock/lockprocess.h b/kdesktop/lock/lockprocess.h index 8be44e57c..ec220f3f6 100644 --- a/kdesktop/lock/lockprocess.h +++ b/kdesktop/lock/lockprocess.h @@ -94,6 +94,7 @@ private slots: bool closeCurrentWindow(); void repaintRootWindowIfNeeded(); void startSecureDialog(); + void slotMouseActivity(XEvent *event); private: void configure(); @@ -197,6 +198,12 @@ private: KSMModalDialog* m_startupStatusDialog; TQDateTime mlockDateTime; + + bool m_mouseDown; + int m_mousePrevX; + int m_mousePrevY; + int m_dialogPrevX; + int m_dialogPrevY; }; #endif diff --git a/kdesktop/lock/main.h b/kdesktop/lock/main.h index c8e0e05a4..23797e4b0 100644 --- a/kdesktop/lock/main.h +++ b/kdesktop/lock/main.h @@ -32,6 +32,7 @@ protected: bool x11EventFilter( XEvent * ); signals: void activity(); + void mouseInteraction(XEvent *event); private: time_t lastTick; }; |