Update lock process to engage the lock in near real time

pull/2/head
Timothy Pearson 12 years ago
parent eba2e1a1af
commit 8d521d0b6b

@ -35,6 +35,6 @@ set( ${target}_SRCS
tde_add_executable( ${target} AUTOMOC tde_add_executable( ${target} AUTOMOC
SOURCES ${${target}_SRCS} SOURCES ${${target}_SRCS}
LINK kdesktopsettings-static dmctl-static kio-shared Xext ${GL_LIBRARY} LINK kdesktopsettings-static dmctl-static kio-shared Xext ${GL_LIBRARY} "-z\ now"
DESTINATION ${BIN_INSTALL_DIR} DESTINATION ${BIN_INSTALL_DIR}
) )

@ -1,6 +1,7 @@
/* This file is part of the KDE project /* This file is part of the KDE project
Copyright (C) 1999 David Faure Copyright (C) 1999 David Faure
Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org> Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
Copyright (c) 2010-2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
@ -43,6 +44,13 @@ bool trinity_desktop_lock_use_sak = FALSE;
bool trinity_desktop_lock_forced = FALSE; bool trinity_desktop_lock_forced = FALSE;
bool signalled_forcelock;
bool signalled_dontlock;
bool signalled_securedialog;
bool signalled_blank;
bool signalled_run;
bool in_internal_mode = FALSE;
bool MyApp::x11EventFilter( XEvent *ev ) bool MyApp::x11EventFilter( XEvent *ev )
{ {
if (ev->type == XKeyPress || ev->type == ButtonPress) { if (ev->type == XKeyPress || ev->type == ButtonPress) {

@ -1,8 +1,9 @@
//=========================================================================== //===========================================================================
// //
// This file is part of the KDE project // This file is part of the TDE project
// //
// Copyright (c) 1999 Martin R. Jones <mjones@kde.org> // Copyright (c) 1999 Martin R. Jones <mjones@kde.org>
// Copyright (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
// //
@ -29,6 +30,14 @@ extern xautolock_corner_t xautolock_corners[ 4 ];
bool trinity_lockeng_sak_available = TRUE; bool trinity_lockeng_sak_available = TRUE;
SaverEngine* m_masterSaverEngine = NULL;
static void sigusr1_handler(int)
{
if (m_masterSaverEngine) {
m_masterSaverEngine->lockProcessWaiting();
}
}
//=========================================================================== //===========================================================================
// //
// Screen saver engine. Doesn't handle the actual screensaver window, // Screen saver engine. Doesn't handle the actual screensaver window,
@ -42,6 +51,16 @@ SaverEngine::SaverEngine()
mSAKProcess(NULL), mSAKProcess(NULL),
mTerminationRequested(false) mTerminationRequested(false)
{ {
struct sigaction act;
// handle SIGUSR1
m_masterSaverEngine = this;
act.sa_handler= sigusr1_handler;
sigemptyset(&(act.sa_mask));
sigaddset(&(act.sa_mask), SIGUSR1);
act.sa_flags = 0;
sigaction(SIGUSR1, &act, 0L);
// Save X screensaver parameters // Save X screensaver parameters
XGetScreenSaver(qt_xdisplay(), &mXTimeout, &mXInterval, XGetScreenSaver(qt_xdisplay(), &mXTimeout, &mXInterval,
&mXBlanking, &mXExposures); &mXBlanking, &mXExposures);
@ -60,6 +79,19 @@ SaverEngine::SaverEngine()
TQTimer::singleShot( 0, this, TQT_SLOT(handleSecureDialog()) ); TQTimer::singleShot( 0, this, TQT_SLOT(handleSecureDialog()) );
configure(); configure();
mLockProcess.clearArguments();
TQString path = KStandardDirs::findExe( "kdesktop_lock" );
if( path.isEmpty())
{
kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl;
}
mLockProcess << path;
mLockProcess << TQString( "--internal" ) << TQString( "%1" ).arg(getpid());
if (mLockProcess.start() == false )
{
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl;
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -68,6 +100,10 @@ SaverEngine::SaverEngine()
// //
SaverEngine::~SaverEngine() SaverEngine::~SaverEngine()
{ {
if (mState == Waiting) {
kill(mLockProcess.pid(), SIGKILL);
}
mLockProcess.detach(); // don't kill it if we crash mLockProcess.detach(); // don't kill it if we crash
delete mXAutoLock; delete mXAutoLock;
@ -86,9 +122,9 @@ void SaverEngine::lock()
{ {
mSAKProcess->kill(SIGTERM); mSAKProcess->kill(SIGTERM);
ok = startLockProcess( ForceLock ); ok = startLockProcess( ForceLock );
// It takes a while for kdesktop_lock to start and lock the screen. // It takes a while for kdesktop_lock to start and lock the screen.
// Therefore delay the DCOP call until it tells kdesktop that the locking is in effect. // Therefore delay the DCOP call until it tells kdesktop that the locking is in effect.
// This is done only for --forcelock . // This is done only for --forcelock .
if( ok && mState != Saving ) if( ok && mState != Saving )
{ {
DCOPClientTransaction* trans = kapp->dcopClient()->beginTransaction(); DCOPClientTransaction* trans = kapp->dcopClient()->beginTransaction();
@ -283,40 +319,42 @@ bool SaverEngine::startLockProcess( LockType lock_type )
kdDebug(1204) << "SaverEngine: starting saver" << endl; kdDebug(1204) << "SaverEngine: starting saver" << endl;
emitDCOPSignal("KDE_start_screensaver()", TQByteArray()); emitDCOPSignal("KDE_start_screensaver()", TQByteArray());
if (mLockProcess.isRunning()) if (!mLockProcess.isRunning()) {
{ mLockProcess.clearArguments();
stopLockProcess(); TQString path = KStandardDirs::findExe( "kdesktop_lock" );
} if( path.isEmpty())
mLockProcess.clearArguments(); {
TQString path = KStandardDirs::findExe( "kdesktop_lock" ); kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl;
if( path.isEmpty()) return false;
{ }
kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl; mLockProcess << path;
return false; mLockProcess << TQString( "--internal" ) << TQString( "%1" ).arg(getpid());
if (mLockProcess.start() == false )
{
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl;
return false;
}
} }
mLockProcess << path;
switch( lock_type ) switch( lock_type )
{ {
case ForceLock: case ForceLock:
mLockProcess << TQString( "--forcelock" ); mLockProcess.kill(SIGUSR1); // Request forcelock
break; break;
case DontLock: case DontLock:
mLockProcess << TQString( "--dontlock" ); mLockProcess.kill(SIGUSR2); // Request dontlock
break; break;
case SecureDialog: case SecureDialog:
mLockProcess << TQString( "--securedialog" ); mLockProcess.kill(SIGWINCH); // Request secure dialog
break; break;
default: default:
break; break;
} }
if (mBlankOnly) if (mBlankOnly) {
mLockProcess << TQString( "--blank" ); mLockProcess.kill(SIGTTIN); // Request blanking
if (mLockProcess.start() == false )
{
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl;
return false;
} }
mLockProcess.kill(SIGTTOU); // Start lock
XSetScreenSaver(qt_xdisplay(), 0, mXInterval, PreferBlanking, mXExposures); XSetScreenSaver(qt_xdisplay(), 0, mXInterval, PreferBlanking, mXExposures);
mState = Preparing; mState = Preparing;
@ -359,9 +397,7 @@ void SaverEngine::stopLockProcess()
void SaverEngine::lockProcessExited() void SaverEngine::lockProcessExited()
{ {
printf("Lock process exited\n\r"); fflush(stdout);
bool abnormalExit = false; bool abnormalExit = false;
kdDebug(1204) << "SaverEngine: lock exited" << endl;
if (mLockProcess.normalExit() == false) { if (mLockProcess.normalExit() == false) {
abnormalExit = true; abnormalExit = true;
} }
@ -387,6 +423,28 @@ printf("Lock process exited\n\r"); fflush(stdout);
system("logout"); system("logout");
} }
} }
else {
// Restart the lock process
if (!mLockProcess.isRunning()) {
mLockProcess.clearArguments();
TQString path = KStandardDirs::findExe( "kdesktop_lock" );
if( path.isEmpty())
{
kdDebug( 1204 ) << "Can't find kdesktop_lock!" << endl;
}
mLockProcess << path;
mLockProcess << TQString( "--internal" ) << TQString( "%1" ).arg(getpid());
if (mLockProcess.start() == false )
{
kdDebug( 1204 ) << "Failed to start kdesktop_lock!" << endl;
}
}
}
}
void SaverEngine::lockProcessWaiting()
{
kdDebug(1204) << "SaverEngine: lock exited" << endl;
if (trinity_lockeng_sak_available == TRUE) { if (trinity_lockeng_sak_available == TRUE) {
handleSecureDialog(); handleSecureDialog();
} }

@ -78,6 +78,9 @@ public:
*/ */
virtual void saverLockReady(); virtual void saverLockReady();
public slots:
void lockProcessWaiting();
protected slots: protected slots:
void idleTimeout(); void idleTimeout();
void lockProcessExited(); void lockProcessExited();

Loading…
Cancel
Save