diff options
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 94 |
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 { |