aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-03-21 22:33:29 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-04-03 21:28:10 +0200
commitc693df127f0bd8911b7621ccb75ecdd458aad3d3 (patch)
tree260e6a24c50558af379c246435953dff325a727b
parent40f03399c706bbf00f2055a10c4b1bb3b49063a8 (diff)
downloadnx-libs-c693df127f0bd8911b7621ccb75ecdd458aad3d3.tar.gz
nx-libs-c693df127f0bd8911b7621ccb75ecdd458aad3d3.tar.bz2
nx-libs-c693df127f0bd8911b7621ccb75ecdd458aad3d3.zip
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.
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keystroke.c23
1 files changed, 23 insertions, 0 deletions
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);