Xlib13/XSetModfierMapping 1/8 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.

e.g. input map is  [ 203 92 0 0] [...]
output map will be [ 92 203 0 0] [...]

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 <[email protected]>
---
 xts5/Xlib13/XSetModifierMapping.m |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/xts5/Xlib13/XSetModifierMapping.m 
b/xts5/Xlib13/XSetModifierMapping.m
index 459c91b..f1df566 100644
--- a/xts5/Xlib13/XSetModifierMapping.m
+++ b/xts5/Xlib13/XSetModifierMapping.m
@@ -171,15 +171,28 @@ XModifierKeymap   *newmap;
                        modmap->max_keypermod);
                FAIL;
        }
-       for (i = 0; i < kpm*8; i++) {
-               if (modmap->modifiermap[i] == newmap->modifiermap[i])
-                       CHECK;
-               else {
+
+        /* Returned modmap is in ascending keycode order for each modifier */
+       for (i = 0; i < kpm*8; i += kpm) {
+            int j, k;
+            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);
-- 
1.7.1

Cheers,
  Peter
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to