diff options
Diffstat (limited to 'khotkeys/app')
-rw-r--r-- | khotkeys/app/Makefile.am | 21 | ||||
-rw-r--r-- | khotkeys/app/app.cpp | 158 | ||||
-rw-r--r-- | khotkeys/app/app.h | 43 | ||||
-rw-r--r-- | khotkeys/app/kded.cpp | 103 | ||||
-rw-r--r-- | khotkeys/app/kded.h | 44 | ||||
-rw-r--r-- | khotkeys/app/khotkeys.desktop | 43 |
6 files changed, 412 insertions, 0 deletions
diff --git a/khotkeys/app/Makefile.am b/khotkeys/app/Makefile.am new file mode 100644 index 000000000..274f4b57e --- /dev/null +++ b/khotkeys/app/Makefile.am @@ -0,0 +1,21 @@ +bin_PROGRAMS = +lib_LTLIBRARIES = +kdeinit_LTLIBRARIES = khotkeys.la +kde_module_LTLIBRARIES = kded_khotkeys.la + +khotkeys_la_SOURCES = app.cpp app.skel +khotkeys_la_LIBADD = ../shared/libkhotkeys_shared.la $(LIB_KDECORE) +khotkeys_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined + +kded_khotkeys_la_SOURCES = kded.cpp kded.skel +kded_khotkeys_la_LIBADD = ../shared/libkhotkeys_shared.la $(LIB_KDECORE) +kded_khotkeys_la_LDFLAGS = $(all_libraries) -module -avoid-version + +noinst_HEADERS = app.h kded.h + +INCLUDES = -I$(srcdir)/../shared $(all_includes) + +METASOURCES = AUTO + +servicesdir = $(kde_servicesdir)/kded +services_DATA = khotkeys.desktop diff --git a/khotkeys/app/app.cpp b/khotkeys/app/app.cpp new file mode 100644 index 000000000..612977aed --- /dev/null +++ b/khotkeys/app/app.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org> + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#define _KHOTKEYS_APP_CPP_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "app.h" + +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <klocale.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <X11/Xlib.h> + +#include <settings.h> +#include <input.h> +#include <action_data.h> +#include <gestures.h> +#include <voices.h> + +namespace KHotKeys +{ + +// KhotKeysApp + +KHotKeysApp::KHotKeysApp() + : KUniqueApplication( false, true ), // no styles + delete_helper( new QObject ) + { + init_global_data( true, delete_helper ); // grab keys + // CHECKME triggery a dalsi vytvaret az tady za inicializaci + actions_root = NULL; + reread_configuration(); + } + +KHotKeysApp::~KHotKeysApp() + { + // CHECKME triggery a dalsi rusit uz tady pred cleanupem + delete actions_root; +// Many global data should be destroyed while the QApplication object still +// exists, and therefore 'this' cannot be the parent, as ~Object +// for 'this' would be called after ~QApplication - use proxy object + delete delete_helper; + } + +void KHotKeysApp::reread_configuration() + { // TODO + kdDebug( 1217 ) << "reading configuration" << endl; + delete actions_root; + khotkeys_set_active( false ); + Settings settings; + settings.read_settings( false ); + gesture_handler->set_mouse_button( settings.gesture_mouse_button ); + gesture_handler->set_timeout( settings.gesture_timeout ); + gesture_handler->enable( !settings.gestures_disabled_globally ); + gesture_handler->set_exclude( settings.gestures_exclude ); + voice_handler->set_shortcut( settings.voice_shortcut ); +#if 0 // TEST CHECKME + settings.write_settings(); +#endif + actions_root = settings.actions; + khotkeys_set_active( true ); + actions_root->update_triggers(); + } + +void KHotKeysApp::quit() + { + kapp->quit(); + } + +} // namespace KHotKeys + + + +using namespace KHotKeys; + +// for multihead +static int khotkeys_screen_number = 0; + +extern "C" +int KDE_EXPORT kdemain( int argc, char** argv ) + { + { + // multiheaded hotkeys + QCString multiHead = getenv("KDE_MULTIHEAD"); + if (multiHead.lower() == "true") { + Display *dpy = XOpenDisplay(NULL); + if (! dpy) { + fprintf(stderr, "%s: FATAL ERROR while trying to open display %s\n", + argv[0], XDisplayName(NULL)); + exit(1); + } + + int number_of_screens = ScreenCount(dpy); + khotkeys_screen_number = DefaultScreen(dpy); + int pos; + QCString displayname = XDisplayString(dpy); + XCloseDisplay(dpy); + dpy = 0; + + if ((pos = displayname.findRev('.')) != -1) + displayname.remove(pos, 10); + + QCString env; + if (number_of_screens != 1) { + for (int i = 0; i < number_of_screens; i++) { + if (i != khotkeys_screen_number && fork() == 0) { + khotkeys_screen_number = i; + // break here because we are the child process, we don't + // want to fork() anymore + break; + } + } + + env.sprintf("DISPLAY=%s.%d", displayname.data(), khotkeys_screen_number); + if (putenv(strdup(env.data()))) { + fprintf(stderr, + "%s: WARNING: unable to set DISPLAY environment variable\n", + argv[0]); + perror("putenv()"); + } + } + } + } + + QCString appname; + if (khotkeys_screen_number == 0) + appname = "khotkeys"; + else + appname.sprintf("khotkeys-screen-%d", khotkeys_screen_number); + + // no need to i18n these, no GUI + KCmdLineArgs::init( argc, argv, appname, I18N_NOOP( "KHotKeys" ), + I18N_NOOP( "KHotKeys daemon" ), KHOTKEYS_VERSION ); + KUniqueApplication::addCmdLineOptions(); + if( !KHotKeysApp::start()) // already running + return 0; + KHotKeysApp app; + app.disableSessionManagement(); + return app.exec(); + } + + +#include "app.moc" diff --git a/khotkeys/app/app.h b/khotkeys/app/app.h new file mode 100644 index 000000000..6166276cb --- /dev/null +++ b/khotkeys/app/app.h @@ -0,0 +1,43 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org> + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#ifndef _KHOTKEYS_APP_H_ +#define _KHOTKEYS_APP_H_ + +#include <kuniqueapplication.h> + +namespace KHotKeys +{ + +class Action_data_group; + +class KHotKeysApp + : public KUniqueApplication + { + Q_OBJECT + K_DCOP + k_dcop: + ASYNC reread_configuration(); + ASYNC quit(); + public: + KHotKeysApp(); + virtual ~KHotKeysApp(); + private: + Action_data_group* actions_root; + QObject* delete_helper; + }; + +//*************************************************************************** +// Inline +//*************************************************************************** + +} // namespace KHotKeys + +#endif diff --git a/khotkeys/app/kded.cpp b/khotkeys/app/kded.cpp new file mode 100644 index 000000000..08c9bb487 --- /dev/null +++ b/khotkeys/app/kded.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org> + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#define _KHOTKEYS_KDED_CPP_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "kded.h" + +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <klocale.h> +#include <kapplication.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <X11/Xlib.h> + +#include <settings.h> +#include <input.h> +#include <action_data.h> +#include <gestures.h> +#include <voices.h> + +extern "C" +KDE_EXPORT KDEDModule *create_khotkeys( const QCString& obj ) + { + return new KHotKeys::KHotKeysModule( obj ); + } + +namespace KHotKeys +{ + +// KhotKeysModule + +KHotKeysModule::KHotKeysModule( const QCString& obj ) + : KDEDModule( obj ) + { + for( int i = 0; + i < 5; + ++i ) + { + if( kapp->dcopClient()->isApplicationRegistered( "khotkeys" )) + { + QByteArray data, replyData; + QCString 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(); + } + +KHotKeysModule::~KHotKeysModule() + { + // CHECKME triggery a dalsi rusit uz tady pred cleanupem + delete actions_root; + } + +void KHotKeysModule::reread_configuration() + { // TODO + kdDebug( 1217 ) << "reading configuration" << endl; + delete actions_root; + khotkeys_set_active( false ); + Settings settings; + settings.read_settings( false ); + gesture_handler->set_mouse_button( settings.gesture_mouse_button ); + gesture_handler->set_timeout( settings.gesture_timeout ); + gesture_handler->enable( !settings.gestures_disabled_globally ); + gesture_handler->set_exclude( settings.gestures_exclude ); + voice_handler->set_shortcut( settings.voice_shortcut ); +#if 0 // TEST CHECKME + settings.write_settings(); +#endif + actions_root = settings.actions; + khotkeys_set_active( true ); + actions_root->update_triggers(); + } + +void KHotKeysModule::quit() + { + delete this; + } + +} // namespace KHotKeys + +#include "kded.moc" diff --git a/khotkeys/app/kded.h b/khotkeys/app/kded.h new file mode 100644 index 000000000..f136cd6a0 --- /dev/null +++ b/khotkeys/app/kded.h @@ -0,0 +1,44 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org> + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#ifndef _KHOTKEYS_KDED_H_ +#define _KHOTKEYS_KDED_H_ + +#include <kdedmodule.h> +#include <dcopclient.h> + +namespace KHotKeys +{ + +class Action_data_group; + +class KHotKeysModule + : public KDEDModule + { + Q_OBJECT + K_DCOP + k_dcop: + ASYNC reread_configuration(); + ASYNC quit(); + public: + KHotKeysModule( const QCString& obj ); + virtual ~KHotKeysModule(); + private: + Action_data_group* actions_root; + DCOPClient client; + }; + +//*************************************************************************** +// Inline +//*************************************************************************** + +} // namespace KHotKeys + +#endif diff --git a/khotkeys/app/khotkeys.desktop b/khotkeys/app/khotkeys.desktop new file mode 100644 index 000000000..c9f983c74 --- /dev/null +++ b/khotkeys/app/khotkeys.desktop @@ -0,0 +1,43 @@ +[Desktop Entry] +Exec=khotkeys +Name=KHotKeys +Name[af]=KDE Kortpad Sleutels +Name[be]=Клавішныя скароты KDE +Name[bg]=Горещи клавиши +Name[cs]=Horké klávesy KDE +Name[csb]=Skrodzënë ë gestë +Name[cy]=BysellauBrysKDE +Name[eo]=Klavkombinoj +Name[es]=Teclas rápidas de KDE +Name[et]=KDE kiirklahvid +Name[fi]=Pikanäppäimet +Name[hi]=के-हॉट-कीज़ +Name[hu]=Parancsbeállító (KHotKeys) +Name[is]=Flýtilyklar KDE +Name[lt]=KDE klavišų kombinacijos +Name[lv]=KDE Karstie Taustiņi +Name[mk]=KDE брзи копчиња +Name[mn]=КДЭ-халуун тушаал +Name[nb]=KDE-hurtigtaster +Name[ne]=केडीई हट कुञ्जी +Name[nn]=KDE-snøggtastar +Name[pa]=ਕੇ-ਹਾਟਕੀ +Name[pl]=Skróty i gesty +Name[pt_BR]=Teclas de atalho +Name[ro]=Taste rapide +Name[ru]=Клавиши быстрого доступа +Name[se]=KDE jođánisboalut +Name[sv]=Khotkeys +Name[ta]=Kஹாட்கீஸ் +Name[te]=కెహాట్ కీలు +Name[tg]=Калидҳои тез +Name[th]=ปุ่มพิมพ์ลัดของ KDE +Name[uk]=Швидкі клавіші KDE +Name[vi]=Phím nóng KDE +Name[zh_TW]=KDE 熱鍵 +Type=Service +ServiceTypes=KDEDModule +X-KDE-ModuleType=Library +X-KDE-Library=khotkeys +X-KDE-FactoryName=khotkeys +X-KDE-Kded-autoload=false |