aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-07-23 02:03:58 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-12-19 12:30:22 +0100
commit3b62184a1aaa3f8a66aab21c21d12162e7ba83df (patch)
treefe7ca002a7534c80d8fe59a017bf713b2657c94a
parentfb31220f248e82a36ae49be5c5d3abef5a791373 (diff)
downloadnx-libs-3b62184a1aaa3f8a66aab21c21d12162e7ba83df.tar.gz
nx-libs-3b62184a1aaa3f8a66aab21c21d12162e7ba83df.tar.bz2
nx-libs-3b62184a1aaa3f8a66aab21c21d12162e7ba83df.zip
Keyboard.c: improve creation of keyboard config file
It will now create better working config files. References: ArcticaProject/nx-libs#239 ArcticaProject/nx-libs#368
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index dcb58de10..9efafdf7c 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -83,7 +83,7 @@ static int nxagentXkbGetNames(char **rules, char **model, char **layout,
static void nxagentKeycodeConversionSetup(char *rules, char *model);
-void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, char *layout, char *variant, char *options);
+void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, char *variant, char *options);
#endif /* XKB */
@@ -840,7 +840,7 @@ XkbError:
}
#endif
- nxagentWriteKeyboardFile(remoteruleslen, remoterules, remotemodel, remotelayout, remotevariant, remoteoptions);
+ nxagentWriteKeyboardFile(remoterules, remotemodel, remotelayout, remotevariant, remoteoptions);
nxagentKeycodeConversionSetup(remoterules, remotemodel);
if (remoterules)
@@ -1588,10 +1588,32 @@ static int nxagentXkbGetNames(char **rules, char **model, char **layout,
return n;
}
-void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, char *layout, char *variant, char *options)
+void writeKeyboardfileData(FILE *out, char *rules, char *model, char *layout, char *variant, char *options)
{
- if (ruleslen)
+ /*
+ How to set "empty" values with setxkbmap, result of trial and error:
+ - model and layout: empty strings are accepted by setxkbmap.
+ - rules: setxkbmap will fail if rules is an empty string
+ (code will intercept in an earlier stage in that case)
+ - variant: the variant line must be omitted completely.
+ - options: prepend value with "," to override, otherwise options will be added.
+ */
+ fprintf(out, "rules=\"%s\"\n", rules);
+ fprintf(out, "model=\"%s\"\n", model ? model : "");
+ fprintf(out, "layout=\"%s\"\n", layout ? layout : "");
+ if (variant && variant[0] != '\0')
+ fprintf(out, "variant=\"%s\"\n", variant);
+ fprintf(out, "options=\",%s\"\n", options ? options : "");
+}
+
+void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, char *variant, char *options)
+{
+ if (rules && rules[0] != '\0')
{
+ #ifdef DEBUG
+ writeKeyboardfileData(stderr, rules, model, layout, variant, options);
+ #endif
+
char *sessionpath = nxagentGetSessionPath();
if (sessionpath)
{
@@ -1605,18 +1627,8 @@ void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, c
free(sessionpath);
if ((keyboard_file = fopen(keyboard_file_path, "w")))
{
- if (rules)
- fprintf(keyboard_file, "rules=\"%s\"\n", rules[0] == '\0' ? "," : rules);
- if (model)
- fprintf(keyboard_file, "model=\"%s\"\n", model[0] == '\0' ? "," : model);
- if (layout)
- fprintf(keyboard_file, "layout=\"%s\"\n", layout[0] == '\0' ? "," : layout);
- /* FIXME: this is not correct. We need to match the number of
- comma separated values between variant and layout */
- if (variant)
- fprintf(keyboard_file, "variant=\"%s\"\n", variant[0] == '\0' ? "," : variant);
- if (options)
- fprintf(keyboard_file, "options=\"%s\"\n", options[0] == '\0' ? "," : options);
+ writeKeyboardfileData(keyboard_file, rules, model, layout, variant, options);
+
fclose(keyboard_file);
fprintf(stderr, "Info: keyboard file created: '%s'\n", keyboard_file_path);
}