summaryrefslogtreecommitdiffstats
path: root/khotkeys/app/kded.cpp
blob: 3ebb555753b8040943a1acd135c8294478ab965c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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 TQCString& obj )
    {
    return new KHotKeys::KHotKeysModule( obj );
    }

namespace KHotKeys
{

// KhotKeysModule

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();
    }

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"