aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Keys.cc49
-rw-r--r--src/Keys.hh22
2 files changed, 30 insertions, 41 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index a0aabd5..196c5e0 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Keys.cc,v 1.35 2003/07/02 05:42:21 fluxgen Exp $ 22//$Id: Keys.cc,v 1.36 2003/08/19 16:19:28 fluxgen Exp $
23 23
24 24
25#include "Keys.hh" 25#include "Keys.hh"
@@ -71,15 +71,16 @@
71 71
72using namespace std; 72using namespace std;
73 73
74int Keys::s_capslock_mod = 0;
75int Keys::s_numlock_mod = 0;
76int Keys::s_scrolllock_mod = 0;
77
74Keys::Keys(const char *filename): 78Keys::Keys(const char *filename):
75 m_capslock_mod(0),
76 m_numlock_mod(0),
77 m_scrolllock_mod(0),
78 m_abortkey(0),
79 m_display(FbTk::App::instance()->display()), 79 m_display(FbTk::App::instance()->display()),
80 m_modmap(0) 80 m_modmap(0) {
81{ 81
82 loadModmap(); 82 loadModmap();
83
83 if (filename != 0) 84 if (filename != 0)
84 load(filename); 85 load(filename);
85} 86}
@@ -92,17 +93,13 @@ Keys::~Keys() {
92 deleteTree(); 93 deleteTree();
93} 94}
94 95
95/// Destroys the keytree and m_abortkey 96/// Destroys the keytree
96void Keys::deleteTree() { 97void Keys::deleteTree() {
97 while (!m_keylist.empty()) { 98 while (!m_keylist.empty()) {
98 if (m_keylist.back() && m_keylist.back() != 0) 99 if (m_keylist.back())
99 delete m_keylist.back(); 100 delete m_keylist.back();
100 m_keylist.pop_back(); 101 m_keylist.pop_back();
101 } 102 }
102 if (m_abortkey) {
103 delete m_abortkey;
104 m_abortkey=0;
105 }
106} 103}
107 104
108/// Ungrabs the keys 105/// Ungrabs the keys
@@ -243,35 +240,35 @@ void Keys::grabKey(unsigned int key, unsigned int mod) {
243 // Grab with numlock, capslock and scrlock 240 // Grab with numlock, capslock and scrlock
244 241
245 //numlock 242 //numlock
246 XGrabKey(m_display, key, mod|m_numlock_mod, 243 XGrabKey(m_display, key, mod|s_numlock_mod,
247 root, True, 244 root, True,
248 GrabModeAsync, GrabModeAsync); 245 GrabModeAsync, GrabModeAsync);
249 //scrolllock 246 //scrolllock
250 XGrabKey(m_display, key, mod|m_scrolllock_mod, 247 XGrabKey(m_display, key, mod|s_scrolllock_mod,
251 root, True, 248 root, True,
252 GrabModeAsync, GrabModeAsync); 249 GrabModeAsync, GrabModeAsync);
253 //capslock 250 //capslock
254 XGrabKey(m_display, key, mod|m_capslock_mod, 251 XGrabKey(m_display, key, mod|s_capslock_mod,
255 root, True, 252 root, True,
256 GrabModeAsync, GrabModeAsync); 253 GrabModeAsync, GrabModeAsync);
257 254
258 //capslock+numlock 255 //capslock+numlock
259 XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, 256 XGrabKey(m_display, key, mod|s_capslock_mod|s_numlock_mod,
260 root, True, 257 root, True,
261 GrabModeAsync, GrabModeAsync); 258 GrabModeAsync, GrabModeAsync);
262 259
263 //capslock+scrolllock 260 //capslock+scrolllock
264 XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, 261 XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod,
265 root, True, 262 root, True,
266 GrabModeAsync, GrabModeAsync); 263 GrabModeAsync, GrabModeAsync);
267 264
268 //capslock+numlock+scrolllock 265 //capslock+numlock+scrolllock
269 XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, 266 XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod|s_numlock_mod,
270 root, True, 267 root, True,
271 GrabModeAsync, GrabModeAsync); 268 GrabModeAsync, GrabModeAsync);
272 269
273 //numlock+scrollLock 270 //numlock+scrollLock
274 XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, 271 XGrabKey(m_display, key, mod|s_numlock_mod|s_scrolllock_mod,
275 root, True, 272 root, True,
276 GrabModeAsync, GrabModeAsync); 273 GrabModeAsync, GrabModeAsync);
277 274
@@ -287,10 +284,10 @@ unsigned int Keys::getModifier(const char *modstr) {
287 if (!modstr) 284 if (!modstr)
288 return 0; 285 return 0;
289 struct t_modlist{ 286 struct t_modlist{
290 char *string; 287 char *str;
291 unsigned int mask; 288 unsigned int mask;
292 bool operator == (const char *modstr) { 289 bool operator == (const char *modstr) {
293 return (strcasecmp(string, modstr) == 0 && mask !=0); 290 return (strcasecmp(str, modstr) == 0 && mask !=0);
294 } 291 }
295 } modlist[] = { 292 } modlist[] = {
296 {"SHIFT", ShiftMask}, 293 {"SHIFT", ShiftMask},
@@ -304,7 +301,7 @@ unsigned int Keys::getModifier(const char *modstr) {
304 }; 301 };
305 302
306 // find mod mask string 303 // find mod mask string
307 for (unsigned int i=0; modlist[i].string!=0; i++) { 304 for (unsigned int i=0; modlist[i].str !=0; i++) {
308 if (modlist[i] == modstr) 305 if (modlist[i] == modstr)
309 return modlist[i].mask; 306 return modlist[i].mask;
310 } 307 }
@@ -480,13 +477,13 @@ void Keys::loadModmap() {
480 477
481 switch (ks) { 478 switch (ks) {
482 case XK_Caps_Lock: 479 case XK_Caps_Lock:
483 m_capslock_mod = mods[i]; 480 s_capslock_mod = mods[i];
484 break; 481 break;
485 case XK_Scroll_Lock: 482 case XK_Scroll_Lock:
486 m_scrolllock_mod = mods[i]; 483 s_scrolllock_mod = mods[i];
487 break; 484 break;
488 case XK_Num_Lock: 485 case XK_Num_Lock:
489 m_numlock_mod = mods[i]; 486 s_numlock_mod = mods[i];
490 break; 487 break;
491 } 488 }
492 } 489 }
diff --git a/src/Keys.hh b/src/Keys.hh
index a296200..efd6331 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -1,5 +1,5 @@
1// Keys.hh for Fluxbox - an X11 Window manager 1// Keys.hh for Fluxbox - an X11 Window manager
2// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at linuxmail.org) 2// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Keys.hh,v 1.26 2003/06/30 14:57:14 fluxgen Exp $ 22// $Id: Keys.hh,v 1.27 2003/08/19 16:18:54 fluxgen Exp $
23 23
24#ifndef KEYS_HH 24#ifndef KEYS_HH
25#define KEYS_HH 25#define KEYS_HH
@@ -52,7 +52,7 @@ public:
52 */ 52 */
53 static unsigned int cleanMods(unsigned int mods) 53 static unsigned int cleanMods(unsigned int mods)
54 //remove numlock, capslock and scrolllock 54 //remove numlock, capslock and scrolllock
55 { return mods & (~Mod2Mask & ~Mod5Mask & ~LockMask);} 55 { return mods & (~s_capslock_mod & ~s_numlock_mod & ~s_scrolllock_mod); }
56 56
57 unsigned int keycodeToModmask(unsigned int keycode); 57 unsigned int keycodeToModmask(unsigned int keycode);
58 void loadModmap(); 58 void loadModmap();
@@ -132,21 +132,13 @@ private:
132 */ 132 */
133 bool mergeTree(t_key *newtree, t_key *basetree=0); 133 bool mergeTree(t_key *newtree, t_key *basetree=0);
134 134
135#ifdef DEBUG 135 static int s_capslock_mod, s_numlock_mod, s_scrolllock_mod; ///< modifiers
136 /// debug function
137 void showTree();
138 /// debug function
139 void showKeyTree(t_key *key, unsigned int w=0);
140#endif //DEBUG
141
142 int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers
143 136
144 std::vector<t_key *> m_keylist; 137 std::vector<t_key *> m_keylist;
145 t_key *m_abortkey; ///< abortkey for keygrabbing chain
146 std::string m_execcmdstring; ///< copy of the execcommandstring 138 std::string m_execcmdstring; ///< copy of the execcommandstring
147 int m_param; ///< copy of the param argument 139 int m_param; ///< copy of the param argument
148 Display *m_display; ///< display connection 140 Display *m_display; ///< display connection
149 XModifierKeymap *m_modmap; // Modifier->keycode mapping 141 XModifierKeymap *m_modmap; ///< Modifier->keycode mapping
150}; 142};
151 143
152#endif // _KEYS_HH_ 144#endif // KEYS_HH