Fix the most egregious style guide violations in the main kdesktop_lock source files

No functional changes were made to the source
pull/2/head
Timothy Pearson 10 years ago
parent c54c4e7003
commit b5462e86f3

@ -1,10 +1,10 @@
//=========================================================================== //===========================================================================
// //
// 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) 2003 Oswald Buddenhagen <ossi@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
// Copyright (c) 2010-2013 Timothy Pearson <kb9vqf@pearsoncomputing.net> // Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
// //
//kdesktop keeps running and checks user inactivity //kdesktop keeps running and checks user inactivity
@ -270,8 +270,7 @@ LockProcess::LockProcess()
// Add KDE specific screensaver path // Add KDE specific screensaver path
TQString relPath="System/ScreenSavers/"; TQString relPath="System/ScreenSavers/";
KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers"); KServiceGroup::Ptr servGroup = KServiceGroup::baseGroup( "screensavers");
if (servGroup) if (servGroup) {
{
relPath=servGroup->relPath(); relPath=servGroup->relPath();
kdDebug(1204) << "relPath=" << relPath << endl; kdDebug(1204) << "relPath=" << relPath << endl;
} }
@ -283,12 +282,13 @@ LockProcess::LockProcess()
gXA_VROOT = XInternAtom (tqt_xdisplay(), "__SWM_VROOT", False); gXA_VROOT = XInternAtom (tqt_xdisplay(), "__SWM_VROOT", False);
gXA_SCREENSAVER_VERSION = XInternAtom (tqt_xdisplay(), "_SCREENSAVER_VERSION", False); gXA_SCREENSAVER_VERSION = XInternAtom (tqt_xdisplay(), "_SCREENSAVER_VERSION", False);
TQStringList dmopt = TQStringList dmopt = TQStringList::split(TQChar(','),
TQStringList::split(TQChar(','),
TQString::fromLatin1( ::getenv( "XDM_MANAGED" ))); TQString::fromLatin1( ::getenv( "XDM_MANAGED" )));
for (TQStringList::ConstIterator it = dmopt.begin(); it != dmopt.end(); ++it) for (TQStringList::ConstIterator it = dmopt.begin(); it != dmopt.end(); ++it) {
if ((*it).startsWith("method=")) if ((*it).startsWith("method=")) {
mMethod = (*it).mid(7); mMethod = (*it).mid(7);
}
}
#ifdef KEEP_MOUSE_UNGRABBED #ifdef KEEP_MOUSE_UNGRABBED
setEnabled(false); setEnabled(false);
@ -467,8 +467,7 @@ bool LockProcess::closeCurrentWindow()
void LockProcess::timerEvent(TQTimerEvent *ev) void LockProcess::timerEvent(TQTimerEvent *ev)
{ {
if (mAutoLogout && ev->timerId() == mAutoLogoutTimerId) if (mAutoLogout && ev->timerId() == mAutoLogoutTimerId) {
{
killTimer(mAutoLogoutTimerId); killTimer(mAutoLogoutTimerId);
AutoLogout autologout(this); AutoLogout autologout(this);
execDialog(&autologout); execDialog(&autologout);
@ -554,8 +553,7 @@ bool LockProcess::lock()
// the screensaver kicks in because the user moved the mouse after // the screensaver kicks in because the user moved the mouse after
// selecting "lock screen", that looks really untidy. // selecting "lock screen", that looks really untidy.
mBusy = true; mBusy = true;
if (startLock()) if (startLock()) {
{
TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed()));
return true; return true;
} }
@ -576,8 +574,9 @@ bool LockProcess::defaultSave()
mLocked = false; mLocked = false;
mOverrideHackStartupEnabled = true; mOverrideHackStartupEnabled = true;
if (startSaver()) { if (startSaver()) {
if (mLockGrace >= 0) if (mLockGrace >= 0) {
TQTimer::singleShot(mLockGrace, this, TQT_SLOT(startLock())); TQTimer::singleShot(mLockGrace, this, TQT_SLOT(startLock()));
}
return true; return true;
} }
return false; return false;
@ -725,8 +724,7 @@ bool LockProcess::inSecureDialog()
void LockProcess::configure() void LockProcess::configure()
{ {
// the configuration is stored in kdesktop's config file // the configuration is stored in kdesktop's config file
if( KDesktopSettings::lock() ) if( KDesktopSettings::lock() ) {
{
mLockGrace = KDesktopSettings::lockGrace(); mLockGrace = KDesktopSettings::lockGrace();
if (mLockGrace < 0) if (mLockGrace < 0)
mLockGrace = 0; mLockGrace = 0;
@ -736,8 +734,7 @@ void LockProcess::configure()
else else
mLockGrace = -1; mLockGrace = -1;
if ( KDesktopSettings::autoLogout() ) if ( KDesktopSettings::autoLogout() ) {
{
mAutoLogout = true; mAutoLogout = true;
mAutoLogoutTimeout = KDesktopSettings::autoLogoutTimeout(); mAutoLogoutTimeout = KDesktopSettings::autoLogoutTimeout();
mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout * 1000); // in milliseconds mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout * 1000); // in milliseconds
@ -773,31 +770,25 @@ void LockProcess::configure()
// //
void LockProcess::readSaver() void LockProcess::readSaver()
{ {
if (!mSaver.isEmpty()) if (!mSaver.isEmpty()) {
{
TQString file = locate("scrsav", mSaver); TQString file = locate("scrsav", mSaver);
bool opengl = kapp->authorize("opengl_screensavers"); bool opengl = kapp->authorize("opengl_screensavers");
bool manipulatescreen = kapp->authorize("manipulatescreen_screensavers"); bool manipulatescreen = kapp->authorize("manipulatescreen_screensavers");
KDesktopFile config(file, true); KDesktopFile config(file, true);
if (config.readEntry("X-TDE-Type").utf8() != 0) if (config.readEntry("X-TDE-Type").utf8() != 0) {
{
TQString saverType = config.readEntry("X-TDE-Type").utf8(); TQString saverType = config.readEntry("X-TDE-Type").utf8();
TQStringList saverTypes = TQStringList::split(";", saverType); TQStringList saverTypes = TQStringList::split(";", saverType);
for (uint i = 0; i < saverTypes.count(); i++) for (uint i = 0; i < saverTypes.count(); i++) {
{ if ((saverTypes[i] == "ManipulateScreen") && !manipulatescreen) {
if ((saverTypes[i] == "ManipulateScreen") && !manipulatescreen)
{
kdDebug(1204) << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden" << endl; kdDebug(1204) << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden" << endl;
mForbidden = true; mForbidden = true;
} }
if ((saverTypes[i] == "OpenGL") && !opengl) if ((saverTypes[i] == "OpenGL") && !opengl) {
{
kdDebug(1204) << "Screensaver is type OpenGL and OpenGL is forbidden" << endl; kdDebug(1204) << "Screensaver is type OpenGL and OpenGL is forbidden" << endl;
mForbidden = true; mForbidden = true;
} }
if (saverTypes[i] == "OpenGL") if (saverTypes[i] == "OpenGL") {
{
mOpenGLVisual = true; mOpenGLVisual = true;
} }
} }
@ -806,15 +797,13 @@ void LockProcess::readSaver()
kdDebug(1204) << "mForbidden: " << (mForbidden ? "true" : "false") << endl; kdDebug(1204) << "mForbidden: " << (mForbidden ? "true" : "false") << endl;
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
if (config.hasActionGroup("InWindow")) if (config.hasActionGroup("InWindow")) {
{
config.setActionGroup("InWindow"); config.setActionGroup("InWindow");
mSaverExec = config.readPathEntry("Exec"); mSaverExec = config.readPathEntry("Exec");
} }
} }
else { else {
if (config.hasActionGroup("Root")) if (config.hasActionGroup("Root")) {
{
config.setActionGroup("Root"); config.setActionGroup("Root");
mSaverExec = config.readPathEntry("Exec"); mSaverExec = config.readPathEntry("Exec");
} }
@ -833,10 +822,8 @@ void LockProcess::createSaverWindow()
XVisualInfo* info = NULL; XVisualInfo* info = NULL;
int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect; int flags = trinity_desktop_lock_use_system_modal_dialogs?0:CWOverrideRedirect;
#ifdef HAVE_GLXCHOOSEVISUAL #ifdef HAVE_GLXCHOOSEVISUAL
if( mOpenGLVisual ) if( mOpenGLVisual ) {
{ static int attribs[][ 15 ] = {
static int attribs[][ 15 ] =
{
#define R GLX_RED_SIZE #define R GLX_RED_SIZE
#define G GLX_GREEN_SIZE #define G GLX_GREEN_SIZE
#define B GLX_BLUE_SIZE #define B GLX_BLUE_SIZE
@ -887,8 +874,7 @@ void LockProcess::createSaverWindow()
break; break;
} }
} }
if ( !info ) if ( !info ) {
{
printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n"); printf("[WARNING] Unable to locate matching X11 GLX Visual; this OpenGL application may not function correctly!\n");
} }
} }
@ -1131,11 +1117,8 @@ void LockProcess::saveVRoot()
int (*oldHandler)(Display *, XErrorEvent *); int (*oldHandler)(Display *, XErrorEvent *);
oldHandler = XSetErrorHandler(ignoreXError); oldHandler = XSetErrorHandler(ignoreXError);
if (XQueryTree(tqt_xdisplay(), root, &rootReturn, &parentReturn, if (XQueryTree(tqt_xdisplay(), root, &rootReturn, &parentReturn, &children, &numChildren)) {
&children, &numChildren)) for (unsigned int i = 0; i < numChildren; i++) {
{
for (unsigned int i = 0; i < numChildren; i++)
{
Atom actual_type; Atom actual_type;
int actual_format; int actual_format;
unsigned long nitems, bytesafter; unsigned long nitems, bytesafter;
@ -1143,8 +1126,7 @@ void LockProcess::saveVRoot()
if ((XGetWindowProperty(tqt_xdisplay(), children[i], gXA_VROOT, 0, 1, if ((XGetWindowProperty(tqt_xdisplay(), children[i], gXA_VROOT, 0, 1,
False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter, False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter,
&newRoot) == Success) && newRoot) &newRoot) == Success) && newRoot) {
{
gVRoot = children[i]; gVRoot = children[i];
Window *dummy = (Window*)newRoot; Window *dummy = (Window*)newRoot;
gVRootData = *dummy; gVRootData = *dummy;
@ -1152,8 +1134,7 @@ void LockProcess::saveVRoot()
break; break;
} }
} }
if (children) if (children) {
{
XFree((char *)children); XFree((char *)children);
} }
} }
@ -1250,21 +1231,17 @@ bool LockProcess::grabInput()
{ {
XSync(tqt_xdisplay(), False); XSync(tqt_xdisplay(), False);
if (!grabKeyboard()) if (!grabKeyboard()) {
{
usleep(100000); usleep(100000);
if (!grabKeyboard()) if (!grabKeyboard()) {
{
return false; return false;
} }
} }
#ifndef KEEP_MOUSE_UNGRABBED #ifndef KEEP_MOUSE_UNGRABBED
if (!grabMouse()) if (!grabMouse()) {
{
usleep(100000); usleep(100000);
if (!grabMouse()) if (!grabMouse()) {
{
XUngrabKeyboard(tqt_xdisplay(), CurrentTime); XUngrabKeyboard(tqt_xdisplay(), CurrentTime);
return false; return false;
} }
@ -1423,15 +1400,17 @@ void LockProcess::stopSaver()
hideSaverWindow(); hideSaverWindow();
mVisibility = false; mVisibility = false;
if (!child_saver) { if (!child_saver) {
if (mLocked) if (mLocked) {
DM().setLock( false ); DM().setLock( false );
}
ungrabInput(); ungrabInput();
const char *out = "GOAWAY!"; const char *out = "GOAWAY!";
for (TQValueList<int>::ConstIterator it = child_sockets.begin(); it != child_sockets.end(); ++it) for (TQValueList<int>::ConstIterator it = child_sockets.begin(); it != child_sockets.end(); ++it) {
if (write(*it, out, sizeof(out)) == -1) { if (write(*it, out, sizeof(out)) == -1) {
// Error handler to shut up gcc warnings // Error handler to shut up gcc warnings
} }
} }
}
} }
// private static // private static
@ -1439,10 +1418,11 @@ TQVariant LockProcess::getConf(void *ctx, const char *key, const TQVariant &dflt
{ {
LockProcess *that = (LockProcess *)ctx; LockProcess *that = (LockProcess *)ctx;
TQString fkey = TQString::fromLatin1( key ) + '='; TQString fkey = TQString::fromLatin1( key ) + '=';
for (TQStringList::ConstIterator it = that->mPluginOptions.begin(); for (TQStringList::ConstIterator it = that->mPluginOptions.begin(); it != that->mPluginOptions.end(); ++it) {
it != that->mPluginOptions.end(); ++it) if ((*it).startsWith( fkey )) {
if ((*it).startsWith( fkey ))
return (*it).mid( fkey.length() ); return (*it).mid( fkey.length() );
}
}
return dflt; return dflt;
} }
@ -1464,8 +1444,7 @@ bool LockProcess::startLock()
{ {
for (TQStringList::ConstIterator it = mPlugins.begin(); it != mPlugins.end(); ++it) { for (TQStringList::ConstIterator it = mPlugins.begin(); it != mPlugins.end(); ++it) {
GreeterPluginHandle plugin; GreeterPluginHandle plugin;
TQString path = KLibLoader::self()->findLibrary( TQString path = KLibLoader::self()->findLibrary( ((*it)[0] == '/' ? *it : "kgreet_" + *it ).latin1() );
((*it)[0] == '/' ? *it : "kgreet_" + *it ).latin1() );
if (path.isEmpty()) { if (path.isEmpty()) {
kdWarning(1204) << "GreeterPlugin " << *it << " does not exist" << endl; kdWarning(1204) << "GreeterPlugin " << *it << " does not exist" << endl;
continue; continue;
@ -1565,10 +1544,11 @@ bool LockProcess::startHack()
{ {
mHackActive = TRUE; mHackActive = TRUE;
if ((mEnsureVRootWindowSecurityTimer) && (!mEnsureVRootWindowSecurityTimer->isActive())) mEnsureVRootWindowSecurityTimer->start(250, FALSE); if ((mEnsureVRootWindowSecurityTimer) && (!mEnsureVRootWindowSecurityTimer->isActive())) {
mEnsureVRootWindowSecurityTimer->start(250, FALSE);
}
if (currentDialog || (!mDialogs.isEmpty())) if (currentDialog || (!mDialogs.isEmpty())) {
{
// no resuming with dialog visible or when not visible // no resuming with dialog visible or when not visible
if (argb_visual) { if (argb_visual) {
setTransparentBackgroundARGB(); setTransparentBackgroundARGB();
@ -1590,13 +1570,11 @@ bool LockProcess::startHack()
setCursor( tqblankCursor ); setCursor( tqblankCursor );
XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime); XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime);
if (mSaverExec.isEmpty()) if (mSaverExec.isEmpty()) {
{
return false; return false;
} }
if (mHackProc.isRunning()) if (mHackProc.isRunning()) {
{
stopHack(); stopHack();
} }
@ -1607,14 +1585,12 @@ bool LockProcess::startHack()
ts >> word; ts >> word;
TQString path = TDEStandardDirs::findExe(word); TQString path = TDEStandardDirs::findExe(word);
if (!path.isEmpty()) if (!path.isEmpty()) {
{
mHackProc << path; mHackProc << path;
kdDebug(1204) << "Starting hack: " << path << endl; kdDebug(1204) << "Starting hack: " << path << endl;
while (!ts.atEnd()) while (!ts.atEnd()) {
{
ts >> word; ts >> word;
if (word == "%w") if (word == "%w")
{ {
@ -1623,8 +1599,7 @@ bool LockProcess::startHack()
mHackProc << word; mHackProc << word;
} }
if (!mForbidden) if (!mForbidden) {
{
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
// Make sure we have a nice clean display to start with! // Make sure we have a nice clean display to start with!
if (argb_visual) { if (argb_visual) {
@ -1650,8 +1625,7 @@ bool LockProcess::startHack()
} }
XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime); XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqblankCursor).handle(), CurrentTime);
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
@ -1667,10 +1641,9 @@ bool LockProcess::startHack()
return true; return true;
} }
} }
else else {
// 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
{
usleep(100); usleep(100);
TQApplication::syncX(); TQApplication::syncX();
if (!trinity_desktop_lock_use_system_modal_dialogs) { if (!trinity_desktop_lock_use_system_modal_dialogs) {
@ -1706,7 +1679,12 @@ bool LockProcess::startHack()
saverReadyIfNeeded(); saverReadyIfNeeded();
} }
} }
if (m_startupStatusDialog) { m_startupStatusDialog->closeSMDialog(); m_startupStatusDialog=NULL; }
if (m_startupStatusDialog) {
m_startupStatusDialog->closeSMDialog();
m_startupStatusDialog=NULL;
}
return false; return false;
} }
@ -1714,11 +1692,9 @@ bool LockProcess::startHack()
// //
void LockProcess::stopHack() void LockProcess::stopHack()
{ {
if (mHackProc.isRunning()) if (mHackProc.isRunning()) {
{
mHackProc.kill(); mHackProc.kill();
if (!mHackProc.wait(10)) if (!mHackProc.wait(10)) {
{
mHackProc.kill(SIGKILL); mHackProc.kill(SIGKILL);
} }
} }
@ -1799,13 +1775,14 @@ void LockProcess::displayLockDialogIfNeeded()
void LockProcess::suspend() void LockProcess::suspend()
{ {
if(!mSuspended) if (!mSuspended) {
{
if (trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_use_system_modal_dialogs) {
mSuspended = true; mSuspended = true;
stopHack(); stopHack();
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); if (mHackStartupEnabled) {
mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
}
} }
else { else {
TQString hackStatus; TQString hackStatus;
@ -1863,8 +1840,7 @@ void LockProcess::resume( bool force )
saverReadyIfNeeded(); saverReadyIfNeeded();
return; return;
} }
if ((mSuspended) && (mHackProc.isRunning())) if ((mSuspended) && (mHackProc.isRunning())) {
{
XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset ); XForceScreenSaver(tqt_xdisplay(), ScreenSaverReset );
bitBlt( this, 0, 0, &mSavedScreen ); bitBlt( this, 0, 0, &mSavedScreen );
TQApplication::syncX(); TQApplication::syncX();
@ -1933,8 +1909,7 @@ bool LockProcess::checkPass()
XWindowAttributes rootAttr; XWindowAttributes rootAttr;
XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(),
tqt_xscreen()), &rootAttr); tqt_xscreen()), &rootAttr);
if(( rootAttr.your_event_mask & SubstructureNotifyMask ) == 0 ) if(( rootAttr.your_event_mask & SubstructureNotifyMask ) == 0 ) {
{
kdWarning() << "ERROR: Something removed SubstructureNotifyMask from the root window!!!" << endl; kdWarning() << "ERROR: Something removed SubstructureNotifyMask from the root window!!!" << endl;
XSelectInput( tqt_xdisplay(), tqt_xrootwin(), XSelectInput( tqt_xdisplay(), tqt_xrootwin(),
SubstructureNotifyMask | rootAttr.your_event_mask ); SubstructureNotifyMask | rootAttr.your_event_mask );
@ -1977,8 +1952,7 @@ int LockProcess::execDialog( TQDialog *dlg )
rect.moveCenter(TDEGlobalSettings::desktopGeometry(TQCursor::pos()).center()); rect.moveCenter(TDEGlobalSettings::desktopGeometry(TQCursor::pos()).center());
dlg->move( rect.topLeft() ); dlg->move( rect.topLeft() );
if (mDialogs.isEmpty()) if (mDialogs.isEmpty()) {
{
suspend(); suspend();
XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime); XChangeActivePointerGrab( tqt_xdisplay(), GRABEVENTS, TQCursor(tqarrowCursor).handle(), CurrentTime);
} }
@ -1999,7 +1973,9 @@ int LockProcess::execDialog( TQDialog *dlg )
oldHandler = XSetErrorHandler(ignoreXError); oldHandler = XSetErrorHandler(ignoreXError);
int rt = dlg->exec(); int rt = dlg->exec();
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
while (mDialogControlLock == true) usleep(100000); while (mDialogControlLock == true) {
usleep(100000);
}
currentDialog = NULL; currentDialog = NULL;
mDialogs.remove( dlg ); mDialogs.remove( dlg );
if( mDialogs.isEmpty() ) { if( mDialogs.isEmpty() ) {
@ -2024,7 +2000,8 @@ int LockProcess::execDialog( TQDialog *dlg )
else { else {
resume( false ); resume( false );
} }
} else { }
else {
fakeFocusIn( mDialogs.first()->winId()); fakeFocusIn( mDialogs.first()->winId());
currentDialog = dynamic_cast<TQDialog*>(mDialogs.first()); currentDialog = dynamic_cast<TQDialog*>(mDialogs.first());
} }
@ -2117,7 +2094,9 @@ void LockProcess::doFunctionKeyBroadcast() {
mBusy=true; mBusy=true;
TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed())); TQTimer::singleShot(1000, this, TQT_SLOT(slotDeadTimePassed()));
if (mkeyCode == XKeysymToKeycode(tqt_xdisplay(), XF86XK_Display)) { if (mkeyCode == XKeysymToKeycode(tqt_xdisplay(), XF86XK_Display)) {
while (mDialogControlLock == true) usleep(100000); 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;
@ -2172,41 +2151,43 @@ bool LockProcess::x11Event(XEvent *event)
case ButtonPress: case ButtonPress:
case MotionNotify: case MotionNotify:
case ButtonRelease: case ButtonRelease:
if( forwardVkbdEvent( event )) if( forwardVkbdEvent( event )) {
return true; // filter out return true; // filter out
}
// fall through // fall through
case KeyPress: case KeyPress:
if ((mHackDelayStartupTimer) && (mHackDelayStartupTimer->isActive())) { if ((mHackDelayStartupTimer) && (mHackDelayStartupTimer->isActive())) {
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
} }
if (mBusy || !mDialogs.isEmpty()) if (mBusy || !mDialogs.isEmpty()) {
break; break;
}
mBusy = true; mBusy = true;
if (trinity_desktop_lock_delay_screensaver_start) { if (trinity_desktop_lock_delay_screensaver_start) {
if (mLocked) { if (mLocked) {
ENABLE_CONTINUOUS_LOCKDLG_DISPLAY ENABLE_CONTINUOUS_LOCKDLG_DISPLAY
if (mHackStartupEnabled) mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE); if (mHackStartupEnabled) {
mHackDelayStartupTimer->start(mHackDelayStartupTimeout, TRUE);
} }
if ((!mLocked) && (!mInSecureDialog)) }
{ if ((!mLocked) && (!mInSecureDialog)) {
stopSaver(); stopSaver();
kapp->quit(); kapp->quit();
} }
if (mAutoLogout) // we need to restart the auto logout countdown if (mAutoLogout) {
{ // we need to restart the auto logout countdown
killTimer(mAutoLogoutTimerId); killTimer(mAutoLogoutTimerId);
mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout);
} }
} }
else { else {
if (!mLocked || checkPass()) if (!mLocked || checkPass()) {
{
mClosingWindows = true; mClosingWindows = true;
stopSaver(); stopSaver();
kapp->quit(); kapp->quit();
} }
else if (mAutoLogout) // we need to restart the auto logout countdown else if (mAutoLogout) {
{ // we need to restart the auto logout countdown
killTimer(mAutoLogoutTimerId); killTimer(mAutoLogoutTimerId);
mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout); mAutoLogoutTimerId = startTimer(mAutoLogoutTimeout);
} }
@ -2215,15 +2196,14 @@ bool LockProcess::x11Event(XEvent *event)
return true; return true;
case VisibilityNotify: case VisibilityNotify:
if( event->xvisibility.window == winId()) if( event->xvisibility.window == winId()) {
{ // mVisibility == false means the screensaver is not visible at all // mVisibility == false means the screensaver is not visible at all
// e.g. when switched to text console // e.g. when switched to text console
mVisibility = !(event->xvisibility.state == VisibilityFullyObscured); mVisibility = !(event->xvisibility.state == VisibilityFullyObscured);
if(!mVisibility) { if(!mVisibility) {
mSuspendTimer.start(2000, true); mSuspendTimer.start(2000, true);
} }
else else {
{
mSuspendTimer.stop(); mSuspendTimer.stop();
if (mResizingDesktopLock == false) { if (mResizingDesktopLock == false) {
if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) { if (trinity_desktop_lock_delay_screensaver_start && trinity_desktop_lock_forced && trinity_desktop_lock_use_system_modal_dialogs) {
@ -2267,17 +2247,17 @@ bool LockProcess::x11Event(XEvent *event)
break; break;
case MapNotify: // from SubstructureNotifyMask on the root window case MapNotify: // from SubstructureNotifyMask on the root window
windowAdded( event->xmap.window, false ); windowAdded( event->xmap.window, false );
if( event->xmap.event == tqt_xrootwin()) if( event->xmap.event == tqt_xrootwin()) {
stayOnTop(); stayOnTop();
}
break; break;
case DestroyNotify: case DestroyNotify:
for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); for( TQValueList< VkbdWindow >::Iterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it ) {
it != mVkbdWindows.end();
++it )
if( (*it).id == event->xdestroywindow.window ) { if( (*it).id == event->xdestroywindow.window ) {
mVkbdWindows.remove( it ); mVkbdWindows.remove( it );
break; break;
} }
}
break; break;
} }
@ -2290,8 +2270,7 @@ bool LockProcess::x11Event(XEvent *event)
// so let's simply dupe it with correct destination window, // so let's simply dupe it with correct destination window,
// and ignore the original one. // and ignore the original one.
if(!mDialogs.isEmpty() && ( event->type == KeyPress || event->type == KeyRelease) if(!mDialogs.isEmpty() && ( event->type == KeyPress || event->type == KeyRelease)
&& event->xkey.window != mDialogs.first()->winId()) && event->xkey.window != mDialogs.first()->winId()) {
{
XEvent ev2 = *event; XEvent ev2 = *event;
ev2.xkey.window = ev2.xkey.subwindow = mDialogs.first()->winId(); ev2.xkey.window = ev2.xkey.subwindow = mDialogs.first()->winId();
tqApp->x11ProcessEvent( &ev2 ); tqApp->x11ProcessEvent( &ev2 );
@ -2303,34 +2282,34 @@ bool LockProcess::x11Event(XEvent *event)
void LockProcess::stayOnTop() void LockProcess::stayOnTop()
{ {
if(!mDialogs.isEmpty() || !mVkbdWindows.isEmpty()) if(!mDialogs.isEmpty() || !mVkbdWindows.isEmpty()) {
{
// this restacking is written in a way so that // this restacking is written in a way so that
// if the stacking positions actually don't change, // if the stacking positions actually don't change,
// all restacking operations will be no-op, // all restacking operations will be no-op,
// and no ConfigureNotify will be generated, // and no ConfigureNotify will be generated,
// thus avoiding possible infinite loops // thus avoiding possible infinite loops
if( !mVkbdWindows.isEmpty()) if( !mVkbdWindows.isEmpty()) {
XRaiseWindow( tqt_xdisplay(), mVkbdWindows.first().id ); XRaiseWindow( tqt_xdisplay(), mVkbdWindows.first().id );
else }
else {
XRaiseWindow( tqt_xdisplay(), mDialogs.first()->winId()); // raise topmost XRaiseWindow( tqt_xdisplay(), mDialogs.first()->winId()); // raise topmost
}
// and stack others below it // and stack others below it
Window* stack = new Window[ mDialogs.count() + mVkbdWindows.count() + 1 ]; Window* stack = new Window[ mDialogs.count() + mVkbdWindows.count() + 1 ];
int count = 0; int count = 0;
for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it )
it != mVkbdWindows.end();
++it )
stack[ count++ ] = (*it).id; stack[ count++ ] = (*it).id;
for( TQValueList< TQWidget* >::ConstIterator it = mDialogs.begin(); }
it != mDialogs.end(); for( TQValueList< TQWidget* >::ConstIterator it = mDialogs.begin(); it != mDialogs.end(); ++it )
++it )
stack[ count++ ] = (*it)->winId(); stack[ count++ ] = (*it)->winId();
}
stack[ count++ ] = winId(); stack[ count++ ] = winId();
XRestackWindows( x11Display(), stack, count ); XRestackWindows( x11Display(), stack, count );
delete[] stack; delete[] stack;
} }
else else {
XRaiseWindow(tqt_xdisplay(), winId()); XRaiseWindow(tqt_xdisplay(), winId());
}
} }
void LockProcess::checkDPMSActive() void LockProcess::checkDPMSActive()
@ -2361,41 +2340,48 @@ void LockProcess::checkDPMSActive()
static enum { Unknown, Yes, No } can_do_xf86_lock = Unknown; static enum { Unknown, Yes, No } can_do_xf86_lock = Unknown;
void LockProcess::lockXF86() void LockProcess::lockXF86()
{ {
if( can_do_xf86_lock == Unknown ) if( can_do_xf86_lock == Unknown ) {
{
int major, minor; int major, minor;
if( XF86MiscQueryVersion( tqt_xdisplay(), &major, &minor ) if( XF86MiscQueryVersion( tqt_xdisplay(), &major, &minor ) && major >= 0 && minor >= 5 ) {
&& major >= 0 && minor >= 5 )
can_do_xf86_lock = Yes; can_do_xf86_lock = Yes;
else }
else {
can_do_xf86_lock = No; can_do_xf86_lock = No;
} }
if( can_do_xf86_lock != Yes ) }
if( can_do_xf86_lock != Yes ) {
return; return;
if( mRestoreXF86Lock ) }
if( mRestoreXF86Lock ) {
return; return;
if( XF86MiscSetGrabKeysState( tqt_xdisplay(), False ) != MiscExtGrabStateSuccess ) }
if( XF86MiscSetGrabKeysState( tqt_xdisplay(), False ) != MiscExtGrabStateSuccess ) {
return; return;
}
// success // success
mRestoreXF86Lock = true; mRestoreXF86Lock = true;
} }
void LockProcess::unlockXF86() void LockProcess::unlockXF86()
{ {
if( can_do_xf86_lock != Yes ) if( can_do_xf86_lock != Yes ) {
return; return;
if( !mRestoreXF86Lock ) }
if( !mRestoreXF86Lock ) {
return; return;
}
XF86MiscSetGrabKeysState( tqt_xdisplay(), True ); XF86MiscSetGrabKeysState( tqt_xdisplay(), True );
mRestoreXF86Lock = false; mRestoreXF86Lock = false;
} }
#else #else
void LockProcess::lockXF86() void LockProcess::lockXF86()
{ {
//
} }
void LockProcess::unlockXF86() void LockProcess::unlockXF86()
{ {
//
} }
#endif #endif
@ -2408,10 +2394,12 @@ void LockProcess::msgBox( TQMessageBox::Icon type, const TQString &txt )
} }
box.setCaption(i18n("Authentication Subsystem Notice")); box.setCaption(i18n("Authentication Subsystem Notice"));
TQFrame *winFrame = new TQFrame( &box ); TQFrame *winFrame = new TQFrame( &box );
if (trinity_desktop_lock_use_system_modal_dialogs) if (trinity_desktop_lock_use_system_modal_dialogs) {
winFrame->setFrameStyle( TQFrame::NoFrame ); winFrame->setFrameStyle( TQFrame::NoFrame );
else }
else {
winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised ); winFrame->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
}
winFrame->setLineWidth( 2 ); winFrame->setLineWidth( 2 );
TQLabel *label1 = new TQLabel( winFrame ); TQLabel *label1 = new TQLabel( winFrame );
label1->setPixmap( TQMessageBox::standardIcon( type ) ); label1->setPixmap( TQMessageBox::standardIcon( type ) );
@ -2438,8 +2426,7 @@ void LockProcess::showVkbd()
#ifdef WITH_HAL #ifdef WITH_HAL
int status = system( "hal-find-by-property --key system.formfactor.subtype --string tabletpc" ); int status = system( "hal-find-by-property --key system.formfactor.subtype --string tabletpc" );
// status = 0; // enable for testing // status = 0; // enable for testing
run_vkbd = ( WIFEXITED( status ) && WEXITSTATUS( status ) == 0 run_vkbd = ( WIFEXITED( status ) && WEXITSTATUS( status ) == 0 && !TDEStandardDirs::findExe( "xvkbd" ).isEmpty()) ? 1 : 0;
&& !TDEStandardDirs::findExe( "xvkbd" ).isEmpty()) ? 1 : 0;
#else // WITH_HAL #else // WITH_HAL
run_vkbd = (!TDEStandardDirs::findExe( "xvkbd" ).isEmpty()); run_vkbd = (!TDEStandardDirs::findExe( "xvkbd" ).isEmpty());
#endif // WITH_HAL #endif // WITH_HAL
@ -2480,8 +2467,9 @@ void LockProcess::windowAdded( WId w, bool managed )
KWin::WindowInfo info = KWin::windowInfo( w, 0, NET::WM2WindowClass ); KWin::WindowInfo info = KWin::windowInfo( w, 0, NET::WM2WindowClass );
XSetErrorHandler(oldHandler); XSetErrorHandler(oldHandler);
if( info.windowClassClass().lower() != "xvkbd" ) if( info.windowClassClass().lower() != "xvkbd" ) {
return; return;
}
// Unmanaged windows (i.e. popups) don't currently work anyway, since they // Unmanaged windows (i.e. popups) don't currently work anyway, since they
// don't have WM_CLASS set anyway. I could perhaps try tricks with X id // don't have WM_CLASS set anyway. I could perhaps try tricks with X id
// ranges if really needed. // ranges if really needed.
@ -2503,14 +2491,16 @@ void LockProcess::windowAdded( WId w, bool managed )
withdrawn = (*wstate == WithdrawnState ); withdrawn = (*wstate == WithdrawnState );
XFree( (char *)data ); XFree( (char *)data );
} }
if( withdrawn ) if( withdrawn ) {
break; break;
} }
} }
}
XSelectInput( tqt_xdisplay(), w, StructureNotifyMask ); XSelectInput( tqt_xdisplay(), w, StructureNotifyMask );
XWindowAttributes attr_geom; XWindowAttributes attr_geom;
if( !XGetWindowAttributes( tqt_xdisplay(), w, &attr_geom )) if( !XGetWindowAttributes( tqt_xdisplay(), w, &attr_geom )) {
return; return;
}
int x = XDisplayWidth( tqt_xdisplay(), tqt_xscreen()) - attr_geom.width; int x = XDisplayWidth( tqt_xdisplay(), tqt_xscreen()) - attr_geom.width;
int y = XDisplayHeight( tqt_xdisplay(), tqt_xscreen()) - attr_geom.height; int y = XDisplayHeight( tqt_xdisplay(), tqt_xscreen()) - attr_geom.height;
if( managed ) { if( managed ) {
@ -2530,8 +2520,9 @@ void LockProcess::windowAdded( WId w, bool managed )
bool LockProcess::forwardVkbdEvent( XEvent* event ) bool LockProcess::forwardVkbdEvent( XEvent* event )
{ {
if( mVkbdProcess == NULL ) if( mVkbdProcess == NULL ) {
return false; return false;
}
TQPoint pos; TQPoint pos;
Time time; Time time;
switch( event->type ) switch( event->type )
@ -2549,9 +2540,7 @@ bool LockProcess::forwardVkbdEvent( XEvent* event )
return false; return false;
} }
// vkbd windows are kept topmost, so just find the first one in the position // vkbd windows are kept topmost, so just find the first one in the position
for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); for( TQValueList< VkbdWindow >::ConstIterator it = mVkbdWindows.begin(); it != mVkbdWindows.end(); ++it ) {
it != mVkbdWindows.end();
++it ) {
if( TQT_TQRECT_OBJECT((*it).rect).contains( pos )) { if( TQT_TQRECT_OBJECT((*it).rect).contains( pos )) {
// Find the subwindow where the event should actually go. // Find the subwindow where the event should actually go.
// Not exactly cheap in the number of X roundtrips but oh well. // Not exactly cheap in the number of X roundtrips but oh well.
@ -2560,10 +2549,12 @@ bool LockProcess::forwardVkbdEvent( XEvent* event )
int root_x, root_y, x, y; int root_x, root_y, x, y;
unsigned int mask; unsigned int mask;
for(;;) { for(;;) {
if( !XQueryPointer( tqt_xdisplay(), window, &root, &child, &root_x, &root_y, &x, &y, &mask )) if( !XQueryPointer( tqt_xdisplay(), window, &root, &child, &root_x, &root_y, &x, &y, &mask )) {
return false; return false;
if( child == None ) }
if( child == None ) {
break; break;
}
window = child; window = child;
} }
switch( event->type ) switch( event->type )
@ -2595,8 +2586,9 @@ bool LockProcess::forwardVkbdEvent( XEvent* event )
// not needed otherwise it seems). // not needed otherwise it seems).
void LockProcess::sendVkbdFocusInOut( WId window, Time t ) void LockProcess::sendVkbdFocusInOut( WId window, Time t )
{ {
if( mVkbdLastEventWindow == window ) if( mVkbdLastEventWindow == window ) {
return; return;
}
if( mVkbdLastEventWindow != None ) { if( mVkbdLastEventWindow != None ) {
XEvent e; XEvent e;
e.xcrossing.type = LeaveNotify; e.xcrossing.type = LeaveNotify;

@ -1,10 +1,10 @@
//=========================================================================== //===========================================================================
// //
// 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) 2003 Oswald Buddenhagen <ossi@kde.org> // Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
// Copyright (c) 2010-2013 Timothy Pearson <kb9vqf@pearsoncomputing.net> // Copyright (c) 2010 - 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
// //
#ifndef __LOCKENG_H__ #ifndef __LOCKENG_H__
@ -75,11 +75,11 @@ class ControlPipeHandlerObject : public TQObject
// Screen saver handling process. Handles screensaver window, // Screen saver handling process. Handles screensaver window,
// starting screensaver hacks, and password entry. // starting screensaver hacks, and password entry.
// //
class LockProcess class LockProcess : public TQWidget
: public TQWidget
{ {
Q_OBJECT Q_OBJECT
public:
public:
LockProcess(); LockProcess();
~LockProcess(); ~LockProcess();
@ -100,10 +100,10 @@ public:
void msgBox( TQMessageBox::Icon type, const TQString &txt ); void msgBox( TQMessageBox::Icon type, const TQString &txt );
int execDialog( TQDialog* dlg ); int execDialog( TQDialog* dlg );
signals: signals:
void terminateHelperThread(); void terminateHelperThread();
public slots: public slots:
void quitSaver(); void quitSaver();
void preparePopup(); void preparePopup();
void cleanupPopup(); void cleanupPopup();
@ -113,12 +113,12 @@ public slots:
void slotPaintBackground(const TQPixmap &pm); void slotPaintBackground(const TQPixmap &pm);
void slotForcePaintBackground(); void slotForcePaintBackground();
protected: protected:
virtual bool x11Event(XEvent *); virtual bool x11Event(XEvent *);
virtual void timerEvent(TQTimerEvent *); virtual void timerEvent(TQTimerEvent *);
virtual void resizeEvent(TQResizeEvent *); virtual void resizeEvent(TQResizeEvent *);
private slots: private slots:
void hackExited(TDEProcess *); void hackExited(TDEProcess *);
void signalPipeSignal(); void signalPipeSignal();
bool startLock(); bool startLock();
@ -135,7 +135,7 @@ private slots:
void slotMouseActivity(XEvent *event); void slotMouseActivity(XEvent *event);
void processInputPipeCommand(TQString command); void processInputPipeCommand(TQString command);
private: private:
void configure(); void configure();
void readSaver(); void readSaver();
void createSaverWindow(); void createSaverWindow();
@ -207,8 +207,7 @@ private:
TDEProcess* mVkbdProcess; TDEProcess* mVkbdProcess;
KWinModule* mKWinModule; KWinModule* mKWinModule;
struct VkbdWindow struct VkbdWindow {
{
WId id; WId id;
TQRect rect; TQRect rect;
}; };

Loading…
Cancel
Save