Unverified Commit 60e0566d authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/fix_keyconv_on_reconnect' into 3.6.x

parents cf24c658 6f390f82
...@@ -687,7 +687,20 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -687,7 +687,20 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{ {
SAFE_free(nxagentKeyboard); SAFE_free(nxagentKeyboard);
if (nxagentX2go && strcmp(argv[i], "null/null") == 0)
{
#ifdef TEST
fprintf(stderr, "%s: changing nxagentKeyboard from [null/null] to [clone].\n", __func__);
#endif
SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup("clone");
}
else
{
nxagentKeyboard = strdup(argv[i]); nxagentKeyboard = strdup(argv[i]);
}
if (nxagentKeyboard == NULL) if (nxagentKeyboard == NULL)
{ {
FatalError("malloc failed"); FatalError("malloc failed");
...@@ -1489,27 +1502,36 @@ static void nxagentParseOptionString(char *string) ...@@ -1489,27 +1502,36 @@ static void nxagentParseOptionString(char *string)
char *option = NULL; char *option = NULL;
/* /*
* we must not modify string, but strtok will insert \0. So let's
* work with a copy
*/
char *dup = strdup(string);
/*
* Remove the port specification. * Remove the port specification.
*/ */
char *delimiter = rindex(string, ':'); char *delimiter = rindex(dup, ':');
if (delimiter) if (delimiter)
{ {
*delimiter = 0; #ifdef DEBUG
fprintf(stderr, "%s: stripping port specification [%s]\n", __func__, delimiter);
#endif
*delimiter = '\0';
} }
else else
{ {
fprintf(stderr, "Warning: Option file doesn't contain a port specification.\n"); fprintf(stderr, "Warning: Option file doesn't contain a port specification.\n");
} }
while ((option = strtok(option ? NULL : string, ","))) while ((option = strtok(option ? NULL : dup, ",")))
{ {
delimiter = rindex(option, '='); delimiter = rindex(option, '=');
if (delimiter) if (delimiter)
{ {
*delimiter = 0; *delimiter = '\0';
value = delimiter + 1; value = delimiter + 1;
} }
else else
...@@ -1519,6 +1541,31 @@ static void nxagentParseOptionString(char *string) ...@@ -1519,6 +1541,31 @@ static void nxagentParseOptionString(char *string)
nxagentParseSingleOption(option, value); nxagentParseSingleOption(option, value);
} }
SAFE_free(dup);
}
char *nxagentSkipNXMarker(char *string)
{
if (strncasecmp(string, "nx/nx,", 6) == 0 ||
strncasecmp(string, "nx/nx:", 6) == 0)
{
#ifdef DEBUG
fprintf(stderr, "%s: skipping [%6.6s]\n", __func__, string);
#endif
return string + 6;
}
else if (strncasecmp(string, "nx,", 3) == 0 ||
strncasecmp(string, "nx:", 3) == 0)
{
#ifdef DEBUG
fprintf(stderr, "%s: skipping [%3.3s]\n", __func__, string);
#endif
return string + 3;
}
else
{
return string;
}
} }
void nxagentProcessOptions(char * string) void nxagentProcessOptions(char * string)
...@@ -1533,15 +1580,10 @@ void nxagentProcessOptions(char * string) ...@@ -1533,15 +1580,10 @@ void nxagentProcessOptions(char * string)
/* if the "filename" starts with an nx marker treat it /* if the "filename" starts with an nx marker treat it
as an option _string_ instead of a filename */ as an option _string_ instead of a filename */
if (strncasecmp(string, "nx/nx,", 6) == 0 || char *skipped = nxagentSkipNXMarker(string);
strncasecmp(string, "nx/nx:", 6) == 0) if (skipped != string)
{
nxagentParseOptionString(string + 6);
}
else if (strncasecmp(string, "nx,", 3) == 0 ||
strncasecmp(string, "nx:", 3) == 0)
{ {
nxagentParseOptionString(string + 3); nxagentParseOptionString(skipped);
} }
else else
{ {
...@@ -1650,9 +1692,13 @@ void nxagentProcessOptionsFile(char * filename) ...@@ -1650,9 +1692,13 @@ void nxagentProcessOptionsFile(char * filename)
for (offset = 0; (offset < sizeOfFile) && (data[offset] != '\n'); offset++); for (offset = 0; (offset < sizeOfFile) && (data[offset] != '\n'); offset++);
data[offset] = 0; data[offset] = '\0';
#ifdef DEBUG
fprintf(stderr, "%s: first line of options file [%s]\n", __func__, data);
#endif
nxagentParseOptionString(data); nxagentParseOptionString(nxagentSkipNXMarker(data));
nxagentProcessOptionsFileExit: nxagentProcessOptionsFileExit:
......
...@@ -458,15 +458,6 @@ Bool nxagentReconnectSession(void) ...@@ -458,15 +458,6 @@ Bool nxagentReconnectSession(void)
nxagentProcessOptions(nxagentOptionsFilenameOrString); nxagentProcessOptions(nxagentOptionsFilenameOrString);
if (nxagentKeyboard && (strcmp(nxagentKeyboard, "null/null") == 0))
{
#ifdef TEST
fprintf(stderr, "nxagentReconnect: changing nxagentKeyboard from [null/null] to [clone].\n");
#endif
SAFE_free(nxagentKeyboard);
nxagentKeyboard = strdup("clone");
}
if (nxagentReconnectDisplay(reconnectLossyLevel[DISPLAY_STEP]) == 0) if (nxagentReconnectDisplay(reconnectLossyLevel[DISPLAY_STEP]) == 0)
{ {
...@@ -608,18 +599,20 @@ Bool nxagentReconnectSession(void) ...@@ -608,18 +599,20 @@ Bool nxagentReconnectSession(void)
nxagentOldKeyboard = NULL; nxagentOldKeyboard = NULL;
} }
if (nxagentOption(ResetKeyboardAtResume) == 1 && /* Reset the keyboard only if we detect any changes. */
(nxagentKeyboard == NULL || nxagentOldKeyboard == NULL || if (nxagentOption(ResetKeyboardAtResume) == 1)
{
if (nxagentKeyboard == NULL || nxagentOldKeyboard == NULL ||
strcmp(nxagentKeyboard, nxagentOldKeyboard) != 0 || strcmp(nxagentKeyboard, nxagentOldKeyboard) != 0 ||
strcmp(nxagentKeyboard, "query") == 0 || strcmp(nxagentKeyboard, "query") == 0 ||
strcmp(nxagentKeyboard, "clone") == 0)) strcmp(nxagentKeyboard, "clone") == 0)
{ {
if (nxagentResetKeyboard() == 0) if (nxagentResetKeyboard() == 0)
{ {
#ifdef WARNING #ifdef WARNING
if (nxagentVerbose == 1) if (nxagentVerbose == 1)
{ {
fprintf(stderr, "nxagentReconnectSession: Failed to reset keyboard device.\n"); fprintf(stderr, "%s: Failed to reset keyboard device.\n", __func__);
} }
#endif #endif
...@@ -630,7 +623,10 @@ Bool nxagentReconnectSession(void) ...@@ -630,7 +623,10 @@ Bool nxagentReconnectSession(void)
} }
else else
{ {
nxagentKeycodeConversionSetup(); #ifdef DEBUG
fprintf(stderr, "%s: keyboard unchanged - skipping keyboard reset.\n", __func__);
#endif
}
} }
nxagentXkbState.Initialized = 0; nxagentXkbState.Initialized = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment