2012-04-10 12:20:27 -06:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Ran Benita <ran234@gmail.com>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2019-12-27 04:03:20 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
2014-09-06 02:29:15 -06:00
|
|
|
#include "evdev-scancodes.h"
|
2012-07-12 07:15:08 -06:00
|
|
|
#include "test.h"
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
2024-02-20 00:13:37 -07:00
|
|
|
test_init();
|
|
|
|
|
2013-03-18 15:02:35 -06:00
|
|
|
struct xkb_context *ctx = test_get_context(0);
|
2012-04-10 12:20:27 -06:00
|
|
|
struct xkb_keymap *keymap;
|
2012-07-12 07:15:08 -06:00
|
|
|
|
2012-04-10 12:20:27 -06:00
|
|
|
assert(ctx);
|
symbols: fix real/alias key merge ordering bug
Background:
The CopySymbolsDef has a comment on a couple of lines which supposedly
fixed a bug:
/*
* kt_index[i] may have been set by a previous run (if we have two
* layouts specified). Let's not overwrite it with the ONE_LEVEL
* default group if we dont even have keys for this group anyway.
*
* FIXME: There should be a better fix for this.
*/
if (!darray_empty(groupi->levels))
key->kt_index[i] = types[i];
But neither the comment nor the fix make any sense, because the kt_index
is indexed per group, i.e. each group gets its own type.
The original xkbcomp commit which added this (36fecff58) points to this
bug: https://bugzilla.redhat.com/show_bug.cgi?id=436626
which complains about -layout "ru,us" -variant "phonetic," not working
properly. And indeed when we try:
sudo ./test/interactive -l ru,us -v
the first group doesn't get any syms for the main keys.
The problem (Clearly the fix above is useless):
The ru(phonetic) map is specified using aliases, e.g. LatQ, LatW instead
of AD01, AD02, etc. When combined with another layout which uses the
real names (AD01, AD02), the symbols code should recognize they are the
same key and merge them into one KeyInfo. The current code does that,
but it doesn't catch the case where the alias was processes *before* the
real one; so we get two KeyInfo's and the later one wins. So e.g. the
ru(phonetic) symbols are ignored.
The fix:
Before adding a new KeyInfo to the keys array, always replace its name
by the real name, which avoids the entire issue. Luckily this is done
pretty late so most error messages should still show the alias name.
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-12 14:51:19 -06:00
|
|
|
keymap = test_compile_rules(ctx, "evdev", "evdev",
|
2012-09-13 02:49:02 -06:00
|
|
|
"us,il,ru,de", ",,phonetic,neo",
|
2012-07-12 07:15:08 -06:00
|
|
|
"grp:alt_shift_toggle,grp:menu_toggle");
|
2012-04-10 12:20:27 -06:00
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_e, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_l, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_l, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
2012-09-16 06:57:36 -06:00
|
|
|
/* Simple shifted level. */
|
2012-04-10 12:20:27 -06:00
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_l, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
2012-09-16 06:57:36 -06:00
|
|
|
/* Key repeat shifted and unshifted in the middle. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, DOWN, XKB_KEY_h, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_h, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_H, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_H, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_h, NEXT,
|
|
|
|
KEY_H, REPEAT, XKB_KEY_h, NEXT,
|
|
|
|
KEY_H, UP, XKB_KEY_h, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
2012-04-10 12:20:27 -06:00
|
|
|
/* Base modifier cleared on key release... */
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_O, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
/* ... But only by the keycode that set it. */
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_O, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A base modifier should only be cleared when no other key affecting
|
|
|
|
* the modifier is down.
|
|
|
|
*/
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
2013-03-08 07:31:33 -07:00
|
|
|
/*
|
|
|
|
* Two key presses from the same key (e.g. if two keyboards use the
|
|
|
|
* same xkb_state) should only be released after two releases.
|
|
|
|
*/
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
|
|
|
/* Same as above with locked modifiers. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
2012-04-10 12:20:27 -06:00
|
|
|
/* Group switching / locking. */
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_e, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_K, BOTH, XKB_KEY_hebrew_lamed, NEXT,
|
|
|
|
KEY_F, BOTH, XKB_KEY_hebrew_kaph, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
symbols: fix real/alias key merge ordering bug
Background:
The CopySymbolsDef has a comment on a couple of lines which supposedly
fixed a bug:
/*
* kt_index[i] may have been set by a previous run (if we have two
* layouts specified). Let's not overwrite it with the ONE_LEVEL
* default group if we dont even have keys for this group anyway.
*
* FIXME: There should be a better fix for this.
*/
if (!darray_empty(groupi->levels))
key->kt_index[i] = types[i];
But neither the comment nor the fix make any sense, because the kt_index
is indexed per group, i.e. each group gets its own type.
The original xkbcomp commit which added this (36fecff58) points to this
bug: https://bugzilla.redhat.com/show_bug.cgi?id=436626
which complains about -layout "ru,us" -variant "phonetic," not working
properly. And indeed when we try:
sudo ./test/interactive -l ru,us -v
the first group doesn't get any syms for the main keys.
The problem (Clearly the fix above is useless):
The ru(phonetic) map is specified using aliases, e.g. LatQ, LatW instead
of AD01, AD02, etc. When combined with another layout which uses the
real names (AD01, AD02), the symbols code should recognize they are the
same key and merge them into one KeyInfo. The current code does that,
but it doesn't catch the case where the alias was processes *before* the
real one; so we get two KeyInfo's and the later one wins. So e.g. the
ru(phonetic) symbols are ignored.
The fix:
Before adding a new KeyInfo to the keys array, always replace its name
by the real name, which avoids the entire issue. Luckily this is done
pretty late so most error messages should still show the alias name.
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-12 14:51:19 -06:00
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
2012-09-13 02:49:02 -06:00
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
2012-07-11 05:12:12 -06:00
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, FINISH));
|
2012-07-11 05:12:12 -06:00
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_Alt_L, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_Alt_L, FINISH));
|
2012-07-11 05:12:12 -06:00
|
|
|
|
2012-04-10 12:20:27 -06:00
|
|
|
/* Locked modifiers. */
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_H, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_O, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_e, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_E, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_L, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_O, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_e, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_l, NEXT,
|
|
|
|
KEY_L, BOTH, XKB_KEY_l, NEXT,
|
|
|
|
KEY_O, BOTH, XKB_KEY_o, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A key release affecting a locked modifier should clear it
|
|
|
|
* regardless of the key press.
|
|
|
|
*/
|
2012-06-29 15:07:09 -06:00
|
|
|
/* assert(test_key_seq(keymap, */
|
2012-08-01 15:40:22 -06:00
|
|
|
/* KEY_H, BOTH, XKB_KEY_h, NEXT, */
|
|
|
|
/* KEY_CAPSLOCK, DOWN, XKB_KEY_Caps_Lock, NEXT, */
|
|
|
|
/* KEY_E, BOTH, XKB_KEY_E, NEXT, */
|
|
|
|
/* KEY_L, BOTH, XKB_KEY_L, NEXT, */
|
|
|
|
/* KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT, */
|
|
|
|
/* KEY_L, BOTH, XKB_KEY_L, NEXT, */
|
|
|
|
/* KEY_CAPSLOCK, UP, XKB_KEY_Caps_Lock, NEXT, */
|
|
|
|
/* KEY_O, BOTH, XKB_KEY_o, FINISH)); */
|
2012-04-10 12:20:27 -06:00
|
|
|
|
|
|
|
/* Simple Num Lock sanity check. */
|
|
|
|
assert(test_key_seq(keymap,
|
2012-08-01 15:40:22 -06:00
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_End, NEXT,
|
|
|
|
KEY_NUMLOCK, BOTH, XKB_KEY_Num_Lock, NEXT,
|
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
|
|
|
|
KEY_KP2, BOTH, XKB_KEY_KP_2, NEXT,
|
|
|
|
KEY_NUMLOCK, BOTH, XKB_KEY_Num_Lock, NEXT,
|
|
|
|
KEY_KP2, BOTH, XKB_KEY_KP_Down, FINISH));
|
2012-04-10 12:20:27 -06:00
|
|
|
|
symbols: fix real/alias key merge ordering bug
Background:
The CopySymbolsDef has a comment on a couple of lines which supposedly
fixed a bug:
/*
* kt_index[i] may have been set by a previous run (if we have two
* layouts specified). Let's not overwrite it with the ONE_LEVEL
* default group if we dont even have keys for this group anyway.
*
* FIXME: There should be a better fix for this.
*/
if (!darray_empty(groupi->levels))
key->kt_index[i] = types[i];
But neither the comment nor the fix make any sense, because the kt_index
is indexed per group, i.e. each group gets its own type.
The original xkbcomp commit which added this (36fecff58) points to this
bug: https://bugzilla.redhat.com/show_bug.cgi?id=436626
which complains about -layout "ru,us" -variant "phonetic," not working
properly. And indeed when we try:
sudo ./test/interactive -l ru,us -v
the first group doesn't get any syms for the main keys.
The problem (Clearly the fix above is useless):
The ru(phonetic) map is specified using aliases, e.g. LatQ, LatW instead
of AD01, AD02, etc. When combined with another layout which uses the
real names (AD01, AD02), the symbols code should recognize they are the
same key and merge them into one KeyInfo. The current code does that,
but it doesn't catch the case where the alias was processes *before* the
real one; so we get two KeyInfo's and the later one wins. So e.g. the
ru(phonetic) symbols are ignored.
The fix:
Before adding a new KeyInfo to the keys array, always replace its name
by the real name, which avoids the entire issue. Luckily this is done
pretty late so most error messages should still show the alias name.
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-12 14:51:19 -06:00
|
|
|
/* Test that the aliases in the ru(phonetic) symbols map work. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_1, BOTH, XKB_KEY_1, NEXT,
|
|
|
|
KEY_Q, BOTH, XKB_KEY_Cyrillic_ya, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_1, BOTH, XKB_KEY_exclam, NEXT,
|
|
|
|
KEY_Q, BOTH, XKB_KEY_Cyrillic_YA, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_V, BOTH, XKB_KEY_Cyrillic_zhe, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_1, BOTH, XKB_KEY_1, NEXT,
|
|
|
|
KEY_V, BOTH, XKB_KEY_Cyrillic_ZHE, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_V, BOTH, XKB_KEY_Cyrillic_zhe, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, UP, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_V, BOTH, XKB_KEY_Cyrillic_ZHE, FINISH));
|
|
|
|
|
2012-10-16 08:05:34 -06:00
|
|
|
#define KS(name) xkb_keysym_from_name(name, 0)
|
2012-09-13 02:49:02 -06:00
|
|
|
|
|
|
|
/* Test that levels (1-5) in de(neo) symbols map work. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
/* Switch to the group. */
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
|
|
|
|
/* Level 1. */
|
|
|
|
KEY_1, BOTH, XKB_KEY_1, NEXT,
|
|
|
|
KEY_Q, BOTH, XKB_KEY_x, NEXT,
|
|
|
|
KEY_KP7, BOTH, XKB_KEY_KP_7, NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
|
|
|
|
/* Level 2 with Shift. */
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_1, BOTH, XKB_KEY_degree, NEXT,
|
|
|
|
KEY_Q, BOTH, XKB_KEY_X, NEXT,
|
|
|
|
KEY_KP7, BOTH, KS("U2714"), NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
/*
|
|
|
|
* XXX: de(neo) uses shift(both_capslock) which causes
|
|
|
|
* the interesting result in the next line. Since it's
|
|
|
|
* a key release, it doesn't actually lock the modifier,
|
|
|
|
* and applications by-and-large ignore the keysym on
|
|
|
|
* release(?). Is this a problem?
|
|
|
|
*/
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
|
|
|
|
/* Level 2 with the Lock modifier. */
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_6, BOTH, XKB_KEY_6, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_S, NEXT,
|
|
|
|
KEY_KP3, BOTH, XKB_KEY_KP_3, NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
|
|
|
|
/* Level 3. */
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_6, BOTH, XKB_KEY_cent, NEXT,
|
|
|
|
KEY_Q, BOTH, XKB_KEY_ellipsis, NEXT,
|
|
|
|
KEY_KP7, BOTH, KS("U2195"), NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
|
|
|
|
/* Level 4. */
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_5, BOTH, XKB_KEY_malesymbol, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_Greek_lambda, NEXT,
|
|
|
|
KEY_SPACE, BOTH, XKB_KEY_nobreakspace, NEXT,
|
|
|
|
KEY_KP8, BOTH, XKB_KEY_intersection, NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
|
2013-07-22 09:43:53 -06:00
|
|
|
/* Level 5. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
|
|
|
|
/* XXX: xkeyboard-config is borked when de(neo) is
|
|
|
|
* not the first group - not our fault. We test
|
2024-02-13 18:29:19 -07:00
|
|
|
* Level5 separately below with only de(neo). */
|
2013-07-22 09:43:53 -06:00
|
|
|
/* KEY_5, BOTH, XKB_KEY_periodcentered, NEXT, */
|
|
|
|
/* KEY_E, BOTH, XKB_KEY_Up, NEXT, */
|
|
|
|
/* KEY_SPACE, BOTH, XKB_KEY_KP_0, NEXT, */
|
|
|
|
/* KEY_KP8, BOTH, XKB_KEY_KP_Up, NEXT, */
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Shift, NEXT,
|
|
|
|
|
|
|
|
KEY_V, BOTH, XKB_KEY_p, FINISH));
|
|
|
|
|
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_rules(ctx, "evdev", "", "de", "neo", "");
|
|
|
|
assert(keymap);
|
|
|
|
assert(test_key_seq(keymap,
|
2012-09-13 02:49:02 -06:00
|
|
|
/* Level 5. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
|
2013-02-17 04:39:41 -07:00
|
|
|
KEY_5, BOTH, XKB_KEY_periodcentered, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_Up, NEXT,
|
|
|
|
KEY_SPACE, BOTH, XKB_KEY_KP_0, NEXT,
|
|
|
|
KEY_KP8, BOTH, XKB_KEY_KP_Up, NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Lock, NEXT,
|
2013-07-25 04:21:33 -06:00
|
|
|
|
|
|
|
/* Level 6. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_5, BOTH, XKB_KEY_NoSymbol, NEXT,
|
|
|
|
KEY_8, BOTH, XKB_KEY_ISO_Left_Tab, NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_Up, NEXT,
|
|
|
|
KEY_SPACE, BOTH, XKB_KEY_KP_0, NEXT,
|
|
|
|
KEY_KP8, BOTH, XKB_KEY_KP_Up, NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Lock, NEXT,
|
2013-07-25 04:21:33 -06:00
|
|
|
|
|
|
|
/* Level 7. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_5, BOTH, KS("U2221"), NEXT,
|
|
|
|
KEY_E, BOTH, XKB_KEY_Greek_LAMBDA, NEXT,
|
|
|
|
KEY_SPACE, BOTH, KS("U202F"), NEXT,
|
|
|
|
KEY_KP8, BOTH, KS("U22C2"), NEXT,
|
|
|
|
KEY_ESC, BOTH, XKB_KEY_Escape, NEXT,
|
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Lock, NEXT,
|
2013-07-25 04:21:33 -06:00
|
|
|
|
|
|
|
/* Level 8. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level5_Shift, NEXT,
|
|
|
|
KEY_CAPSLOCK, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_RIGHTSHIFT, DOWN, XKB_KEY_Shift_R, NEXT,
|
|
|
|
KEY_TAB, BOTH, XKB_KEY_ISO_Level5_Lock, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_V, BOTH, XKB_KEY_Greek_pi, NEXT,
|
2013-07-25 04:21:33 -06:00
|
|
|
KEY_RIGHTSHIFT, UP, XKB_KEY_Caps_Lock, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_V, BOTH, XKB_KEY_asciitilde, NEXT,
|
2013-07-25 04:21:33 -06:00
|
|
|
KEY_CAPSLOCK, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_V, BOTH, XKB_KEY_p, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level5_Lock, NEXT,
|
|
|
|
/* Locks Level 5. */
|
2013-07-25 04:21:33 -06:00
|
|
|
|
2017-12-03 04:04:35 -07:00
|
|
|
KEY_V, BOTH, XKB_KEY_Return, FINISH));
|
2013-07-25 04:21:33 -06:00
|
|
|
|
2012-09-13 02:49:02 -06:00
|
|
|
|
2012-09-21 07:30:01 -06:00
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_rules(ctx, "evdev", "", "us,il,ru", "",
|
|
|
|
"grp:alt_shift_toggle_bidir,grp:menu_toggle");
|
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, FINISH));
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_Alt_L, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_Alt_L, FINISH));
|
|
|
|
|
|
|
|
/* Check backwards (negative) group switching and wrapping. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_LEFTALT, BOTH, XKB_KEY_ISO_Prev_Group, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
2012-10-29 12:20:51 -06:00
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_rules(ctx, "evdev", "", "us,il,ru", "",
|
|
|
|
"grp:switch,grp:lswitch,grp:menu_toggle");
|
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
/* Test depressed group works (Mode_switch). */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
|
|
|
/* Test locked+depressed group works, with wrapping and accumulation. */
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
/* Should wrap back to first group. */
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
|
|
|
|
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
/* Two SetGroup(+1)'s should add up. */
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
|
|
|
|
KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, FINISH));
|
|
|
|
|
2014-09-11 05:08:12 -06:00
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_rules(ctx, "evdev", "", "us", "euro", "");
|
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_5, BOTH, XKB_KEY_5, NEXT,
|
|
|
|
KEY_RIGHTALT, DOWN, XKB_KEY_ISO_Level3_Shift, NEXT,
|
|
|
|
KEY_5, BOTH, XKB_KEY_EuroSign, NEXT,
|
|
|
|
KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, FINISH));
|
|
|
|
|
state: fix unbound virtual modifier bug
Recent xkeyboard-config introduced the following line in symbols/level3:
vmods = LevelThree,
However, the XKM format which xkbcomp produces for the X server can't
handle explicit virtual modifiers such as this:
https://bugs.freedesktop.org/show_bug.cgi?id=4927
So by doing the following, for example:
setxkbmap -layout de (or another 3-level layouts)
xkbcomp $DISPLAY out.xkb
xkbcomp out.xkb $DISPLAY
The modifier is lost and can't be used for switching to Level3 (see the
included test).
We, however, are affected worse by this bug when we load the out.xkb
keymap. First, the FOUR_LEVEL_ALPHABETIC key type has these entries:
map[None] = Level1;
map[Shift] = Level2;
map[Lock] = Level2;
map[LevelThree] = Level3;
[...]
Now, because the LevelThree virtual modifier is not bound to anything,
the effective mask of the "map[LevelThree]" entry is just 0. So when
the modifier state is empty (initial state), this entry is chosen, and
we get Level3, instead of failing to match any entry and getting the
default Level1.
The difference in behavior from the xserver stems from this commit:
acdad6058d52dc8a3e724dc95448300850d474f2
Which removed the entry->active field. Without bugs, this would be
correct; however, it seems in this case we should just follow the
server's behavior.
The server sets the entry->active field like so in XKBMisc.c:
/* entry is active if vmods are bound */
entry->active = (mask != 0);
The xkblib spec explains this field, but does not specify how to
initialize it. This commit does the same as above but more directly.
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-02-17 05:59:50 -07:00
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_file(ctx, "keymaps/unbound-vmod.xkb");
|
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_H, BOTH, XKB_KEY_h, NEXT,
|
|
|
|
KEY_Z, BOTH, XKB_KEY_y, NEXT,
|
|
|
|
KEY_MINUS, BOTH, XKB_KEY_ssharp, NEXT,
|
|
|
|
KEY_Z, BOTH, XKB_KEY_y, FINISH));
|
|
|
|
|
2014-10-16 16:14:57 -06:00
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
keymap = test_compile_rules(ctx, "evdev", "applealu_ansi", "us", "",
|
|
|
|
"terminate:ctrl_alt_bksp");
|
|
|
|
assert(keymap);
|
|
|
|
|
|
|
|
assert(test_key_seq(keymap,
|
|
|
|
KEY_5, BOTH, XKB_KEY_5, NEXT,
|
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
|
|
|
|
KEY_NUMLOCK, BOTH, XKB_KEY_Clear, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
|
|
|
|
KEY_LEFTSHIFT, DOWN, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_KP1, BOTH, XKB_KEY_KP_1, NEXT,
|
|
|
|
KEY_LEFTSHIFT, UP, XKB_KEY_Shift_L, NEXT,
|
|
|
|
KEY_CAPSLOCK, BOTH, XKB_KEY_Caps_Lock, NEXT,
|
|
|
|
KEY_A, BOTH, XKB_KEY_a, FINISH));
|
|
|
|
|
2012-09-21 05:44:17 -06:00
|
|
|
xkb_keymap_unref(keymap);
|
2012-04-10 12:20:27 -06:00
|
|
|
xkb_context_unref(ctx);
|
|
|
|
return 0;
|
|
|
|
}
|