aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-13 14:35:01 (GMT)
committerfluxgen <fluxgen>2002-11-13 14:35:01 (GMT)
commit598ff7125d6b035e16bc854547846ca7b606e590 (patch)
treef55cbcff919fdb5a24d7603d5ced49c6e1833789 /src/Keys.cc
parent353c08f1c03f884f6ac40192a96dff4c62b14eb8 (diff)
downloadfluxbox-598ff7125d6b035e16bc854547846ca7b606e590.zip
fluxbox-598ff7125d6b035e16bc854547846ca7b606e590.tar.bz2
determine lock masks
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc60
1 files changed, 52 insertions, 8 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
128Keys::Keys(Display *display, const char *filename): 128Keys::Keys(Display *display, const char *filename):
129m_capslock_mod(0),
130m_numlock_mod(0),
131m_scrolllock_mod(0),
129m_abortkey(0), 132m_abortkey(0),
130m_display(display) 133m_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
636void 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}