fix the new modifier key code..
This commit is contained in:
parent
7e946f68d9
commit
88d00a0120
1 changed files with 18 additions and 11 deletions
|
@ -27,7 +27,7 @@
|
||||||
Mod2Mask (1<<4), Mod3Mask (1<<5), Mod4Mask (1<<6), Mod5Mask (1<<7)
|
Mod2Mask (1<<4), Mod3Mask (1<<5), Mod4Mask (1<<6), Mod5Mask (1<<7)
|
||||||
*/
|
*/
|
||||||
#define NUM_MASKS 8
|
#define NUM_MASKS 8
|
||||||
#define ALL_MASKS 0xf /* an or'ing of all 8 keyboard masks */
|
#define ALL_MASKS 0xff /* an or'ing of all 8 keyboard masks */
|
||||||
|
|
||||||
/* Get the bitflag for the n'th modifier mask */
|
/* Get the bitflag for the n'th modifier mask */
|
||||||
#define nth_mask(n) (1 << n)
|
#define nth_mask(n) (1 << n)
|
||||||
|
@ -40,16 +40,22 @@ static guchar modkeys_keys[OB_MODKEY_NUM_KEYS];
|
||||||
|
|
||||||
void modkeys_startup(gboolean reconfigure)
|
void modkeys_startup(gboolean reconfigure)
|
||||||
{
|
{
|
||||||
/* keycodes for the modifier keys which will be bound to the masks */
|
KeySym *keymap;
|
||||||
gint i, j, k;
|
gint i, j, k;
|
||||||
|
gint min_keycode, max_keycode, keysyms_per_keycode;
|
||||||
modmap = XGetModifierMapping(ob_display);
|
|
||||||
g_assert(modmap->max_keypermod > 0);
|
|
||||||
|
|
||||||
/* reset the keys to not be bound to any masks */
|
/* reset the keys to not be bound to any masks */
|
||||||
for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
|
for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
|
||||||
modkeys_keys[i] = 0;
|
modkeys_keys[i] = 0;
|
||||||
|
|
||||||
|
modmap = XGetModifierMapping(ob_display);
|
||||||
|
g_assert(modmap->max_keypermod > 0);
|
||||||
|
|
||||||
|
XDisplayKeycodes(ob_display, &min_keycode, &max_keycode);
|
||||||
|
keymap = XGetKeyboardMapping(ob_display, min_keycode,
|
||||||
|
max_keycode - min_keycode + 1,
|
||||||
|
&keysyms_per_keycode);
|
||||||
|
|
||||||
/* go through each of the modifier masks (eg ShiftMask, CapsMask...) */
|
/* go through each of the modifier masks (eg ShiftMask, CapsMask...) */
|
||||||
for (i = 0; i < NUM_MASKS; ++i) {
|
for (i = 0; i < NUM_MASKS; ++i) {
|
||||||
/* go through each keycode that is bound to the mask */
|
/* go through each keycode that is bound to the mask */
|
||||||
|
@ -58,15 +64,16 @@ void modkeys_startup(gboolean reconfigure)
|
||||||
/* get a keycode that is bound to the mask (i) */
|
/* get a keycode that is bound to the mask (i) */
|
||||||
KeyCode keycode = modmap->modifiermap[i*modmap->max_keypermod + j];
|
KeyCode keycode = modmap->modifiermap[i*modmap->max_keypermod + j];
|
||||||
/* go through each keysym bound to the given keycode */
|
/* go through each keysym bound to the given keycode */
|
||||||
for (k = 0; ; ++k) {
|
for (k = 0; k < keysyms_per_keycode; ++k) {
|
||||||
sym = XKeycodeToKeysym(ob_display, keycode, k);
|
sym = keymap[(keycode-min_keycode) * keysyms_per_keycode + k];
|
||||||
if (sym == NoSymbol) break;
|
if (sym != NoSymbol) {
|
||||||
|
/* bind the key to the mask (e.g. Alt_L => Mod1Mask) */
|
||||||
/* bind the key to the mask (e.g. Alt_L => Mod1Mask) */
|
set_modkey_mask(nth_mask(i), sym);
|
||||||
set_modkey_mask(nth_mask(i), sym);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XFree(keymap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modkeys_shutdown(gboolean reconfigure)
|
void modkeys_shutdown(gboolean reconfigure)
|
||||||
|
|
Loading…
Reference in a new issue