[PATCH XTS] Xlib13: fix XSetModfierMapping test 1/8.

Peter Hutterer peter.hutterer at who-t.net
Sun Jul 4 23:23:29 PDT 2010


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 <peter.hutterer at who-t.net>
---
 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


More information about the xorg-devel mailing list