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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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 TQObject )
{
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 TQApplication object still
// exists, and therefore 'this' cannot be the parent, as ~Object
// for 'this' would be called after ~TQApplication - 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
TQCString 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;
TQCString displayname = XDisplayString(dpy);
XCloseDisplay(dpy);
dpy = 0;
if ((pos = displayname.tqfindRev('.')) != -1)
displayname.remove(pos, 10);
TQCString 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()");
}
}
}
}
TQCString 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"
|