diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-07-05 16:18:36 +1000 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2011-05-24 13:16:54 -0700 |
commit | cbe5db71534e82caf920faa708c6c512d2382305 (patch) | |
tree | 61c068602945d52ba3a1f20089392cd830945da9 | |
parent | 3c1f9a29456b2b35bd7446b629c223a43b9a2099 (diff) |
Xlib13: fix XSetModifierMapping test 1/8.
XSetModifierMapping reports FAIL due to a different ordering of the
modifiers in the return value. The server keeps the modifiers in a
different format than used by the core protocol. The modifier map
returned by XGetModifierMapping(3) always has the keycodes in
ascending order for each modifier.
A straight input_map[i] == output_map[i] comparison is not enough if
the input map is not in order. Instead, all values for each modifier
need to be compared to find the right modifier.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
[aplattner@nvidia.com: clarification comment added]
Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r-- | xts5/Xlib13/XSetModifierMapping.m | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/xts5/Xlib13/XSetModifierMapping.m b/xts5/Xlib13/XSetModifierMapping.m index 459c91b8..54bed8a1 100644 --- a/xts5/Xlib13/XSetModifierMapping.m +++ b/xts5/Xlib13/XSetModifierMapping.m @@ -171,15 +171,33 @@ XModifierKeymap *newmap; modmap->max_keypermod); FAIL; } - for (i = 0; i < kpm*8; i++) { - if (modmap->modifiermap[i] == newmap->modifiermap[i]) - CHECK; - else { + + for (i = 0; i < kpm*8; i += kpm) { + int j, k; + + /* + * "The order of keycodes within each set is chosen arbitrarily by + * the server," so loop over all of the keycodes in both lists to + * see if any match because the server might have reordered them. + */ + for (j = i; j < i + kpm; j++) { + int found = 0; + + for (k = i; !found && k < i + kpm; k++) { + if (modmap->modifiermap[j] == newmap->modifiermap[k]) { + CHECK; + found = 1; + } + } + + if (!found) { report("Modifier map was not set correctly"); FAIL; break; - } - } + } + } + } + CHECKPASS(1+kpm*8); XFreeModifiermap(newmap); |