Author: olivier Date: 2007-05-02 05:47:02 +0000 (Wed, 02 May 2007) New Revision: 25667
Modified: xfwm4/branches/xfce_4_4/NEWS xfwm4/branches/xfce_4_4/src/keyboard.c Log: Fix modifier mask not working with all keynaps (Bug #3194) Modified: xfwm4/branches/xfce_4_4/NEWS =================================================================== --- xfwm4/branches/xfce_4_4/NEWS 2007-05-02 05:40:38 UTC (rev 25666) +++ xfwm4/branches/xfce_4_4/NEWS 2007-05-02 05:47:02 UTC (rev 25667) @@ -1,6 +1,7 @@ 4.4.2 ===== +- Fix modifier mask not working with all keynaps (Bug #3194) - Fix wrong count of key shortcut causing switch to last workspace on modifier key press if no window is focused (Bug #3191) - Fix spec file missing from the tar ball causing 'make dist' to fail Modified: xfwm4/branches/xfce_4_4/src/keyboard.c =================================================================== --- xfwm4/branches/xfce_4_4/src/keyboard.c 2007-05-02 05:40:38 UTC (rev 25666) +++ xfwm4/branches/xfce_4_4/src/keyboard.c 2007-05-02 05:47:02 UTC (rev 25667) @@ -258,8 +258,13 @@ void initModifiers (Display * dpy) { - XModifierKeymap *xmk = XGetModifierMapping (dpy); - int m, k; + XModifierKeymap *modmap; + KeySym *keymap; + unsigned int keycode; + int min_keycode; + int max_keycode; + int keysyms_per_keycode; + int i; AltMask = 0; MetaMask = 0; @@ -267,102 +272,67 @@ ScrollLockMask = 0; SuperMask = 0; HyperMask = 0; + keysyms_per_keycode = 0; + min_keycode = 0; + max_keycode = 0; - if (xmk) - { - KeyCode *c = xmk->modifiermap; - KeyCode numLockKeyCode; - KeyCode scrollLockKeyCode; - KeyCode altKeyCode; - KeyCode metaKeyCode; - KeyCode superKeyCode; - KeyCode hyperKeyCode; + XDisplayKeycodes (dpy, &min_keycode, &max_keycode); + modmap = XGetModifierMapping (dpy); + keymap = XGetKeyboardMapping (dpy, min_keycode, max_keycode - min_keycode + 1, &keysyms_per_keycode); - numLockKeyCode = XKeysymToKeycode (dpy, XK_Num_Lock); - scrollLockKeyCode = XKeysymToKeycode (dpy, XK_Scroll_Lock); - altKeyCode = XKeysymToKeycode (dpy, XK_Alt_L); - metaKeyCode = XKeysymToKeycode (dpy, XK_Meta_L); - superKeyCode = XKeysymToKeycode (dpy, XK_Super_L); - hyperKeyCode = XKeysymToKeycode (dpy, XK_Hyper_L); + if (modmap && keymap) + { + for (i = 3 * modmap->max_keypermod; i < 8 * modmap->max_keypermod; i++) + { + keycode = modmap->modifiermap[i]; + if ((keycode >= min_keycode) && (keycode <= max_keycode)) + { + int j; + KeySym *syms = keymap + (keycode - min_keycode) * keysyms_per_keycode; - if (!altKeyCode) - { - altKeyCode = XKeysymToKeycode (dpy, XK_Alt_R); - } - if (!metaKeyCode) - { - metaKeyCode = XKeysymToKeycode (dpy, XK_Meta_R); - } - if (!superKeyCode) - { - superKeyCode = XKeysymToKeycode (dpy, XK_Super_R); - } - if (!hyperKeyCode) - { - hyperKeyCode = XKeysymToKeycode (dpy, XK_Hyper_R); - } - - for (m = 0; m < 8; m++) - { - for (k = 0; k < xmk->max_keypermod; k++, c++) - { - if (*c == NoSymbol) - { - continue; - } - if (*c == numLockKeyCode) - { - NumLockMask = (1 << m); - } - if (*c == scrollLockKeyCode) - { - ScrollLockMask = (1 << m); - } - if (*c == altKeyCode) - { - AltMask = (1 << m); - } - if (*c == metaKeyCode) - { - MetaMask = (1 << m); - } - if (*c == superKeyCode) - { - SuperMask = (1 << m); - } - if (*c == hyperKeyCode) - { - HyperMask = (1 << m); - } - } - } - XFreeModifiermap (xmk); + for (j = 0; j < keysyms_per_keycode; j++) + { + if (!NumLockMask && (syms[j] == XK_Num_Lock)) + { + NumLockMask = (1 << (i / modmap->max_keypermod)); + } + else if (!ScrollLockMask && (syms[j] == XK_Scroll_Lock)) + { + ScrollLockMask = (1 << (i / modmap->max_keypermod)); + } + else if (!AltMask && ((syms[j] == XK_Alt_L) || (syms[j] == XK_Alt_R))) + { + AltMask = (1 << (i / modmap->max_keypermod)); + } + else if (!SuperMask && ((syms[j] == XK_Super_L) || (syms[j] == XK_Super_R))) + { + SuperMask = (1 << (i / modmap->max_keypermod)); + } + else if (!HyperMask && ((syms[j] == XK_Hyper_L) || (syms[j] == XK_Hyper_R))) + { + HyperMask = (1 << (i / modmap->max_keypermod)); + } + else if (!MetaMask && ((syms[j] == XK_Meta_L) || (syms[j] == XK_Meta_R))) + { + MetaMask = (1 << (i / modmap->max_keypermod)); + } + } + } + } } - if (MetaMask == AltMask) + /* Cleanup memory */ + if (modmap) { - MetaMask = 0; + XFreeModifiermap (modmap); } - if ((AltMask != 0) && (MetaMask == Mod1Mask)) + if (keymap) { - MetaMask = AltMask; - AltMask = Mod1Mask; + XFree (keymap); } - if ((AltMask == 0) && (MetaMask != 0)) - { - if (MetaMask != Mod1Mask) - { - AltMask = Mod1Mask; - } - else - { - AltMask = MetaMask; - MetaMask = 0; - } - } - + /* In case we didn't find AltMask, use Mod1Mask */ if (AltMask == 0) { AltMask = Mod1Mask; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits