summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-06-09 22:22:02 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-08-01 13:02:12 +0300
commiteb1c3eedba99bb194d6aec4659fb5ff92348455c (patch)
tree66d14dc437953dbcbc0c37bb6ffad89d6c415658
parentdb3f842c545ce838e40a50e8025268c833c9fc57 (diff)
downloadtdebase-eb1c3eedba99bb194d6aec4659fb5ff92348455c.tar.gz
tdebase-eb1c3eedba99bb194d6aec4659fb5ff92348455c.zip
Add support for assigning global shortcuts for suspend actions
The corresponding shortcuts have been added as part of the KDesktop shortucts, to complement similar options (logout, shutdown, reboot). The shortcuts are only shown for the options that KSMServer reports via DCOP as valid. In order to do be able to make a DCOP call from kdesktopbindings.cpp, the <dcopref.h> include had to be added to several files of the shortcuts TDECM. Signed-off-by: Mavridis Philippe <mavridisf@gmail.com> (cherry picked from commit 95837cc844210a35b3374bbe707cb82920b80a9b)
-rw-r--r--kcontrol/keys/main.cpp1
-rw-r--r--kcontrol/keys/shortcuts.cpp1
-rw-r--r--kdesktop/desktop.cpp28
-rw-r--r--kdesktop/desktop.h4
-rw-r--r--kdesktop/kdesktopbindings.cpp21
5 files changed, 53 insertions, 2 deletions
diff --git a/kcontrol/keys/main.cpp b/kcontrol/keys/main.cpp
index bba777adb..db7416c28 100644
--- a/kcontrol/keys/main.cpp
+++ b/kcontrol/keys/main.cpp
@@ -26,6 +26,7 @@
#include <kdebug.h>
#include <tdelocale.h>
#include <ksimpleconfig.h>
+#include <dcopref.h>
#include "commandShortcuts.h"
#include "main.h"
diff --git a/kcontrol/keys/shortcuts.cpp b/kcontrol/keys/shortcuts.cpp
index 18f6803ab..4fb58a9b5 100644
--- a/kcontrol/keys/shortcuts.cpp
+++ b/kcontrol/keys/shortcuts.cpp
@@ -41,6 +41,7 @@
#include <tdeshortcutlist.h>
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
+#include <dcopref.h>
ShortcutsModule::ShortcutsModule( TQWidget *parent, const char *name )
: TQWidget( parent, name )
diff --git a/kdesktop/desktop.cpp b/kdesktop/desktop.cpp
index e7681b1f2..fac03a185 100644
--- a/kdesktop/desktop.cpp
+++ b/kdesktop/desktop.cpp
@@ -113,7 +113,7 @@ bool KRootWidget::eventFilter ( TQObject *, TQEvent * e )
else if ( e->type() == TQEvent::Drop )
{
TQDropEvent* de = static_cast<TQDropEvent*>( e );
- if ( KColorDrag::canDecode( de ) )
+ if ( KColorDrag::canDecode( de ) )
emit colorDropEvent( de );
else if ( TQImageDrag::canDecode( de ) )
emit imageDropEvent( de );
@@ -215,7 +215,7 @@ KDesktop::initRoot()
Display *dpy = tqt_xdisplay();
Window root = RootWindow(dpy, kdesktop_screen_number);
XDefineCursor(dpy, root, cursor().handle());
-
+
m_bDesktopEnabled = KDesktopSettings::desktopEnabled();
if ( !m_bDesktopEnabled && !m_pRootWidget )
{
@@ -1064,6 +1064,30 @@ void KDesktop::slotRebootNoCnf()
TDEApplication::ShutdownTypeReboot );
}
+void KDesktop::slotFreeze()
+{
+ DCOPRef r("ksmserver", "ksmserver");
+ r.send("suspend", 1);
+}
+
+void KDesktop::slotSuspend()
+{
+ DCOPRef r("ksmserver", "ksmserver");
+ r.send("suspend", 3);
+}
+
+void KDesktop::slotHibernate()
+{
+ DCOPRef r("ksmserver", "ksmserver");
+ r.send("suspend", 4);
+}
+
+void KDesktop::slotHybridSuspend()
+{
+ DCOPRef r("ksmserver", "ksmserver");
+ r.send("suspend", 5);
+}
+
void KDesktop::setVRoot( bool enable )
{
if ( enable == set_vroot )
diff --git a/kdesktop/desktop.h b/kdesktop/desktop.h
index c85e8b577..ca1eefc61 100644
--- a/kdesktop/desktop.h
+++ b/kdesktop/desktop.h
@@ -135,6 +135,10 @@ private slots:
void slotLogoutNoCnf();
void slotHaltNoCnf();
void slotRebootNoCnf();
+ void slotFreeze();
+ void slotSuspend();
+ void slotHibernate();
+ void slotHybridSuspend();
/** Connected to KSycoca */
void slotDatabaseChanged();
diff --git a/kdesktop/kdesktopbindings.cpp b/kdesktop/kdesktopbindings.cpp
index 17b27fc65..5f4fb24cd 100644
--- a/kdesktop/kdesktopbindings.cpp
+++ b/kdesktop/kdesktopbindings.cpp
@@ -49,6 +49,27 @@
}
#endif
+ // Only add these options if supported by ksmserver
+ DCOPRef ksmref("ksmserver", "ksmserver");
+ DCOPReply reply = ksmref.call("suspendOptions");
+
+ TQStringList suspendOptions;
+ if (reply.isValid()) {
+ reply.get(suspendOptions);
+ }
+
+ if (suspendOptions.contains("freeze"))
+ DEF( I18N_NOOP("Freeze"), TDEShortcut(), TDEShortcut(), slotFreeze() );
+
+ if (suspendOptions.contains("suspend"))
+ DEF( I18N_NOOP("Suspend"), TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), slotSuspend() );
+
+ if (suspendOptions.contains("hibernate"))
+ DEF( I18N_NOOP("Hibernate"), TDEShortcut(), TDEShortcut(), slotHibernate() );
+
+ if (suspendOptions.contains("hybridSuspend"))
+ DEF( I18N_NOOP("Hybrid Suspend"), TDEShortcut(), TDEShortcut(), slotHybridSuspend() );
+
#undef DEF
#undef DEF2
#undef WIN