From c693df127f0bd8911b7621ccb75ecdd458aad3d3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 21 Mar 2017 22:33:29 +0100 Subject: Keystroke.c: detect duplicate keystroke definitions We cannot check if an action is defined twice because the viewport stuff is controlled by multiple keystrokes (arrow keys and keypad) in the default configuration. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 136f53542..402f10b91 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -341,6 +341,7 @@ static void parse_keystroke_file(Bool force) /* now we know which file to read, if any */ if (filename) { + fprintf(stderr, "Info: using keystrokes file %s\n", filename); LIBXML_TEST_VERSION xmlDoc *doc = xmlReadFile(filename, NULL, 0); if (doc) @@ -375,7 +376,29 @@ static void parse_keystroke_file(Bool force) if (bindings->type == XML_ELEMENT_NODE && strcmp((char *)bindings->name, "keystroke") == 0 && read_binding_from_xmlnode(bindings, &(map[idx]))) + { + Bool store = True; + for (int j = 0; j < idx; j++) + { + if (map[j].stroke != KEYSTROKE_NOTHING && + map[idx].keysym != NoSymbol && + map[j].keysym == map[idx].keysym && + map[j].modifierMask == map[idx].modifierMask && + map[j].modifierAltMeta == map[idx].modifierAltMeta) + { + fprintf(stderr, "Warning: ignoring keystroke '%s' (already in use by '%s')\n", + nxagentSpecialKeystrokeNames[map[idx].stroke], + nxagentSpecialKeystrokeNames[map[j].stroke]); + store = False; + break; + } + } + + if (store) idx++; + else + map[idx].stroke = KEYSTROKE_NOTHING; + } } #ifdef DEBUG fprintf(stderr, "%s: read %d keystrokes", __func__, idx); -- cgit v1.2.3