diff options
author | fluxgen <fluxgen> | 2002-11-13 14:35:01 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-11-13 14:35:01 (GMT) |
commit | 598ff7125d6b035e16bc854547846ca7b606e590 (patch) | |
tree | f55cbcff919fdb5a24d7603d5ced49c6e1833789 | |
parent | 353c08f1c03f884f6ac40192a96dff4c62b14eb8 (diff) | |
download | fluxbox-598ff7125d6b035e16bc854547846ca7b606e590.zip fluxbox-598ff7125d6b035e16bc854547846ca7b606e590.tar.bz2 |
determine lock masks
-rw-r--r-- | src/Keys.cc | 60 | ||||
-rw-r--r-- | src/Keys.hh | 10 |
2 files changed, 59 insertions, 11 deletions
diff --git a/src/Keys.cc b/src/Keys.cc index 84953d9..c4185b7 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.19 2002/08/28 20:25:15 fluxgen Exp $ | 22 | //$Id: Keys.cc,v 1.20 2002/11/13 14:34:24 fluxgen Exp $ |
23 | 23 | ||
24 | 24 | ||
25 | #include "Keys.hh" | 25 | #include "Keys.hh" |
@@ -126,9 +126,13 @@ Keys::t_actionstr Keys::m_actionlist[] = { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | Keys::Keys(Display *display, const char *filename): | 128 | Keys::Keys(Display *display, const char *filename): |
129 | m_capslock_mod(0), | ||
130 | m_numlock_mod(0), | ||
131 | m_scrolllock_mod(0), | ||
129 | m_abortkey(0), | 132 | m_abortkey(0), |
130 | m_display(display) | 133 | m_display(display) |
131 | { | 134 | { |
135 | determineModmap(); | ||
132 | assert(display); | 136 | assert(display); |
133 | if (filename != 0) | 137 | if (filename != 0) |
134 | load(filename); | 138 | load(filename); |
@@ -363,35 +367,35 @@ void Keys::grabKey(unsigned int key, unsigned int mod) { | |||
363 | // Grab with numlock, capslock and scrlock | 367 | // Grab with numlock, capslock and scrlock |
364 | 368 | ||
365 | //numlock | 369 | //numlock |
366 | XGrabKey(m_display, key, mod|Mod2Mask, | 370 | XGrabKey(m_display, key, mod|m_numlock_mod, |
367 | root, True, | 371 | root, True, |
368 | GrabModeAsync, GrabModeAsync); | 372 | GrabModeAsync, GrabModeAsync); |
369 | //scrolllock | 373 | //scrolllock |
370 | XGrabKey(m_display, key, mod|Mod5Mask, | 374 | XGrabKey(m_display, key, mod|m_scrolllock_mod, |
371 | root, True, | 375 | root, True, |
372 | GrabModeAsync, GrabModeAsync); | 376 | GrabModeAsync, GrabModeAsync); |
373 | //capslock | 377 | //capslock |
374 | XGrabKey(m_display, key, mod|LockMask, | 378 | XGrabKey(m_display, key, mod|m_capslock_mod, |
375 | root, True, | 379 | root, True, |
376 | GrabModeAsync, GrabModeAsync); | 380 | GrabModeAsync, GrabModeAsync); |
377 | 381 | ||
378 | //capslock+numlock | 382 | //capslock+numlock |
379 | XGrabKey(m_display, key, mod|LockMask|Mod2Mask, | 383 | XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, |
380 | root, True, | 384 | root, True, |
381 | GrabModeAsync, GrabModeAsync); | 385 | GrabModeAsync, GrabModeAsync); |
382 | 386 | ||
383 | //capslock+scrolllock | 387 | //capslock+scrolllock |
384 | XGrabKey(m_display, key, mod|LockMask|Mod5Mask, | 388 | XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, |
385 | root, True, | 389 | root, True, |
386 | GrabModeAsync, GrabModeAsync); | 390 | GrabModeAsync, GrabModeAsync); |
387 | 391 | ||
388 | //capslock+numlock+scrolllock | 392 | //capslock+numlock+scrolllock |
389 | XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask|LockMask, | 393 | XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, |
390 | root, True, | 394 | root, True, |
391 | GrabModeAsync, GrabModeAsync); | 395 | GrabModeAsync, GrabModeAsync); |
392 | 396 | ||
393 | //numlock+scrollLock | 397 | //numlock+scrollLock |
394 | XGrabKey(m_display, key, mod|Mod2Mask|Mod5Mask, | 398 | XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, |
395 | root, True, | 399 | root, True, |
396 | GrabModeAsync, GrabModeAsync); | 400 | GrabModeAsync, GrabModeAsync); |
397 | 401 | ||
@@ -628,3 +632,43 @@ Keys::t_key::~t_key() { | |||
628 | } | 632 | } |
629 | } | 633 | } |
630 | } | 634 | } |
635 | |||
636 | void Keys::determineModmap() { | ||
637 | // mask to use for modifier | ||
638 | int mods[] = { | ||
639 | ShiftMask, | ||
640 | LockMask, | ||
641 | ControlMask, | ||
642 | Mod1Mask, | ||
643 | Mod2Mask, | ||
644 | Mod3Mask, | ||
645 | Mod4Mask, | ||
646 | Mod5Mask, | ||
647 | 0 | ||
648 | }; | ||
649 | |||
650 | XModifierKeymap *map = XGetModifierMapping(m_display); | ||
651 | // find modifiers and set them | ||
652 | for (int i=0, realkey=0; i<8; ++i) { | ||
653 | for (int key=0; key<map->max_keypermod; ++key, ++realkey) { | ||
654 | |||
655 | if (map->modifiermap[realkey] == 0) | ||
656 | continue; | ||
657 | |||
658 | KeySym ks = XKeycodeToKeysym(m_display, map->modifiermap[realkey], 0); | ||
659 | |||
660 | switch (ks) { | ||
661 | case XK_Caps_Lock: | ||
662 | m_capslock_mod = mods[i]; | ||
663 | break; | ||
664 | case XK_Scroll_Lock: | ||
665 | m_scrolllock_mod = mods[i]; | ||
666 | break; | ||
667 | case XK_Num_Lock: | ||
668 | m_numlock_mod = mods[i]; | ||
669 | break; | ||
670 | } | ||
671 | } | ||
672 | } | ||
673 | XFreeModifiermap(map); | ||
674 | } | ||
diff --git a/src/Keys.hh b/src/Keys.hh index 3351668..9f24fc3 100644 --- a/src/Keys.hh +++ b/src/Keys.hh | |||
@@ -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.15 2002/08/04 15:55:13 fluxgen Exp $ | 22 | // $Id: Keys.hh,v 1.16 2002/11/13 14:35:01 fluxgen Exp $ |
23 | 23 | ||
24 | #ifndef KEYS_HH | 24 | #ifndef KEYS_HH |
25 | #define KEYS_HH | 25 | #define KEYS_HH |
@@ -165,12 +165,16 @@ private: | |||
165 | /// debug function | 165 | /// debug function |
166 | void showKeyTree(t_key *key, unsigned int w=0); | 166 | void showKeyTree(t_key *key, unsigned int w=0); |
167 | #endif //DEBUG | 167 | #endif //DEBUG |
168 | /// determine key modifier maps for caps-, num- and scrolllock | ||
169 | void determineModmap(); | ||
168 | 170 | ||
169 | struct t_actionstr{ | 171 | struct t_actionstr{ |
170 | const char *string; | 172 | const char *string; |
171 | KeyAction action; | 173 | KeyAction action; |
172 | }; | 174 | }; |
173 | 175 | ||
176 | int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers | ||
177 | |||
174 | static t_actionstr m_actionlist[]; | 178 | static t_actionstr m_actionlist[]; |
175 | 179 | ||
176 | std::vector<t_key *> m_keylist; | 180 | std::vector<t_key *> m_keylist; |