Fix comment

This commit is contained in:
Gawaboumga 2016-10-12 21:38:33 +02:00
parent d4e569c09e
commit eb1416f48d
1 changed files with 24 additions and 27 deletions

View File

@ -777,15 +777,10 @@ namespace Nz
X11::XCBKeySymbolsFree(keysyms); X11::XCBKeySymbolsFree(keysyms);
}); });
// Stolen from https://github.com/ehntoo/unagi/blob/master/src/key.c // Based on documentation in https://cgit.freedesktop.org/xcb/util-keysyms/tree/keysyms/keysyms.c
// Based on https://cgit.freedesktop.org/xcb/util-keysyms/tree/keysyms/keysyms.c // Mode switch = ctlr and alt gr = XCB_MOD_MASK_5
// Mode switch = ctlr ;-) and alt gr = XCB_MOD_MASK_5
/* 'col' (third parameter) is used to get the proper KeySym // The first four elements of the list are split into two groups of KeySyms.
* according to modifier (XCB doesn't provide an equivalent to
* XLookupString()).
*
* If Mode_Switch is ON we look into second group.
*/
if (state & XCB_MOD_MASK_1) if (state & XCB_MOD_MASK_1)
{ {
k0 = xcb_key_symbols_get_keysym(keysyms, keycode, 2); k0 = xcb_key_symbols_get_keysym(keysyms, keycode, 2);
@ -802,44 +797,46 @@ namespace Nz
k1 = xcb_key_symbols_get_keysym(keysyms, keycode, 1); k1 = xcb_key_symbols_get_keysym(keysyms, keycode, 1);
} }
/* If the second column does not exists use the first one. */ // If the second element of the group is NoSymbol, then the group should be treated as if the second element were the same as the first element.
if (k1 == XCB_NO_SYMBOL) if (k1 == XCB_NO_SYMBOL)
k1 = k0; k1 = k0;
/* The numlock modifier is on and the second KeySym is a keypad /* The numlock modifier is on and the second KeySym is a keypad KeySym
* KeySym */ The numlock modifier is on and the second KeySym is a keypad KeySym. In
this case, if the Shift modifier is on, or if the Lock modifier is on
and is interpreted as ShiftLock, then the first KeySym is used,
otherwise the second KeySym is used.
*/
if ((state & XCB_MOD_MASK_2) && xcb_is_keypad_key(k1)) if ((state & XCB_MOD_MASK_2) && xcb_is_keypad_key(k1))
{ {
/* The Shift modifier is on, or if the Lock modifier is on and
* is interpreted as ShiftLock, use the first KeySym */
if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT)))
return k0; return k0;
else else
return k1; return k1;
} }
/* The Shift and Lock modifers are both off, use the first KeySym */ /* The Shift and Lock modifiers are both off. In this case, the first
KeySym is used.*/
else if (!(state & XCB_MOD_MASK_SHIFT) && !(state & XCB_MOD_MASK_LOCK)) else if (!(state & XCB_MOD_MASK_SHIFT) && !(state & XCB_MOD_MASK_LOCK))
return k0; return k0;
/* The Shift modifier is off and the Lock modifier is on and is /* The Shift modifier is off, and the Lock modifier is on and is
* interpreted as CapsLock */ interpreted as CapsLock. In this case, the first KeySym is used, but
if that KeySym is lowercase alphabetic, then the corresponding
uppercase KeySym is used instead. */
else if (!(state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) else if (!(state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT)))
/* The first Keysym is used but if that KeySym is lowercase return k0;
* alphabetic, then the corresponding uppercase KeySym is used
* instead */
return k1;
/* The Shift modifier is on, and the Lock modifier is on and is /* The Shift modifier is on, and the Lock modifier is on and is
* interpreted as CapsLock */ interpreted as CapsLock. In this case, the second KeySym is used, but
if that KeySym is lowercase alphabetic, then the corresponding
uppercase KeySym is used instead.*/
else if ((state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) else if ((state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT)))
/* The second Keysym is used but if that KeySym is lowercase
* alphabetic, then the corresponding uppercase KeySym is used
* instead */
return k1; return k1;
/* The Shift modifer is on, or the Lock modifier is on and is /* The Shift modifier is on, or the Lock modifier is on and is
* interpreted as ShiftLock, or both */ interpreted as ShiftLock, or both. In this case, the second KeySym is
used. */
else if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) else if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT)))
return k1; return k1;