Fix desktop lock process not hiding secondary screens

This closes Bug 669
(cherry picked from commit 4ea3979393)
v3.5.13-sru
Timothy Pearson 13 years ago committed by Slávek Banko
parent 81db2daabd
commit 6dbf47b221

@ -115,7 +115,7 @@ void PasswordDlg::init(GreeterPluginHandle *plugin)
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised );
frame->setLineWidth( 2 ); frame->setLineWidth( 2 );
TQLabel *pixLabel; TQLabel *pixLabel = NULL;
if (!trinity_desktop_lock_use_system_modal_dialogs) { if (!trinity_desktop_lock_use_system_modal_dialogs) {
pixLabel = new TQLabel( frame, "pixlabel" ); pixLabel = new TQLabel( frame, "pixlabel" );
pixLabel->setPixmap(DesktopIcon("lock")); pixLabel->setPixmap(DesktopIcon("lock"));
@ -134,7 +134,7 @@ void PasswordDlg::init(GreeterPluginHandle *plugin)
i18n("<nobr><b>The session was locked by %1</b><br>").arg( user.fullName() ), frame ); i18n("<nobr><b>The session was locked by %1</b><br>").arg( user.fullName() ), frame );
} }
TQLabel *lockDTLabel; TQLabel *lockDTLabel = NULL;
if ((trinity_desktop_lock_use_system_modal_dialogs) && (!m_lockStartDT.isNull())) { if ((trinity_desktop_lock_use_system_modal_dialogs) && (!m_lockStartDT.isNull())) {
lockDTLabel = new TQLabel(i18n("This session has been locked since %1").arg(m_lockStartDT.toString()), frame); lockDTLabel = new TQLabel(i18n("This session has been locked since %1").arg(m_lockStartDT.toString()), frame);
} }

@ -173,6 +173,7 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
mDialogControlLock(false), mDialogControlLock(false),
mForceReject(false), mForceReject(false),
currentDialog(NULL), currentDialog(NULL),
mEnsureScreenHiddenTimer(NULL),
mForceContinualLockDisplayTimer(NULL), mForceContinualLockDisplayTimer(NULL),
mEnsureVRootWindowSecurityTimer(NULL), mEnsureVRootWindowSecurityTimer(NULL),
mHackDelayStartupTimer(NULL), mHackDelayStartupTimer(NULL),
@ -288,6 +289,10 @@ LockProcess::~LockProcess()
hackResumeTimer->stop(); hackResumeTimer->stop();
delete hackResumeTimer; delete hackResumeTimer;
} }
if (mEnsureScreenHiddenTimer != NULL) {
mEnsureScreenHiddenTimer->stop();
delete mEnsureScreenHiddenTimer;
}
if (mForceContinualLockDisplayTimer != NULL) { if (mForceContinualLockDisplayTimer != NULL) {
mForceContinualLockDisplayTimer->stop(); mForceContinualLockDisplayTimer->stop();
delete mForceContinualLockDisplayTimer; delete mForceContinualLockDisplayTimer;
@ -410,7 +415,7 @@ void LockProcess::checkPipe()
if (numread > 0) { if (numread > 0) {
if (readbuf[0] == 'C') { if (readbuf[0] == 'C') {
mInfoMessageDisplayed=false; mInfoMessageDisplayed=false;
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
@ -423,7 +428,7 @@ void LockProcess::checkPipe()
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
@ -444,7 +449,7 @@ void LockProcess::checkPipe()
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
@ -468,7 +473,7 @@ void LockProcess::checkPipe()
to_display = to_display.remove(0,1); to_display = to_display.remove(0,1);
// Lock out password dialogs and close any active dialog // Lock out password dialogs and close any active dialog
mInfoMessageDisplayed=true; mInfoMessageDisplayed=true;
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
if (currentDialog != NULL) { if (currentDialog != NULL) {
mForceReject = true; mForceReject = true;
@ -887,8 +892,13 @@ void LockProcess::desktopResized()
mRootWidth = rootAttr.width; mRootWidth = rootAttr.width;
mRootHeight = rootAttr.height; mRootHeight = rootAttr.height;
// Resize the background widget
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
// Black out the background widget to hide ugly resize tiling artifacts
setBackgroundColor(black);
erase();
// This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever // This slot needs to be able to execute very rapidly so as to prevent the user's desktop from ever
// being displayed, so we finish the hack restarting/display prettying operations in a separate timed slot // being displayed, so we finish the hack restarting/display prettying operations in a separate timed slot
if (resizeTimer == NULL) { if (resizeTimer == NULL) {
@ -902,7 +912,7 @@ void LockProcess::doDesktopResizeFinish()
{ {
stopHack(); stopHack();
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
if (closeCurrentWindow()) { if (closeCurrentWindow()) {
TQTimer::singleShot( 0, this, SLOT(doDesktopResizeFinish()) ); TQTimer::singleShot( 0, this, SLOT(doDesktopResizeFinish()) );
@ -911,7 +921,13 @@ void LockProcess::doDesktopResizeFinish()
mDialogControlLock = false; mDialogControlLock = false;
// Restart the hack as the window size is now different // Restart the hack as the window size is now different
if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
}
else {
startHack(); startHack();
}
mBusy = false; mBusy = false;
} }
@ -1064,7 +1080,7 @@ bool LockProcess::grabInput()
if (!grabKeyboard()) if (!grabKeyboard())
{ {
sleep(1); usleep(100000);
if (!grabKeyboard()) if (!grabKeyboard())
{ {
return false; return false;
@ -1073,7 +1089,7 @@ bool LockProcess::grabInput()
if (!grabMouse()) if (!grabMouse())
{ {
sleep(1); usleep(100000);
if (!grabMouse()) if (!grabMouse())
{ {
XUngrabKeyboard(qt_xdisplay(), CurrentTime); XUngrabKeyboard(qt_xdisplay(), CurrentTime);
@ -1117,7 +1133,7 @@ bool LockProcess::startSaver()
m_grayImage.fill(0); // Set the alpha buffer to 0 (fully transparent) m_grayImage.fill(0); // Set the alpha buffer to 0 (fully transparent)
m_grayImage.setAlphaBuffer(true); m_grayImage.setAlphaBuffer(true);
TQPixmap m_root; TQPixmap m_root;
m_root.resize( TQApplication::desktop()->geometry().width(), TQApplication::desktop()->geometry().height() ); m_root.resize(mRootWidth, mRootHeight);
TQPainter p; TQPainter p;
p.begin( &m_root ); p.begin( &m_root );
m_grayImage.setAlphaBuffer(false); m_grayImage.setAlphaBuffer(false);
@ -1144,14 +1160,21 @@ bool LockProcess::startSaver()
setBackgroundColor(black); setBackgroundColor(black);
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
} }
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
// Try to get the root pixmap // Try to get the root pixmap
m_rootPixmap = new KRootPixmap(this); if (!m_rootPixmap) m_rootPixmap = new KRootPixmap(this);
m_rootPixmap->setCustomPainting(true); m_rootPixmap->setCustomPainting(true);
connect(m_rootPixmap, TQT_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQT_SLOT(slotPaintBackground(const TQPixmap &))); connect(m_rootPixmap, TQT_SIGNAL(backgroundUpdated(const TQPixmap &)), this, TQT_SLOT(slotPaintBackground(const TQPixmap &)));
m_rootPixmap->start(); m_rootPixmap->start();
// Sometimes KRootPixmap fails...make sure the desktop is hidden regardless
if (!mEnsureScreenHiddenTimer) {
mEnsureScreenHiddenTimer = new TQTimer( this );
connect( mEnsureScreenHiddenTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotForcePaintBackground()) );
}
mEnsureScreenHiddenTimer->start(2000, true);
} }
if (trinity_desktop_lock_in_sec_dlg == FALSE) { if (trinity_desktop_lock_in_sec_dlg == FALSE) {
@ -1275,6 +1298,7 @@ void LockProcess::repaintRootWindowIfNeeded()
if (!mHackProc.isRunning()) { if (!mHackProc.isRunning()) {
if (backingPixmap.isNull()) { if (backingPixmap.isNull()) {
setBackgroundColor(black); setBackgroundColor(black);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
} }
else { else {
@ -1298,6 +1322,7 @@ bool LockProcess::startHack()
setBackgroundColor(black); setBackgroundColor(black);
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
return false; return false;
} }
@ -1344,6 +1369,7 @@ bool LockProcess::startHack()
setBackgroundColor(black); setBackgroundColor(black);
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
mSuspended = false; mSuspended = false;
} }
@ -1377,7 +1403,10 @@ bool LockProcess::startHack()
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
} }
if (backingPixmap.isNull()) erase(); if (backingPixmap.isNull()) {
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else bitBlt(this, 0, 0, &backingPixmap); else bitBlt(this, 0, 0, &backingPixmap);
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
@ -1416,7 +1445,10 @@ void LockProcess::hackExited(KProcess *)
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
} }
if (backingPixmap.isNull()) erase(); if (backingPixmap.isNull()) {
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else bitBlt(this, 0, 0, &backingPixmap); else bitBlt(this, 0, 0, &backingPixmap);
if (!mSuspended) { if (!mSuspended) {
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
@ -1492,6 +1524,7 @@ void LockProcess::resume( bool force )
setBackgroundColor(black); setBackgroundColor(black);
else else
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
return; return;
} }
@ -1597,10 +1630,13 @@ int LockProcess::execDialog( TQDialog *dlg )
} }
mDialogs.prepend( dlg ); mDialogs.prepend( dlg );
fakeFocusIn( dlg->winId()); fakeFocusIn( dlg->winId());
if (backingPixmap.isNull() && trinity_desktop_lock_use_system_modal_dialogs) erase(); if (backingPixmap.isNull() && trinity_desktop_lock_use_system_modal_dialogs) {
setGeometry(0, 0, mRootWidth, mRootHeight);
erase();
}
else bitBlt(this, 0, 0, &backingPixmap); else bitBlt(this, 0, 0, &backingPixmap);
int rt = dlg->exec(); int rt = dlg->exec();
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
currentDialog = NULL; currentDialog = NULL;
mDialogs.remove( dlg ); mDialogs.remove( dlg );
if( mDialogs.isEmpty() ) { if( mDialogs.isEmpty() ) {
@ -1624,8 +1660,18 @@ int LockProcess::execDialog( TQDialog *dlg )
return rt; return rt;
} }
void LockProcess::slotForcePaintBackground()
{
TQPixmap blankPixmap(mRootWidth, mRootHeight);
blankPixmap.fill(Qt::black);
slotPaintBackground(blankPixmap);
printf("[WARNING] Unable to obtain desktop wallpaper in a timely manner. High system load or possibly a TDE bug!\n\r"); fflush(stdout);
}
void LockProcess::slotPaintBackground(const TQPixmap &rpm) void LockProcess::slotPaintBackground(const TQPixmap &rpm)
{ {
mEnsureScreenHiddenTimer->stop();
TQPixmap pm = rpm; TQPixmap pm = rpm;
if (TQPaintDevice::x11AppDepth() == 32) { if (TQPaintDevice::x11AppDepth() == 32) {
@ -1652,6 +1698,7 @@ void LockProcess::slotPaintBackground(const TQPixmap &rpm)
backingPixmap = pm; backingPixmap = pm;
if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) { if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced) {
setBackgroundPixmap(backingPixmap); setBackgroundPixmap(backingPixmap);
setGeometry(0, 0, mRootWidth, mRootHeight);
erase(); erase();
} }
} }
@ -1677,7 +1724,7 @@ void LockProcess::doFunctionKeyBroadcast() {
mBusy=true; mBusy=true;
TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed()));
if (mkeyCode == XKeysymToKeycode(qt_xdisplay(), XF86XK_Display)) { if (mkeyCode == XKeysymToKeycode(qt_xdisplay(), XF86XK_Display)) {
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) usleep(100000);
mDialogControlLock = true; mDialogControlLock = true;
currentDialog->close(); // DO NOT use closeCurrentWindow() here! currentDialog->close(); // DO NOT use closeCurrentWindow() here!
mDialogControlLock = false; mDialogControlLock = false;

@ -74,6 +74,7 @@ public slots:
void doDesktopResizeFinish(); void doDesktopResizeFinish();
void doFunctionKeyBroadcast(); void doFunctionKeyBroadcast();
void slotPaintBackground(const TQPixmap &pm); void slotPaintBackground(const TQPixmap &pm);
void slotForcePaintBackground();
protected: protected:
virtual bool x11Event(XEvent *); virtual bool x11Event(XEvent *);
@ -181,6 +182,7 @@ private:
bool mForceReject; bool mForceReject;
TQDialog *currentDialog; TQDialog *currentDialog;
TQTimer* mEnsureScreenHiddenTimer;
TQTimer* mForceContinualLockDisplayTimer; TQTimer* mForceContinualLockDisplayTimer;
TQTimer* mEnsureVRootWindowSecurityTimer; TQTimer* mEnsureVRootWindowSecurityTimer;
TQTimer* mHackDelayStartupTimer; TQTimer* mHackDelayStartupTimer;

Loading…
Cancel
Save