Fix system modal dialogs

Fix shutdown background
Add code to make the desktop locking system use the system window decorations and generally use the same theme and style as the active desktop
This code is disabled for now, but can be enabled via the two new static variables in kdesktop/lock/main.cc


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1252900 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 1f40ada72d
commit 9925fc58bc

@ -25,12 +25,27 @@
#include <tqdialog.h> #include <tqdialog.h>
#include <tqprogressbar.h> #include <tqprogressbar.h>
#include <X11/Xatom.h>
#define COUNTDOWN 30 #define COUNTDOWN 30
AutoLogout::AutoLogout(LockProcess *parent) : TQDialog(parent, "password dialog", true, (WFlags)WX11BypassWM) extern bool trinity_desktop_lock_use_system_modal_dialogs;
AutoLogout::AutoLogout(LockProcess *parent) : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)))
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
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("Automatic Logout Notification"));
frame = new TQFrame(this); frame = new TQFrame(this);
frame->setFrameStyle(TQFrame::Panel | TQFrame::Raised); if (trinity_desktop_lock_use_system_modal_dialogs)
frame->setFrameStyle( TQFrame::NoFrame );
else
frame->setFrameStyle(TQFrame::Panel | TQFrame::Raised);
frame->setLineWidth(2); frame->setLineWidth(2);
TQLabel *pixLabel = new TQLabel( frame, "pixlabel" ); TQLabel *pixLabel = new TQLabel( frame, "pixlabel" );

@ -48,22 +48,36 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h>
#include <fixx11h.h> #include <fixx11h.h>
#ifndef AF_LOCAL #ifndef AF_LOCAL
# define AF_LOCAL AF_UNIX # define AF_LOCAL AF_UNIX
#endif #endif
extern bool trinity_desktop_lock_use_system_modal_dialogs;
//=========================================================================== //===========================================================================
// //
// Simple dialog for displaying an unlock status or recurring error message // Simple dialog for displaying an unlock status or recurring error message
// //
InfoDlg::InfoDlg(LockProcess *parent) InfoDlg::InfoDlg(LockProcess *parent)
: TQDialog(parent, "information dialog", true, (WFlags)WX11BypassWM), : TQDialog(parent, "information dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))),
mUnlockingFailed(false) mUnlockingFailed(false)
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
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("Information"));
frame = new TQFrame( this ); frame = new TQFrame( this );
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); if (trinity_desktop_lock_use_system_modal_dialogs)
frame->setFrameStyle( TQFrame::NoFrame );
else
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised );
frame->setLineWidth( 2 ); frame->setLineWidth( 2 );
mpixLabel = new TQLabel( frame, "pixlabel" ); mpixLabel = new TQLabel( frame, "pixlabel" );

@ -52,26 +52,42 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h>
#include <fixx11h.h> #include <fixx11h.h>
#ifndef AF_LOCAL #ifndef AF_LOCAL
# define AF_LOCAL AF_UNIX # define AF_LOCAL AF_UNIX
#endif #endif
// [FIXME] This interval should be taken from the screensaver start delay of kdesktop
#define PASSDLG_HIDE_TIMEOUT 10000 #define PASSDLG_HIDE_TIMEOUT 10000
extern bool trinity_desktop_lock_autohide_lockdlg;
extern bool trinity_desktop_lock_use_system_modal_dialogs;
//=========================================================================== //===========================================================================
// //
// Simple dialog for entering a password. // Simple dialog for entering a password.
// //
PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin) PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin)
: TQDialog(parent, "password dialog", true, (WFlags)WX11BypassWM), : TQDialog(parent, "password dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))),
mPlugin( plugin ), mPlugin( plugin ),
mCapsLocked(-1), mCapsLocked(-1),
mUnlockingFailed(false) mUnlockingFailed(false)
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
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"));
frame = new TQFrame( this ); frame = new TQFrame( this );
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); if (trinity_desktop_lock_use_system_modal_dialogs)
frame->setFrameStyle( TQFrame::NoFrame );
else
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised );
frame->setLineWidth( 2 ); frame->setLineWidth( 2 );
TQLabel *pixLabel = new TQLabel( frame, "pixlabel" ); TQLabel *pixLabel = new TQLabel( frame, "pixlabel" );
@ -93,6 +109,7 @@ PasswordDlg::PasswordDlg(LockProcess *parent, GreeterPluginHandle *plugin)
mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), frame ); mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), frame );
ok = new KPushButton( i18n("Unl&ock"), frame ); ok = new KPushButton( i18n("Unl&ock"), frame );
cancel = new KPushButton( KStdGuiItem::cancel(), frame ); cancel = new KPushButton( KStdGuiItem::cancel(), frame );
if (!trinity_desktop_lock_autohide_lockdlg) cancel->setEnabled(false);
greet = plugin->info->create( this, 0, this, mLayoutButton, TQString::null, greet = plugin->info->create( this, 0, this, mLayoutButton, TQString::null,
KGreeterPlugin::Authenticate, KGreeterPlugin::ExUnlock ); KGreeterPlugin::Authenticate, KGreeterPlugin::ExUnlock );
@ -164,6 +181,12 @@ PasswordDlg::~PasswordDlg()
delete greet; delete greet;
} }
void PasswordDlg::reject()
{
if (trinity_desktop_lock_autohide_lockdlg)
TQDialog::reject();
}
void PasswordDlg::layoutClicked() void PasswordDlg::layoutClicked()
{ {
@ -210,7 +233,12 @@ void PasswordDlg::timerEvent(TQTimerEvent *ev)
{ {
if (ev->timerId() == mTimeoutTimerId) if (ev->timerId() == mTimeoutTimerId)
{ {
reject(); if (trinity_desktop_lock_autohide_lockdlg) {
reject();
}
else {
slotActivity();
}
} }
else if (ev->timerId() == mFailedTimerId) else if (ev->timerId() == mFailedTimerId)
{ {
@ -513,9 +541,21 @@ void PasswordDlg::slotStartNewSession()
killTimer(mTimeoutTimerId); killTimer(mTimeoutTimerId);
mTimeoutTimerId = 0; mTimeoutTimerId = 0;
TQDialog *dialog = new TQDialog( this, "warnbox", true, (WFlags)WX11BypassWM ); TQDialog *dialog = new TQDialog( this, "warnbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)));
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(), "_KDE_WM_MODAL_SYS_NOTIFICATION", False);
XChangeProperty(qt_xdisplay(), dialog->winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L);
}
dialog->setCaption(i18n("New Session"));
TQFrame *winFrame = new TQFrame( dialog ); TQFrame *winFrame = new TQFrame( dialog );
winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); if (trinity_desktop_lock_use_system_modal_dialogs)
winFrame->setFrameStyle( TQFrame::NoFrame );
else
winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
winFrame->setLineWidth( 2 ); winFrame->setLineWidth( 2 );
TQVBoxLayout *vbox = new TQVBoxLayout( dialog ); TQVBoxLayout *vbox = new TQVBoxLayout( dialog );
vbox->addWidget( winFrame ); vbox->addWidget( winFrame );
@ -627,9 +667,21 @@ void PasswordDlg::slotSwitchUser()
int p = 0; int p = 0;
DM dm; DM dm;
TQDialog dialog( this, "sessbox", true, (WFlags)WX11BypassWM ); TQDialog dialog( this, "sessbox", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM)) );
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(), "_KDE_WM_MODAL_SYS_NOTIFICATION", False);
XChangeProperty(qt_xdisplay(), dialog.winId(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L);
}
dialog.setCaption(i18n("Switch User"));
TQFrame *winFrame = new TQFrame( &dialog ); TQFrame *winFrame = new TQFrame( &dialog );
winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); if (trinity_desktop_lock_use_system_modal_dialogs)
winFrame->setFrameStyle( TQFrame::NoFrame );
else
winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
winFrame->setLineWidth( 2 ); winFrame->setLineWidth( 2 );
TQBoxLayout *vbox = new TQVBoxLayout( &dialog ); TQBoxLayout *vbox = new TQVBoxLayout( &dialog );
vbox->addWidget( winFrame ); vbox->addWidget( winFrame );

@ -58,6 +58,9 @@ private slots:
void layoutClicked(); void layoutClicked();
void slotActivity(); void slotActivity();
protected slots:
virtual void reject();
private: private:
void setLayoutText( const TQString &txt ); void setLayoutText( const TQString &txt );
void capsLocked(); void capsLocked();

@ -51,6 +51,7 @@
#include <tqsocketnotifier.h> #include <tqsocketnotifier.h>
#include <tqvaluevector.h> #include <tqvaluevector.h>
#include <tqtooltip.h> #include <tqtooltip.h>
#include <tqimage.h>
#include <tqdatetime.h> #include <tqdatetime.h>
@ -122,6 +123,18 @@ static void segv_handler(int)
} }
extern Atom qt_wm_state; extern Atom qt_wm_state;
extern bool trinity_desktop_lock_use_system_modal_dialogs;
extern bool trinity_desktop_lock_delay_screensaver_start;
bool trinity_desktop_lock_autohide_lockdlg = TRUE;
#define ENABLE_CONTINUOUS_LOCKDLG_DISPLAY \
mForceContinualLockDisplayTimer->start(100, FALSE); \
trinity_desktop_lock_autohide_lockdlg = FALSE;
#define DISABLE_CONTINUOUS_LOCKDLG_DISPLAY \
mForceContinualLockDisplayTimer->stop(); \
trinity_desktop_lock_autohide_lockdlg = TRUE;
//=========================================================================== //===========================================================================
// //
@ -129,7 +142,7 @@ extern Atom qt_wm_state;
// starting screensaver hacks, and password entry.f // starting screensaver hacks, and password entry.f
// //
LockProcess::LockProcess(bool child, bool useBlankOnly) LockProcess::LockProcess(bool child, bool useBlankOnly)
: TQWidget(0L, "saver window", WX11BypassWM), : TQWidget(0L, "saver window", (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)(WStyle_StaysOnTop|WStyle_Customize | WStyle_NoBorder)):((WFlags)WX11BypassWM))),
mOpenGLVisual(0), mOpenGLVisual(0),
child_saver(child), child_saver(child),
mParent(0), mParent(0),
@ -147,13 +160,26 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
mForceReject(false), mForceReject(false),
mDialogControlLock(false), mDialogControlLock(false),
currentDialog(NULL), currentDialog(NULL),
resizeTimer(NULL) resizeTimer(NULL),
hackResumeTimer(NULL),
mForceContinualLockDisplayTimer(NULL),
mHackDelayStartupTimer(NULL),
mHackDelayStartupTimeout(0)
{ {
setupSignals(); setupSignals();
setupPipe(); setupPipe();
kapp->installX11EventFilter(this); kapp->installX11EventFilter(this);
mForceContinualLockDisplayTimer = new TQTimer( this );
connect( mForceContinualLockDisplayTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(displayLockDialogIfNeeded()) );
mHackDelayStartupTimer = new TQTimer( this );
connect( mHackDelayStartupTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(startHack()) );
// [FIXME] This interval should be taken from the screensaver start delay of kdesktop
mHackDelayStartupTimeout = 10*1000;
// Get root window size // Get root window size
XWindowAttributes rootAttr; XWindowAttributes rootAttr;
XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(), XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(),
@ -232,6 +258,23 @@ LockProcess::LockProcess(bool child, bool useBlankOnly)
// //
LockProcess::~LockProcess() LockProcess::~LockProcess()
{ {
if (resizeTimer != NULL) {
resizeTimer->stop();
delete resizeTimer;
}
if (hackResumeTimer != NULL) {
hackResumeTimer->stop();
delete hackResumeTimer;
}
if (mForceContinualLockDisplayTimer != NULL) {
mForceContinualLockDisplayTimer->stop();
delete mForceContinualLockDisplayTimer;
}
if (mHackDelayStartupTimer != NULL) {
mHackDelayStartupTimer->stop();
delete mHackDelayStartupTimer;
}
if (greetPlugin.library) { if (greetPlugin.library) {
if (greetPlugin.info->done) if (greetPlugin.info->done)
greetPlugin.info->done(); greetPlugin.info->done();
@ -575,10 +618,19 @@ void LockProcess::readSaver()
kdDebug(1204) << "mForbidden: " << (mForbidden ? "true" : "false") << endl; kdDebug(1204) << "mForbidden: " << (mForbidden ? "true" : "false") << endl;
if (config.hasActionGroup("Root")) if (trinity_desktop_lock_use_system_modal_dialogs) {
{ if (config.hasActionGroup("InWindow"))
config.setActionGroup("Root"); {
mSaverExec = config.readPathEntry("Exec"); config.setActionGroup("InWindow");
mSaverExec = config.readPathEntry("Exec");
}
}
else {
if (config.hasActionGroup("Root"))
{
config.setActionGroup("Root");
mSaverExec = config.readPathEntry("Exec");
}
} }
} }
} }
@ -591,7 +643,7 @@ void LockProcess::createSaverWindow()
{ {
Visual* visual = CopyFromParent; Visual* visual = CopyFromParent;
XSetWindowAttributes attrs; XSetWindowAttributes attrs;
int flags = CWOverrideRedirect; int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect;
#ifdef HAVE_GLXCHOOSEVISUAL #ifdef HAVE_GLXCHOOSEVISUAL
if( mOpenGLVisual ) if( mOpenGLVisual )
{ {
@ -658,7 +710,8 @@ void LockProcess::createSaverWindow()
// set NoBackground so that the saver can capture the current // set NoBackground so that the saver can capture the current
// screen state if necessary // screen state if necessary
setBackgroundMode(TQWidget::NoBackground); // this is a security risk and has been deactivated--welcome to the 21st century folks!
// setBackgroundMode(TQWidget::NoBackground);
setCursor( tqblankCursor ); setCursor( tqblankCursor );
setGeometry(0, 0, mRootWidth, mRootHeight); setGeometry(0, 0, mRootWidth, mRootHeight);
@ -915,7 +968,27 @@ bool LockProcess::startSaver()
raise(); raise();
XSync(qt_xdisplay(), False); XSync(qt_xdisplay(), False);
setVRoot( winId(), winId() ); setVRoot( winId(), winId() );
startHack(); if (!trinity_desktop_lock_delay_screensaver_start) {
setBackgroundColor(black);
erase();
}
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Try to get the root pixmap
TQString filename = getenv("USER");
filename.prepend("/tmp/kde-");
filename.append("/krootbacking.png");
remove(filename.ascii());
system("krootbacking &");
TQTimer::singleShot( 0, this, SLOT(slotPaintBackground()) );
}
if (trinity_desktop_lock_delay_screensaver_start) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
}
else {
startHack();
}
return true; return true;
} }
@ -926,8 +999,9 @@ bool LockProcess::startSaver()
void LockProcess::stopSaver() void LockProcess::stopSaver()
{ {
kdDebug(1204) << "LockProcess: stopping saver" << endl; kdDebug(1204) << "LockProcess: stopping saver" << endl;
resume( true ); mHackProc.kill(SIGCONT);
stopHack(); stopHack();
mSuspended = false;
hideSaverWindow(); hideSaverWindow();
mVisibility = false; mVisibility = false;
if (!child_saver) { if (!child_saver) {
@ -1048,12 +1122,27 @@ bool LockProcess::startHack()
if (!mForbidden) if (!mForbidden)
{ {
if (trinity_desktop_lock_delay_screensaver_start) {
// Make sure we have a nice clean display to start with!
setBackgroundColor(black);
erase();
mSuspended = false;
}
if (mHackProc.start() == true) if (mHackProc.start() == true)
{ {
#ifdef HAVE_SETPRIORITY #ifdef HAVE_SETPRIORITY
setpriority(PRIO_PROCESS, mHackProc.pid(), mPriority); setpriority(PRIO_PROCESS, mHackProc.pid(), mPriority);
#endif #endif
//bitBlt(this, 0, 0, &mOriginal); //bitBlt(this, 0, 0, &mOriginal);
DISABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (trinity_desktop_lock_delay_screensaver_start) {
// Close any active dialogs
if (currentDialog != NULL) {
mForceReject = true;
currentDialog->close();
}
}
return true; return true;
} }
} }
@ -1061,7 +1150,12 @@ bool LockProcess::startHack()
// we aren't allowed to start the specified screensaver either because it didn't run for some reason // we aren't allowed to start the specified screensaver either because it didn't run for some reason
// according to the kiosk restrictions forbid it // according to the kiosk restrictions forbid it
{ {
setBackgroundColor(black); usleep(100);
TQApplication::syncX();
if (!trinity_desktop_lock_use_system_modal_dialogs) setBackgroundColor(black);
if (backingPixmap.isNull()) erase();
else bitBlt(this, 0, 0, &backingPixmap);
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
} }
} }
return false; return false;
@ -1087,7 +1181,28 @@ void LockProcess::hackExited(KProcess *)
{ {
// Hack exited while we're supposed to be saving the screen. // Hack exited while we're supposed to be saving the screen.
// Make sure the saver window is black. // Make sure the saver window is black.
setBackgroundColor(black); usleep(100);
TQApplication::syncX();
if (!trinity_desktop_lock_use_system_modal_dialogs) setBackgroundColor(black);
if (backingPixmap.isNull()) erase();
else bitBlt(this, 0, 0, &backingPixmap);
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
}
void LockProcess::displayLockDialogIfNeeded()
{
if (trinity_desktop_lock_use_system_modal_dialogs) {
if (!mBusy) {
mBusy = true;
if (mLocked) {
if (checkPass()) {
stopSaver();
kapp->quit();
}
}
mBusy = false;
}
}
} }
void LockProcess::suspend() void LockProcess::suspend()
@ -1096,6 +1211,8 @@ void LockProcess::suspend()
{ {
mHackProc.kill(SIGSTOP); mHackProc.kill(SIGSTOP);
TQApplication::syncX(); TQApplication::syncX();
usleep(100); // Let the stop signal get through
TQApplication::syncX();
mSavedScreen = TQPixmap::grabWindow( winId()); mSavedScreen = TQPixmap::grabWindow( winId());
} }
mSuspended = true; mSuspended = true;
@ -1105,7 +1222,7 @@ void LockProcess::resume( bool force )
{ {
if( !force && (!mDialogs.isEmpty() || !mVisibility )) if( !force && (!mDialogs.isEmpty() || !mVisibility ))
return; // no resuming with dialog visible or when not visible return; // no resuming with dialog visible or when not visible
if(mSuspended) if ((mSuspended) && (mHackProc.isRunning()))
{ {
XForceScreenSaver(qt_xdisplay(), ScreenSaverReset ); XForceScreenSaver(qt_xdisplay(), ScreenSaverReset );
bitBlt( this, 0, 0, &mSavedScreen ); bitBlt( this, 0, 0, &mSavedScreen );
@ -1169,6 +1286,11 @@ static void fakeFocusIn( WId window )
XSendEvent( qt_xdisplay(), window, False, NoEventMask, &ev ); XSendEvent( qt_xdisplay(), window, False, NoEventMask, &ev );
} }
void LockProcess::resumeUnforced()
{
resume( false );
}
int LockProcess::execDialog( TQDialog *dlg ) int LockProcess::execDialog( TQDialog *dlg )
{ {
currentDialog=dlg; currentDialog=dlg;
@ -1186,6 +1308,8 @@ 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();
else bitBlt(this, 0, 0, &backingPixmap);
int rt = dlg->exec(); int rt = dlg->exec();
while (mDialogControlLock == true) sleep(1); while (mDialogControlLock == true) sleep(1);
currentDialog = NULL; currentDialog = NULL;
@ -1193,12 +1317,63 @@ int LockProcess::execDialog( TQDialog *dlg )
if( mDialogs.isEmpty() ) { if( mDialogs.isEmpty() ) {
XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS, XChangeActivePointerGrab( qt_xdisplay(), GRABEVENTS,
TQCursor(tqblankCursor).handle(), CurrentTime); TQCursor(tqblankCursor).handle(), CurrentTime);
resume( false ); if (trinity_desktop_lock_use_system_modal_dialogs) {
// Slight delay before screensaver resume to allow the dialog window to fully disappear
if (hackResumeTimer == NULL) {
hackResumeTimer = new TQTimer( this );
connect( hackResumeTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(resumeUnforced()) );
}
hackResumeTimer->start( 10, TRUE );
}
else {
resume( false );
}
} else } else
fakeFocusIn( mDialogs.first()->winId()); fakeFocusIn( mDialogs.first()->winId());
return rt; return rt;
} }
void LockProcess::slotPaintBackground()
{
TQPixmap pm;
TQString filename = getenv("USER");
filename.prepend("/tmp/kde-");
filename.append("/krootbacking.png");
bool success = pm.load(filename, "PNG");
if (!success) {
sleep(1);
success = pm.load(filename, "PNG");
if (!success) {
pm = TQPixmap(kapp->desktop()->width(), kapp->desktop()->height());
pm.fill(Qt::black);
}
}
if (TQPaintDevice::x11AppDepth() == 32) {
// Remove the alpha components from the image
TQImage correctedImage = pm.convertToImage();
correctedImage = correctedImage.convertDepth(32);
correctedImage.setAlphaBuffer(true);
int w = correctedImage.width();
int h = correctedImage.height();
for (int y = 0; y < h; ++y) {
TQRgb *ls = (TQRgb *)correctedImage.scanLine( y );
for (int x = 0; x < w; ++x) {
TQRgb l = ls[x];
int r = int( tqRed( l ) );
int g = int( tqGreen( l ) );
int b = int( tqBlue( l ) );
int a = int( 255 );
ls[x] = tqRgba( r, g, b, a );
}
}
pm.convertFromImage(correctedImage);
}
backingPixmap = pm;
if (trinity_desktop_lock_delay_screensaver_start) erase();
}
void LockProcess::preparePopup() void LockProcess::preparePopup()
{ {
TQWidget *dlg = (TQWidget *)sender(); TQWidget *dlg = (TQWidget *)sender();
@ -1266,6 +1441,8 @@ bool LockProcess::x11Event(XEvent *event)
return true; // filter out return true; // filter out
// fall through // fall through
case KeyPress: case KeyPress:
if ((mHackDelayStartupTimer) && ((trinity_desktop_lock_autohide_lockdlg == FALSE) && (mHackDelayStartupTimer->isActive())))
mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
if (mBusy || !mDialogs.isEmpty()) if (mBusy || !mDialogs.isEmpty())
break; break;
mBusy = true; mBusy = true;

@ -68,6 +68,7 @@ public slots:
void desktopResized(); void desktopResized();
void doDesktopResizeFinish(); void doDesktopResizeFinish();
void doFunctionKeyBroadcast(); void doFunctionKeyBroadcast();
void slotPaintBackground();
protected: protected:
virtual bool x11Event(XEvent *); virtual bool x11Event(XEvent *);
@ -81,6 +82,9 @@ private slots:
void checkDPMSActive(); void checkDPMSActive();
void slotDeadTimePassed(); void slotDeadTimePassed();
void windowAdded( WId ); void windowAdded( WId );
void resumeUnforced();
void displayLockDialogIfNeeded();
bool startHack();
private: private:
void configure(); void configure();
@ -97,7 +101,6 @@ private:
void cantLock(const TQString &reason); void cantLock(const TQString &reason);
bool startSaver(); bool startSaver();
void stopSaver(); void stopSaver();
bool startHack();
void stopHack(); void stopHack();
void setupSignals(); void setupSignals();
void setupPipe(); void setupPipe();
@ -146,6 +149,8 @@ private:
TQTimer *resizeTimer; TQTimer *resizeTimer;
unsigned int mkeyCode; unsigned int mkeyCode;
TQTimer *hackResumeTimer;
KProcess* mVkbdProcess; KProcess* mVkbdProcess;
KWinModule* mKWinModule; KWinModule* mKWinModule;
struct VkbdWindow struct VkbdWindow
@ -162,9 +167,16 @@ private:
int mPipe_fd_out; int mPipe_fd_out;
bool mInfoMessageDisplayed; bool mInfoMessageDisplayed;
TQDialog *currentDialog;
bool mDialogControlLock; bool mDialogControlLock;
bool mForceReject; bool mForceReject;
TQDialog *currentDialog;
TQTimer* mForceContinualLockDisplayTimer;
TQTimer* mHackDelayStartupTimer;
int mHackDelayStartupTimeout;
TQPixmap backingPixmap;
}; };
#endif #endif

@ -34,6 +34,10 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <fixx11h.h> #include <fixx11h.h>
// [FIXME] These settings should be user configurable!
bool trinity_desktop_lock_use_system_modal_dialogs = FALSE;
bool trinity_desktop_lock_delay_screensaver_start = 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)

@ -48,22 +48,36 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/Xatom.h>
#include <fixx11h.h> #include <fixx11h.h>
#ifndef AF_LOCAL #ifndef AF_LOCAL
# define AF_LOCAL AF_UNIX # define AF_LOCAL AF_UNIX
#endif #endif
extern bool trinity_desktop_lock_use_system_modal_dialogs;
//=========================================================================== //===========================================================================
// //
// Simple dialog for displaying a password/PIN entry dialog // Simple dialog for displaying a password/PIN entry dialog
// //
QueryDlg::QueryDlg(LockProcess *parent) QueryDlg::QueryDlg(LockProcess *parent)
: TQDialog(parent, "query dialog", true, (WFlags)WX11BypassWM), : TQDialog(parent, "query dialog", true, (trinity_desktop_lock_use_system_modal_dialogs?((WFlags)WStyle_StaysOnTop):((WFlags)WX11BypassWM))),
mUnlockingFailed(false) mUnlockingFailed(false)
{ {
if (trinity_desktop_lock_use_system_modal_dialogs) {
// Signal that we do not want any window controls to be shown at all
Atom kde_wm_system_modal_notification;
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("Information Needed"));
frame = new TQFrame( this ); frame = new TQFrame( this );
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); if (trinity_desktop_lock_use_system_modal_dialogs)
frame->setFrameStyle( TQFrame::NoFrame );
else
frame->setFrameStyle( TQFrame::Panel | TQFrame::Raised );
frame->setLineWidth( 2 ); frame->setLineWidth( 2 );
mpixLabel = new TQLabel( frame, "pixlabel" ); mpixLabel = new TQLabel( frame, "pixlabel" );

@ -520,6 +520,10 @@ KSMShutdownIPFeedback::KSMShutdownIPFeedback()
{ {
// Try to get the root pixmap // Try to get the root pixmap
TQString filename = getenv("USER");
filename.prepend("/tmp/kde-");
filename.append("/krootbacking.png");
remove(filename.ascii());
system("krootbacking &"); system("krootbacking &");
resize(0, 0); resize(0, 0);

@ -1991,6 +1991,8 @@ void Client::takeFocus( allowed_t )
*/ */
bool Client::providesContextHelp() const bool Client::providesContextHelp() const
{ {
if (isModalSystemNotification())
return false;
return Pcontexthelp; return Pcontexthelp;
} }

@ -1688,6 +1688,8 @@ bool Client::isResizable() const
*/ */
bool Client::isMaximizable() const bool Client::isMaximizable() const
{ {
if( isModalSystemNotification())
return false;
{ // isMovable() and isResizable() may be false for maximized windows { // isMovable() and isResizable() may be false for maximized windows
// with moving/resizing maximized windows disabled // with moving/resizing maximized windows disabled
TemporaryAssign< MaximizeMode > tmp( max_mode, MaximizeRestore ); TemporaryAssign< MaximizeMode > tmp( max_mode, MaximizeRestore );

Loading…
Cancel
Save