summaryrefslogtreecommitdiffstats
path: root/ksmserver
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-05-20 18:22:04 -0500
committerTimothy Pearson <[email protected]>2012-05-20 18:22:04 -0500
commit193d9afcdb186902317c5bef5d6c769fc8933f1a (patch)
tree7634b1ddfbef08527a9fc55841ccbbdac2de7cae /ksmserver
parent2f2f32d31cb1548defcd7aa84187ac7df6479cce (diff)
downloadtdebase-193d9afcdb186902317c5bef5d6c769fc8933f1a.tar.gz
tdebase-193d9afcdb186902317c5bef5d6c769fc8933f1a.zip
Fix desktop lock not engaging on suspend
This closes Bug 1003
Diffstat (limited to 'ksmserver')
-rw-r--r--ksmserver/shutdown.cpp43
-rw-r--r--ksmserver/shutdowndlg.cpp59
-rw-r--r--ksmserver/shutdowndlg.h5
3 files changed, 60 insertions, 47 deletions
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp
index 09cb2d743..ef0c0c92f 100644
--- a/ksmserver/shutdown.cpp
+++ b/ksmserver/shutdown.cpp
@@ -83,6 +83,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libkrsync/krsync.h>
+#ifdef WITH_UPOWER
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+#endif
+
#include "server.h"
#include "global.h"
#include "shutdowndlg.h"
@@ -169,14 +176,48 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
dialogActive = true;
if ( !logoutConfirmed ) {
+ int selection;
KSMShutdownFeedback::start(); // make the screen gray
logoutConfirmed =
- KSMShutdownDlg::confirmShutdown( maysd, sdtype, bopt );
+ KSMShutdownDlg::confirmShutdown( maysd, sdtype, bopt, &selection );
// ###### We can't make the screen remain gray while talking to the apps,
// because this prevents interaction ("do you want to save", etc.)
// TODO: turn the feedback widget into a list of apps to be closed,
// with an indicator of the current status for each.
KSMShutdownFeedback::stop(); // make the screen become normal again
+ if (selection != 0) {
+ // respect lock on resume & disable suspend/hibernate settings
+ // from power-manager
+ KConfig config("power-managerrc");
+ bool lockOnResume = config.readBoolEntry("lockOnResume", true);
+ if (lockOnResume) {
+ DCOPRef("kdesktop", "KScreensaverIface").send("lock");
+ }
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (selection == 1) { // Suspend
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Suspend");
+ dbusConn.sendWithReply(msg);
+ }
+ }
+ if (selection == 2) { // Hibernate
+ if( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Hibernate");
+ dbusConn.sendWithReply(msg);
+ }
+ }
+#endif // WITH_UPOWER
+ }
}
if ( logoutConfirmed ) {
diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp
index 35cae6537..3b1e27f68 100644
--- a/ksmserver/shutdowndlg.cpp
+++ b/ksmserver/shutdowndlg.cpp
@@ -674,14 +674,17 @@ void KSMShutdownIPFeedback::slotPaintEffect()
//////
KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
- bool maysd, KApplication::ShutdownType sdtype )
- : TQDialog( parent, 0, TRUE, (WFlags)WType_Popup ), targets(0)
+ bool maysd, KApplication::ShutdownType sdtype, int* selection )
+ : TQDialog( parent, 0, TRUE, (WFlags)WType_Popup ), targets(0), m_selection(selection)
// this is a WType_Popup on purpose. Do not change that! Not
// having a popup here has severe side effects.
{
TQVBoxLayout* vbox = new TQVBoxLayout( this );
+ if (m_selection) {
+ *m_selection = 0;
+ }
TQFrame* frame = new TQFrame( this );
frame->setFrameStyle( TQFrame::StyledPanel | TQFrame::Raised );
@@ -1104,27 +1107,12 @@ void KSMShutdownDlg::slotHalt()
void KSMShutdownDlg::slotSuspend()
{
-#ifdef WITH_UPOWER
- if (m_lockOnResume) {
- DCOPRef("kdesktop", "KScreensaverIface").send("lock");
- }
+ *m_selection = 1; // Suspend
- if( m_dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Suspend");
- m_dbusConn.sendWithReply(msg);
- }
-
- reject(); // continue on resume
+#ifdef WITH_UPOWER
+ // Handled in shutdown.cpp
#else
#ifdef COMPILE_HALBACKEND
- if (m_lockOnResume) {
- DCOPRef("kdesktop", "KScreensaverIface").send("lock");
- }
-
if (m_dbusConn)
{
DBusMessage *msg = dbus_message_new_method_call(
@@ -1140,35 +1128,19 @@ void KSMShutdownDlg::slotSuspend()
dbus_message_unref(msg);
}
-
- reject(); // continue on resume
#endif
#endif // WITH_UPOWER
+ reject(); // continue on resume
}
void KSMShutdownDlg::slotHibernate()
{
-#ifdef WITH_UPOWER
- if (m_lockOnResume) {
- DCOPRef("kdesktop", "KScreensaverIface").send("lock");
- }
-
- if( m_dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Hibernate");
- m_dbusConn.sendWithReply(msg);
- }
+ *m_selection = 2; // Hibernate
- reject(); // continue on resume
+#ifdef WITH_UPOWER
+ // Handled in shutdown.cpp
#else
#ifdef COMPILE_HALBACKEND
- if (m_lockOnResume) {
- DCOPRef("kdesktop", "KScreensaverIface").send("lock");
- }
-
if (m_dbusConn)
{
DBusMessage *msg = dbus_message_new_method_call(
@@ -1181,18 +1153,17 @@ void KSMShutdownDlg::slotHibernate()
dbus_message_unref(msg);
}
-
- reject(); // continue on resume
#endif
#endif // WITH_UPOWER
+ reject(); // continue on resume
}
-bool KSMShutdownDlg::confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, TQString& bootOption )
+bool KSMShutdownDlg::confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, TQString& bootOption, int* selection )
{
kapp->enableStyles();
KSMShutdownDlg* l = new KSMShutdownDlg( 0,
//KSMShutdownFeedback::self(),
- maysd, sdtype );
+ maysd, sdtype, selection );
// Show dialog (will save the background in showEvent)
TQSize sh = l->sizeHint();
diff --git a/ksmserver/shutdowndlg.h b/ksmserver/shutdowndlg.h
index 05ca99126..eab4570e1 100644
--- a/ksmserver/shutdowndlg.h
+++ b/ksmserver/shutdowndlg.h
@@ -129,7 +129,7 @@ class KSMShutdownDlg : public TQDialog
Q_OBJECT
public:
- static bool confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, TQString& bopt );
+ static bool confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, TQString& bopt, int* selection=0 );
public slots:
void slotLogout();
@@ -143,7 +143,7 @@ protected:
~KSMShutdownDlg();
private:
- KSMShutdownDlg( TQWidget* parent, bool maysd, KApplication::ShutdownType sdtype );
+ KSMShutdownDlg( TQWidget* parent, bool maysd, KApplication::ShutdownType sdtype, int* selection=0 );
KApplication::ShutdownType m_shutdownType;
TQString m_bootOption;
TQPopupMenu *targets;
@@ -157,6 +157,7 @@ private:
#endif
#endif // WITH_UPOWER
bool m_lockOnResume;
+ int* m_selection;
};
// The shutdown-in-progress dialog