aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-07-22 18:56:13 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-12-19 12:30:22 +0100
commit269a352ff493f2f41e81afa5485dec39d2d5dbf4 (patch)
treef1849a2af035c6d884c1833bc2aa3b36ebd00e2f /nx-X11
parentd610e9c3c878e39ae908f04843ed563b4669732f (diff)
downloadnx-libs-269a352ff493f2f41e81afa5485dec39d2d5dbf4.tar.gz
nx-libs-269a352ff493f2f41e81afa5485dec39d2d5dbf4.tar.bz2
nx-libs-269a352ff493f2f41e81afa5485dec39d2d5dbf4.zip
Keyboard.c: refactor keycode conversion
we'll need the remote xkb in KeyboardProc in future so let's move it up.
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Keyboard.c94
1 files changed, 56 insertions, 38 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 0b4e26953..3410e09b0 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -81,7 +81,7 @@ is" without express or implied warranty.
static int nxagentXkbGetNames(char **rules, char **model, char **layout,
char **variant, char **options);
-static void nxagentKeycodeConversionSetup(void);
+static void nxagentKeycodeConversionSetup(char *rules, char *model);
void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, char *layout, char *variant, char *options);
@@ -818,9 +818,38 @@ XkbError:
fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n");
#endif
- xkb = XkbGetKeyboard(nxagentDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ {
+ char *drules = NULL;
+ char *dmodel = NULL;
+ char *dlayout = NULL;
+ char *dvariant = NULL;
+ char *doptions = NULL;
+
+ unsigned int drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
+ &dvariant, &doptions);
+
+ #ifdef DEBUG
+ if (drulesLen && drules && dmodel)
+ {
+ fprintf(stderr, "%s: Remote: [rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n",
+ __func__, drules, dmodel, dlayout, dvariant, doptions);
+ }
+ else
+ {
+ fprintf(stderr, "%s: Failed to retrieve remote rules.\n", __func__);
+ }
+ #endif
- nxagentKeycodeConversionSetup();
+ nxagentWriteKeyboardFile(drulesLen, drules, dmodel, dlayout, dvariant, doptions);
+ nxagentKeycodeConversionSetup(drules, dmodel);
+
+ if (drules)
+ {
+ XFree(drules);
+ }
+ }
+
+ xkb = XkbGetKeyboard(nxagentDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
if (xkb && xkb->geom)
{
@@ -1609,15 +1638,8 @@ void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, c
}
}
-void nxagentKeycodeConversionSetup(void)
+void nxagentKeycodeConversionSetup(char * rules, char * model)
{
- char *drules = NULL;
- char *dmodel = NULL;
- char *dlayout = NULL;
- char *dvariant = NULL;
- char *doptions = NULL;
- unsigned int drulesLen;
-
if (nxagentOption(KeycodeConversion) == KeycodeConversionOff)
{
fprintf(stderr, "Info: Keycode conversion is off\n");
@@ -1631,28 +1653,9 @@ void nxagentKeycodeConversionSetup(void)
return;
}
- nxagentKeycodeConversion = False;
-
- drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
- &dvariant, &doptions);
-
- #ifdef DEBUG
- if (drulesLen != 0 && drules && dmodel)
- {
- fprintf(stderr, "%s: Remote: [rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n",
- __func__, drules, dmodel, dlayout, dvariant, doptions);
- }
- else
- {
- fprintf(stderr, "%s: Failed to retrieve remote rules.\n", __func__);
- }
- #endif
-
- nxagentWriteKeyboardFile(drulesLen, drules, dmodel, dlayout, dvariant, doptions);
-
- if (drules && dmodel &&
- (strcmp(drules, "evdev") == 0 ||
- strcmp(dmodel, "evdev") == 0))
+ if (rules && model &&
+ (strcmp(rules, "evdev") == 0 ||
+ strcmp(model, "evdev") == 0))
{
#ifdef DEBUG
fprintf(stderr, "%s: Activating KeyCode conversion.\n", __func__);
@@ -1663,12 +1666,13 @@ void nxagentKeycodeConversionSetup(void)
}
else
{
+ #ifdef DEBUG
+ fprintf(stderr, "%s: Deactivating KeyCode conversion.\n", __func__);
+ #endif
+
fprintf(stderr, "Info: Keycode conversion auto-determined as off\n");
- }
- if (drules)
- {
- XFree(drules);
+ nxagentKeycodeConversion = False;
}
}
@@ -1683,7 +1687,21 @@ void nxagentResetKeycodeConversion(void)
if (result != 0)
{
- nxagentKeycodeConversionSetup();
+ char *drules = NULL;
+ char *dmodel = NULL;
+ char *dlayout = NULL;
+ char *dvariant = NULL;
+ char *doptions = NULL;
+ unsigned int drulesLen;
+
+ drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
+ &dvariant, &doptions);
+
+ if (drulesLen && drules && dmodel)
+ nxagentKeycodeConversionSetup(drules, dmodel);
+
+ if (drules)
+ XFree(drules);
}
else
{