aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Keys.cc168
1 files changed, 75 insertions, 93 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 92fa617..54ae77a 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.8 2002/01/10 14:24:09 fluxgen Exp $ 22//$Id: Keys.cc,v 1.9 2002/01/21 01:48:47 fluxgen Exp $
23 23
24#ifdef HAVE_CONFIG_H 24#ifdef HAVE_CONFIG_H
25# include "config.h" 25# include "config.h"
@@ -76,53 +76,53 @@
76using namespace std; 76using namespace std;
77 77
78Keys::t_actionstr Keys::m_actionlist[] = { 78Keys::t_actionstr Keys::m_actionlist[] = {
79 {"Minimize", ICONIFY}, 79 {"Minimize", ICONIFY},
80 {"Raise", RAISE}, 80 {"Raise", RAISE},
81 {"Lower", LOWER}, 81 {"Lower", LOWER},
82 {"Close", CLOSE}, 82 {"Close", CLOSE},
83 {"AbortKeychain", ABORTKEYCHAIN}, 83 {"AbortKeychain", ABORTKEYCHAIN},
84 {"Workspace1", WORKSPACE1}, 84 {"Workspace1", WORKSPACE1},
85 {"Workspace2", WORKSPACE2}, 85 {"Workspace2", WORKSPACE2},
86 {"Workspace3", WORKSPACE3}, 86 {"Workspace3", WORKSPACE3},
87 {"Workspace4", WORKSPACE4}, 87 {"Workspace4", WORKSPACE4},
88 {"Workspace5", WORKSPACE5}, 88 {"Workspace5", WORKSPACE5},
89 {"Workspace6", WORKSPACE6}, 89 {"Workspace6", WORKSPACE6},
90 {"Workspace7", WORKSPACE7}, 90 {"Workspace7", WORKSPACE7},
91 {"Workspace8", WORKSPACE8}, 91 {"Workspace8", WORKSPACE8},
92 {"Workspace9", WORKSPACE9}, 92 {"Workspace9", WORKSPACE9},
93 {"Workspace10", WORKSPACE10}, 93 {"Workspace10", WORKSPACE10},
94 {"Workspace11", WORKSPACE11}, 94 {"Workspace11", WORKSPACE11},
95 {"Workspace12", WORKSPACE12}, 95 {"Workspace12", WORKSPACE12},
96 {"NextWorkspace", NEXTWORKSPACE}, 96 {"NextWorkspace", NEXTWORKSPACE},
97 {"PrevWorkspace", PREVWORKSPACE}, 97 {"PrevWorkspace", PREVWORKSPACE},
98 {"LeftWorkspace", LEFTWORKSPACE}, 98 {"LeftWorkspace", LEFTWORKSPACE},
99 {"RightWorkspace", RIGHTWORKSPACE}, 99 {"RightWorkspace", RIGHTWORKSPACE},
100 {"KillWindow", KILLWINDOW}, 100 {"KillWindow", KILLWINDOW},
101 {"NextWindow", NEXTWINDOW}, 101 {"NextWindow", NEXTWINDOW},
102 {"PrevWindow", PREVWINDOW}, 102 {"PrevWindow", PREVWINDOW},
103 {"NextTab", NEXTTAB}, 103 {"NextTab", NEXTTAB},
104 {"PrevTab", PREVTAB}, 104 {"PrevTab", PREVTAB},
105 {"ShadeWindow", SHADE}, 105 {"ShadeWindow", SHADE},
106 {"MaximizeWindow", MAXIMIZE}, 106 {"MaximizeWindow", MAXIMIZE},
107 {"StickWindow", STICK}, 107 {"StickWindow", STICK},
108 {"ExecCommand", EXECUTE}, 108 {"ExecCommand", EXECUTE},
109 {"MaximizeVertical", VERTMAX}, 109 {"MaximizeVertical", VERTMAX},
110 {"MaximizeHorizontal", HORIZMAX}, 110 {"MaximizeHorizontal", HORIZMAX},
111 {"NudgeRight", NUDGERIGHT}, 111 {"NudgeRight", NUDGERIGHT},
112 {"NudgeLeft", NUDGELEFT}, 112 {"NudgeLeft", NUDGELEFT},
113 {"NudgeUp", NUDGEUP}, 113 {"NudgeUp", NUDGEUP},
114 {"NudgeDown", NUDGEDOWN}, 114 {"NudgeDown", NUDGEDOWN},
115 {"BigNudgeRight", BIGNUDGERIGHT}, 115 {"BigNudgeRight", BIGNUDGERIGHT},
116 {"BigNudgeLeft", BIGNUDGELEFT}, 116 {"BigNudgeLeft", BIGNUDGELEFT},
117 {"BigNudgeUp", BIGNUDGEUP}, 117 {"BigNudgeUp", BIGNUDGEUP},
118 {"BigNudgeDown", BIGNUDGEDOWN}, 118 {"BigNudgeDown", BIGNUDGEDOWN},
119 {"HorizontalIncrement", HORIZINC}, 119 {"HorizontalIncrement", HORIZINC},
120 {"VerticalIncrement", VERTINC}, 120 {"VerticalIncrement", VERTINC},
121 {"HorizontalDecrement", HORIZDEC}, 121 {"HorizontalDecrement", HORIZDEC},
122 {"VerticalDecrement", VERTDEC}, 122 {"VerticalDecrement", VERTDEC},
123 {"ToggleDecor", TOGGLEDECOR}, 123 {"ToggleDecor", TOGGLEDECOR},
124 {0, LASTKEYGRAB} 124 {0, LASTKEYGRAB}
125 }; 125 };
126 126
127Keys::Keys(Display *display, char *filename): 127Keys::Keys(Display *display, char *filename):
128m_abortkey(0), 128m_abortkey(0),
@@ -277,17 +277,6 @@ bool Keys::load(char *filename) {
277 //add the keychain to list 277 //add the keychain to list
278 if (!mergeTree(current_key)) 278 if (!mergeTree(current_key))
279 cerr<<"Keys: Failed to merge keytree!"<<endl; 279 cerr<<"Keys: Failed to merge keytree!"<<endl;
280
281 #ifdef DEBUG
282 if (m_actionlist[i].action == Keys::EXECUTE) {
283
284 cerr<<"line:"<<line<<endl;
285 cerr<<"buffer:"<<const_cast<char *>(StringUtil::strcasestr(linebuffer.get(),
286 getActionStr(Keys::EXECUTE)) + strlen(getActionStr(Keys::EXECUTE)))<<endl;
287 cerr<<"command:"<<last_key->execcommand<<endl;
288
289 }
290 #endif
291 280
292 //clear keypointers now that we have them in m_keylist 281 //clear keypointers now that we have them in m_keylist
293 delete current_key; 282 delete current_key;
@@ -308,10 +297,7 @@ bool Keys::load(char *filename) {
308 } 297 }
309 } 298 }
310 } 299 }
311 300
312 #ifdef DEBUG
313 showTree(); //who keybinding tree
314 #endif
315 return true; 301 return true;
316} 302}
317 303
@@ -320,53 +306,49 @@ bool Keys::load(char *filename) {
320// and with numlock,capslock and scrollock 306// and with numlock,capslock and scrollock
321//---------------------------------------- 307//----------------------------------------
322void Keys::grabKey(unsigned int key, unsigned int mod) { 308void Keys::grabKey(unsigned int key, unsigned int mod) {
323 309
324 #ifdef DEBUG
325 cerr<<__FILE__<<"("<<__LINE__<<"): keycode "<<key<<" mod "<<hex<<mod<<dec<<endl;
326 #endif
327
328 for (int screen=0; screen<ScreenCount(m_display); screen++) { 310 for (int screen=0; screen<ScreenCount(m_display); screen++) {
329 311
330 Window root = RootWindow(m_display, screen); 312 Window root = RootWindow(m_display, screen);
331 313
332 XGrabKey(m_display, key, mod, 314 XGrabKey(m_display, key, mod,
333 root, True, 315 root, True,
334 GrabModeAsync, GrabModeAsync); 316 GrabModeAsync, GrabModeAsync);
335 317
336 // Grab with numlock, capslock and scrlock 318 // Grab with numlock, capslock and scrlock
337 319
338 //numlock 320 //numlock
339 XGrabKey(m_display, key, mod|Mod2Mask, 321 XGrabKey(m_display, key, mod|Mod2Mask,
340 root, True, 322 root, True,
341 GrabModeAsync, GrabModeAsync); 323 GrabModeAsync, GrabModeAsync);
342 //scrolllock 324 //scrolllock
343 XGrabKey(m_display, key, mod|Mod5Mask, 325 XGrabKey(m_display, key, mod|Mod5Mask,
344 root, True, 326 root, True,
345 GrabModeAsync, GrabModeAsync); 327 GrabModeAsync, GrabModeAsync);
346 //capslock 328 //capslock
347 XGrabKey(m_display, key, mod|LockMask, 329 XGrabKey(m_display, key, mod|LockMask,
348 root, True, 330 root, True,
349 GrabModeAsync, GrabModeAsync); 331 GrabModeAsync, GrabModeAsync);
350 332
351 //capslock+numlock 333 //capslock+numlock
352 XGrabKey(m_display, key, mod|LockMask|Mod2Mask, 334 XGrabKey(m_display, key, mod|LockMask|Mod2Mask,
353 root, True, 335 root, True,
354 GrabModeAsync, GrabModeAsync); 336 GrabModeAsync, GrabModeAsync);
355 337
356 //capslock+scrolllock 338 //capslock+scrolllock
357 XGrabKey(m_display, key, mod|LockMask|Mod5Mask, 339 XGrabKey(m_display, key, mod|LockMask|Mod5Mask,
358 root, True, 340 root, True,
359 GrabModeAsync, GrabModeAsync); 341 GrabModeAsync, GrabModeAsync);
360 342
361 //capslock+numlock+scrolllock 343 //capslock+numlock+scrolllock
362 XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask|LockMask, 344 XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask|LockMask,
363 root, True, 345 root, True,
364 GrabModeAsync, GrabModeAsync); 346 GrabModeAsync, GrabModeAsync);
365 347
366 //numlock+scrollLock 348 //numlock+scrollLock
367 XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask, 349 XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask,
368 root, True, 350 root, True,
369 GrabModeAsync, GrabModeAsync); 351 GrabModeAsync, GrabModeAsync);
370 352
371 } 353 }
372 354
@@ -387,14 +369,14 @@ unsigned int Keys::getModifier(const char *modstr) {
387 return (strcasecmp(string, modstr) == 0 && mask !=0); 369 return (strcasecmp(string, modstr) == 0 && mask !=0);
388 } 370 }
389 } modlist[] = { 371 } modlist[] = {
390 {"SHIFT", ShiftMask}, 372 {"SHIFT", ShiftMask},
391 {"CONTROL", ControlMask}, 373 {"CONTROL", ControlMask},
392 {"MOD1", Mod1Mask}, 374 {"MOD1", Mod1Mask},
393 {"MOD2", Mod2Mask}, 375 {"MOD2", Mod2Mask},
394 {"MOD3", Mod3Mask}, 376 {"MOD3", Mod3Mask},
395 {"MOD4", Mod4Mask}, 377 {"MOD4", Mod4Mask},
396 {"MOD5", Mod5Mask}, 378 {"MOD5", Mod5Mask},
397 {0, 0} 379 {0, 0}
398 }; 380 };
399 381
400 for (unsigned int i=0; modlist[i].string!=0; i++) { 382 for (unsigned int i=0; modlist[i].string!=0; i++) {
@@ -413,7 +395,7 @@ unsigned int Keys::getKey(const char *keystr) {
413 if (!keystr) 395 if (!keystr)
414 return 0; 396 return 0;
415 return XKeysymToKeycode(m_display, 397 return XKeysymToKeycode(m_display,
416 XStringToKeysym(keystr)); 398 XStringToKeysym(keystr));
417} 399}
418 400
419//--------- getAction ----------------- 401//--------- getAction -----------------