Commit c693df12 authored by Ulrich Sibiller's avatar Ulrich Sibiller

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.
parent 40f03399
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment