From 94368f4722fa8eae1f7e7cd4b02679a760b0d620 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 19 Sep 2024 17:48:43 +0900 Subject: Various fixes for khotkeys. This resolves issue #326. 1. ensure there is a single khotkeys instance running per session instead of per screen (remote multihead related code) 2. allow khotkeys to be run as a kded module 3. make sure that khotkeys run either as a standalone application or as a kded module, but not both at the same time 4. do not register khotkeys as a main DCOP entry (like an app) anymore. When run as kded module, this was causing kded to be registered as khotkeys a second time. Signed-off-by: Michele Calgaro --- khotkeys/app/kded.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'khotkeys/app/kded.cpp') diff --git a/khotkeys/app/kded.cpp b/khotkeys/app/kded.cpp index db4153e01..c78504919 100644 --- a/khotkeys/app/kded.cpp +++ b/khotkeys/app/kded.cpp @@ -16,6 +16,7 @@ #include "kded.h" +#include #include #include #include @@ -35,9 +36,17 @@ extern "C" TDE_EXPORT KDEDModule *create_khotkeys( const TQCString& obj ) - { - return new KHotKeys::KHotKeysModule( obj ); - } +{ + // Check if khotkeys is already running as a stand alone application. + // In such case just exit. + if (kapp->dcopClient()->isApplicationRegistered("khotkeys")) + { + kdWarning(1217) << "khotkeys [kded module] is already running as a standalone application. Exiting." << endl; + return nullptr; + } + + return new KHotKeys::KHotKeysModule( obj ); +} namespace KHotKeys { @@ -47,22 +56,7 @@ namespace KHotKeys KHotKeysModule::KHotKeysModule( const TQCString& obj ) : KDEDModule( obj ) { - for( int i = 0; - i < 5; - ++i ) - { - if( kapp->dcopClient()->isApplicationRegistered( "khotkeys" )) - { - TQByteArray data, replyData; - TQCString reply; - // wait for it to finish - kapp->dcopClient()->call( "khotkeys*", "khotkeys", "quit()", data, reply, replyData ); - sleep( 1 ); - } - } - client.registerAs( "khotkeys", false ); // extra dcop connection (like if it was an app) init_global_data( true, this ); // grab keys - // CHECKME triggery a dalsi vytvaret az tady za inicializaci actions_root = NULL; reread_configuration(); } -- cgit v1.2.1