From a6e2ce7a2ae5690c60b6f1c3dfe7d19dd3e2ea7b Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 12 Sep 2011 21:24:43 +0000 Subject: Fix desktop locking with opengl screensavers git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1253062 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdesktop/lock/lockdlg.cc | 2 +- kdesktop/lock/lockprocess.cc | 50 ++++++++++++++++++++++++++++++++++++-------- kdesktop/lock/main.cc | 7 ++++++- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/kdesktop/lock/lockdlg.cc b/kdesktop/lock/lockdlg.cc index 812933e08..b22eddbd8 100644 --- a/kdesktop/lock/lockdlg.cc +++ b/kdesktop/lock/lockdlg.cc @@ -81,7 +81,7 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin) kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(), "_KDE_WM_MODAL_SYS_NOTIFICATION", False); XChangeProperty(qt_xdisplay(), winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L); } - setCaption(i18n("Authentication Required")); + setCaption(i18n("Desktop Session Locked")); frame = new TQFrame( this ); if (trinity_desktop_lock_use_system_modal_dialogs) diff --git a/kdesktop/lock/lockprocess.cc b/kdesktop/lock/lockprocess.cc index 519646f1e..02d2cf860 100644 --- a/kdesktop/lock/lockprocess.cc +++ b/kdesktop/lock/lockprocess.cc @@ -52,6 +52,7 @@ #include #include #include +#include #include @@ -125,6 +126,7 @@ static void segv_handler(int) extern Atom qt_wm_state; extern bool trinity_desktop_lock_use_system_modal_dialogs; extern bool trinity_desktop_lock_delay_screensaver_start; +extern bool trinity_desktop_lock_forced; bool trinity_desktop_lock_autohide_lockdlg = TRUE; @@ -968,7 +970,7 @@ bool LockProcess::startSaver() raise(); XSync(qt_xdisplay(), False); setVRoot( winId(), winId() ); - if (!trinity_desktop_lock_delay_screensaver_start) { + if (!(trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced)) { setBackgroundColor(black); erase(); } @@ -982,7 +984,7 @@ bool LockProcess::startSaver() TQTimer::singleShot( 0, this, SLOT(slotPaintBackground()) ); } - if (trinity_desktop_lock_delay_screensaver_start) { + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { ENABLE_CONTINUOUS_LOCKDLG_DISPLAY mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); } @@ -1122,7 +1124,7 @@ bool LockProcess::startHack() if (!mForbidden) { - if (trinity_desktop_lock_delay_screensaver_start) { + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { // Make sure we have a nice clean display to start with! setBackgroundColor(black); erase(); @@ -1136,7 +1138,7 @@ bool LockProcess::startHack() #endif //bitBlt(this, 0, 0, &mOriginal); DISABLE_CONTINUOUS_LOCKDLG_DISPLAY - if (trinity_desktop_lock_delay_screensaver_start) { + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { // Close any active dialogs if (currentDialog != NULL) { mForceReject = true; @@ -1186,7 +1188,9 @@ void LockProcess::hackExited(KProcess *) if (!trinity_desktop_lock_use_system_modal_dialogs) setBackgroundColor(black); if (backingPixmap.isNull()) erase(); else bitBlt(this, 0, 0, &backingPixmap); - ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + if (!mSuspended) { + ENABLE_CONTINUOUS_LOCKDLG_DISPLAY + } } void LockProcess::displayLockDialogIfNeeded() @@ -1209,9 +1213,34 @@ void LockProcess::suspend() { if(!mSuspended) { - mHackProc.kill(SIGSTOP); - TQApplication::syncX(); - usleep(100); // Let the stop signal get through + if (trinity_desktop_lock_use_system_modal_dialogs) { + mSuspended = true; + stopHack(); + mSuspended = false; + } + else { + TQString hackStatus; + mHackProc.kill(SIGSTOP); +#if 0 + // wait for the stop signal to take effect + while (hackStatus != "T") { + char hackstat[8192]; + FILE *fp = fopen(TQString("/proc/%1/stat").arg(mHackProc.pid()).ascii(),"r"); + if (fp != NULL) { + if (fgets (hackstat, 8192, fp) != NULL) + puts(hackstat); + fclose (fp); + } + hackstat[8191] = 0; + hackStatus = hackstat; + hackStatus = hackStatus.remove(TQRegExp("(*) ", TRUE, TRUE)); + TQStringList hackStatusList = TQStringList::split(" ", hackStatus); + hackStatus = (*(hackStatusList.at(1))); + } +#endif + TQApplication::syncX(); + usleep(100000); // Allow certain bad graphics drivers (*cough* fglrx *cough*) time to actually sync up the display + } TQApplication::syncX(); mSavedScreen = TQPixmap::grabWindow( winId()); } @@ -1229,6 +1258,9 @@ void LockProcess::resume( bool force ) TQApplication::syncX(); mHackProc.kill(SIGCONT); } + else if (mSuspended && trinity_desktop_lock_use_system_modal_dialogs) { + startHack(); + } mSuspended = false; } @@ -1371,7 +1403,7 @@ void LockProcess::slotPaintBackground() } backingPixmap = pm; - if (trinity_desktop_lock_delay_screensaver_start) erase(); + if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) erase(); } void LockProcess::preparePopup() diff --git a/kdesktop/lock/main.cc b/kdesktop/lock/main.cc index 667becaa0..14dd75384 100644 --- a/kdesktop/lock/main.cc +++ b/kdesktop/lock/main.cc @@ -34,10 +34,12 @@ #include #include -// [FIXME] These settings should be user configurable! +// [FIXME] These two settings should be user configurable! bool trinity_desktop_lock_use_system_modal_dialogs = FALSE; bool trinity_desktop_lock_delay_screensaver_start = FALSE; +bool trinity_desktop_lock_forced = FALSE; + bool MyApp::x11EventFilter( XEvent *ev ) { if (ev->type == XKeyPress || ev->type == ButtonPress) @@ -71,6 +73,9 @@ int main( int argc, char **argv ) KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if (args->isSet( "forcelock" )) + trinity_desktop_lock_forced = TRUE; + putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); // not needed -- cgit v1.2.1