Fix ACPI event detection as a normal user

This resolves Bug 1597
Do not display logout dialog if screensaver/lock dialog is active
pull/1/head
Timothy Pearson 11 years ago
parent f956245ca2
commit acd6cbd7de

@ -39,6 +39,8 @@
#include "tdepowersave_debug.h" #include "tdepowersave_debug.h"
#include "privileges.h" #include "privileges.h"
// #define USE_EVENT_DEVICES_DIRECTLY 1
/*! The default constructor of the class HardwareInfo */ /*! The default constructor of the class HardwareInfo */
HardwareInfo::HardwareInfo() { HardwareInfo::HardwareInfo() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
@ -55,7 +57,10 @@ HardwareInfo::HardwareInfo() {
// initialize connection to the TDE hardware library // initialize connection to the TDE hardware library
m_hwdevices = TDEGlobal::hardwareDevices(); m_hwdevices = TDEGlobal::hardwareDevices();
connect(m_hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareChangedEvent(TDEGenericDevice*))); connect(m_hwdevices, TQT_SIGNAL(hardwareUpdated(TDEGenericDevice*)), this, TQT_SLOT(processHardwareChangedEvent(TDEGenericDevice*)));
#ifdef USE_EVENT_DEVICES_DIRECTLY
connect(m_hwdevices, TQT_SIGNAL(eventDeviceKeyPressed(unsigned int, TDEEventDevice*)), this, TQT_SLOT(processKeyPressEvent(unsigned int, TDEEventDevice*))); connect(m_hwdevices, TQT_SIGNAL(eventDeviceKeyPressed(unsigned int, TDEEventDevice*)), this, TQT_SLOT(processKeyPressEvent(unsigned int, TDEEventDevice*)));
#endif
// update everything the first time // update everything the first time
update_info_ac_changed = true; update_info_ac_changed = true;

@ -30,6 +30,7 @@
#include <knotifydialog.h> #include <knotifydialog.h>
#include <kpassivepopup.h> #include <kpassivepopup.h>
#include <tdepopupmenu.h> #include <tdepopupmenu.h>
#include <kglobalaccel.h>
// other TQt headers: // other TQt headers:
#include <tqcursor.h> #include <tqcursor.h>
@ -114,6 +115,17 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
connect(autoDimm, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_downDimm())); connect(autoDimm, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_downDimm()));
connect(autoDimm, TQT_SIGNAL(UserIsActiveAgain()), this, TQT_SLOT(do_upDimm())); connect(autoDimm, TQT_SIGNAL(UserIsActiveAgain()), this, TQT_SLOT(do_upDimm()));
// connect to hotkeys
m_globalAccel = new TDEGlobalAccel( TQT_TQOBJECT(this) );
m_globalAccel->insert( "Power button", i18n( "Execute configured power button action"), TQString(),
TDEShortcut(TQString("XF86PowerOff")), TDEShortcut(TQString("XF86PowerOff")), TQT_TQOBJECT(this), TQT_SLOT( handlePowerButtonEvent() ) );
m_globalAccel->insert( "Sleep button", i18n( "Sleep configured power button action"), TQString(),
TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), TQT_TQOBJECT(this), TQT_SLOT( handleSleepButtonEvent() ) );
m_globalAccel->insert( "Hibernate button", i18n( "Hibernate configured power button action"), TQString(),
TDEShortcut(TQString("XF86Suspend")), TDEShortcut(TQString("XF86Suspend")), TQT_TQOBJECT(this), TQT_SLOT( handleS2DiskButtonEvent() ) );
m_globalAccel->readSettings();
m_globalAccel->updateConnections();
config->sync(); config->sync();
config_dialog_shown = false; config_dialog_shown = false;
@ -1982,7 +1994,7 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
if (hwinfo->currentSessionIsActive()) { if (hwinfo->currentSessionIsActive()) {
switch (action) { switch (action) {
case GO_SHUTDOWN: case GO_SHUTDOWN:
// to be shure if we really need the shutdown // confirm that we really need/want to shutdown
if ((checkAC && !hwinfo->getAcAdapter()) || !checkAC ) { if ((checkAC && !hwinfo->getAcAdapter()) || !checkAC ) {
DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" ); DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" );
shutdown.send("logout", 0, 2, 2); shutdown.send("logout", 0, 2, 2);
@ -1990,8 +2002,22 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
break; break;
case LOGOUT_DIALOG: case LOGOUT_DIALOG:
{ {
DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" ); // Do not display the logout dialog if the screen saver/lock system is active
shutdown.send("logout", 1, 2, 2); bool saving = true;
TQString _method;
DCOPRef dcop_ref = DCOPRef( "kdesktop", "KScreensaverIface" );
_method = "isBlanked()";
DCOPReply reply = dcop_ref.call(_method.latin1());
if ( reply.isValid() ) {
if (!reply.get(saving)) {
saving = false;
}
}
if (!saving) {
DCOPRef shutdown = DCOPRef( "ksmserver", "ksmserver" );
shutdown.send("logout", 1, 2, 2);
}
} }
break; break;
case GO_SUSPEND2RAM: case GO_SUSPEND2RAM:

@ -52,6 +52,7 @@
#include "screen.h" #include "screen.h"
#include "settings.h" #include "settings.h"
class TDEGlobalAccel;
/*! /*!
* \file tdepowersave.h * \file tdepowersave.h
@ -98,6 +99,7 @@ private:
//! instance of \ref countDownDialog //! instance of \ref countDownDialog
countDownDialog *countdown; countDownDialog *countdown;
TDEGlobalAccel *m_globalAccel;
//! struct wth information about suspend states and permissions //! struct wth information about suspend states and permissions
SuspendStates suspend; SuspendStates suspend;

Loading…
Cancel
Save