aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs')
-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);
}