From 6f390f8207689b1b807048ef39ca956978472e32 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 3 Jan 2020 01:01:24 +0100 Subject: nxagent: remove additional keyboard handling from Reconnect.c At reconnect we check if a keyboard reset is required. If so, we are calling the corresponding code from Keyboard.c. No explicit keyboard code in Reconnect.c required. fixes ArcticaProject/nx-libs#886 --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 13 +++++++-- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 39 +++++++++++++++----------- 2 files changed, 32 insertions(+), 20 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index c6756b1cc..a79052080 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -649,7 +649,6 @@ XkbError: __func__, nxagentRemoteRules, nxagentRemoteModel, nxagentRemoteLayout, nxagentRemoteVariant, nxagentRemoteOptions); #endif - /* Only setup keycode conversion if we are NOT in clone mode */ if (nxagentKeyboard && (strcmp(nxagentKeyboard, "clone") == 0)) { SAFE_free(rules); rules = strdup(nxagentRemoteRules); @@ -657,7 +656,15 @@ XkbError: SAFE_free(layout); layout = strdup(nxagentRemoteLayout); SAFE_free(variant); variant = strdup(nxagentRemoteVariant); SAFE_free(options); options = strdup(nxagentRemoteOptions); - /* + + /* Only setup keycode conversion if we are NOT in clone mode */ + #ifdef DEBUG + fprintf(stderr, "%s: nxagentKeyboard is [%s] - disabling keycode conversion.\n", __func__, + nxagentKeyboard); + #endif + nxagentChangeOption(KeycodeConversion, KeycodeConversionOff); + + /* * when cloning we do not want X2Go to set the keyboard * via a keyboard file generated by nxagent. The defined * method for switching that off is the creation of a dir @@ -670,7 +677,6 @@ XkbError: } else { - nxagentKeycodeConversionSetup(); /* * Keyboard has always been tricky with nxagent. For that * reason X2Go offers "auto" keyboard configuration. You can @@ -688,6 +694,7 @@ XkbError: nxagentWriteKeyboardFile(nxagentRemoteRules, nxagentRemoteModel, nxagentRemoteLayout, nxagentRemoteVariant, nxagentRemoteOptions); } } + nxagentKeycodeConversionSetup(); } #ifdef DEBUG else diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 69a3011f9..5ff0c6506 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -599,29 +599,34 @@ Bool nxagentReconnectSession(void) nxagentOldKeyboard = NULL; } - if (nxagentOption(ResetKeyboardAtResume) == 1 && - (nxagentKeyboard == NULL || nxagentOldKeyboard == NULL || - strcmp(nxagentKeyboard, nxagentOldKeyboard) != 0 || - strcmp(nxagentKeyboard, "query") == 0 || - strcmp(nxagentKeyboard, "clone") == 0)) + /* Reset the keyboard only if we detect any changes. */ + if (nxagentOption(ResetKeyboardAtResume) == 1) { - if (nxagentResetKeyboard() == 0) + if (nxagentKeyboard == NULL || nxagentOldKeyboard == NULL || + strcmp(nxagentKeyboard, nxagentOldKeyboard) != 0 || + strcmp(nxagentKeyboard, "query") == 0 || + strcmp(nxagentKeyboard, "clone") == 0) { - #ifdef WARNING - if (nxagentVerbose == 1) + if (nxagentResetKeyboard() == 0) { - fprintf(stderr, "nxagentReconnectSession: Failed to reset keyboard device.\n"); - } - #endif + #ifdef WARNING + if (nxagentVerbose == 1) + { + fprintf(stderr, "%s: Failed to reset keyboard device.\n", __func__); + } + #endif - failedStep = WINDOW_STEP; + failedStep = WINDOW_STEP; - goto nxagentReconnectError; + goto nxagentReconnectError; + } + } + else + { + #ifdef DEBUG + fprintf(stderr, "%s: keyboard unchanged - skipping keyboard reset.\n", __func__); + #endif } - } - else - { - nxagentKeycodeConversionSetup(); } nxagentXkbState.Initialized = 0; -- cgit v1.2.3