From d7a49834ea4b3fbe9703cdd408b1a4b4a36a1636 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:38:25 +0100 Subject: nxcomp/Children.cpp: display dialog text in output This ensures the dialog text is visible in the log which is useful when the dialog display tool (nxclient, nxdialog, ...) fails or cannot be found. Fixes ArcticaProject/nx-libs#915 --- nxcomp/src/Children.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index 036cffa95..40eccd9da 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -216,7 +216,15 @@ int NXTransDialog(const char *caption, const char *message, UnsetEnv("LD_LIBRARY_PATH"); - for (int i = 0; i < 2; i++) + if (!pulldown) + { + cerr << "Info: Upcoming dialog:\n" + << "/-----------------------------------------------------------\n" + << caption << ":\n" + << message << "\n" + << "\\-----------------------------------------------------------\n"; + } + { if (local != 0) { -- cgit v1.2.3 From 90ff3d0256327bd4097568740a0ece24ca722989 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:44:33 +0100 Subject: nxcomp/Children.cpp: add macro checks around some log/stderr prints This helps no flooding the output with (double) messages. --- nxcomp/src/Children.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index 40eccd9da..842db7fe5 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -257,15 +257,17 @@ int NXTransDialog(const char *caption, const char *message, } } - #ifdef WARNING + #ifdef TEST *logofs << "NXTransDialog: WARNING! Couldn't start '" << command << "'. " << "Error is " << EGET() << " '" << ESTR() << "'.\n" << logofs_flush; #endif + #ifdef WARNING cerr << "Warning" << ": Couldn't start '" << command << "'. Error is " << EGET() << " '" << ESTR() << "'.\n"; + #endif // // Retry by looking for the default name @@ -302,13 +304,15 @@ int NXTransDialog(const char *caption, const char *message, // FIXME: check if strncat would be better here snprintf(newPath + newLength, DEFAULT_STRING_LIMIT - newLength, "%s", oldPath); - #ifdef WARNING + #ifdef TEST *logofs << "NXTransDialog: WARNING! Trying with path '" << newPath << "'.\n" << logofs_flush; #endif + #ifdef WARNING cerr << "Warning" << ": Trying with path '" << newPath << "'.\n"; + #endif // // Solaris doesn't seem to have -- cgit v1.2.3 From 31beb51df199d1fec9cec2afe2c7c3684728bc2a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:48:28 +0100 Subject: nxcomp/Children.cpp: also try searching nxdialog, not only nxclient --- nxcomp/src/Children.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index 842db7fe5..abfcbf2f9 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -225,6 +225,7 @@ int NXTransDialog(const char *caption, const char *message, << "\\-----------------------------------------------------------\n"; } + for (int i = 0; i < 4; i++) { if (local != 0) { @@ -274,11 +275,17 @@ int NXTransDialog(const char *caption, const char *message, // in the default NX path. // - if (i == 0) + if (i == 0 || i == 2) { - strcpy(command, "nxclient"); + } + else if (i == 1 || i == 3) + { + strcpy(command, "nxdialog"); + } + if (i == 2) + { char newPath[DEFAULT_STRING_LIMIT]; strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); @@ -332,7 +339,18 @@ int NXTransDialog(const char *caption, const char *message, setenv("PATH", newPath, 1); #endif + } + else + { + #ifdef TEST + *logofs << "NXTransDialog: WARNING! Trying with command '" + << command << "'.\n" << logofs_flush; + #endif + #ifdef WARNING + cerr << "Warning" << ": Trying with command '" << command + << "'.\n"; + #endif } } -- cgit v1.2.3 From 2e3fe61d11b606ab5be561e30649984240e90954 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:48:55 +0100 Subject: nxcomp/Children.cpp: reformat code drop some superflous empty lines to make code more compact. --- nxcomp/src/Children.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index abfcbf2f9..829c6fbad 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -291,21 +291,16 @@ int NXTransDialog(const char *caption, const char *message, strcpy(newPath, "/usr/NX/bin:/opt/NX/bin:/usr/local/NX/bin:"); #ifdef __APPLE__ - // FIXME: missing length limitation! strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); - #endif #ifdef __CYGWIN32__ - // FIXME: missing length limitation! strcat(newPath, ".:"); - #endif int newLength = strlen(newPath); - char *oldPath = getenv("PATH"); // FIXME: check if strncat would be better here @@ -327,17 +322,11 @@ int NXTransDialog(const char *caption, const char *message, // #ifdef __sun - char newEnv[DEFAULT_STRING_LIMIT + 5]; - sprintf(newEnv,"PATH=%s", newPath); - putenv(newEnv); - #else - setenv("PATH", newPath, 1); - #endif } else -- cgit v1.2.3 From 1338cffc940eb3c3291ee8bea098f79545e969da Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:49:21 +0100 Subject: nxcomp/Children.cpp: print a message if the dialog could not be displayed --- nxcomp/src/Children.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index 829c6fbad..2e89f2e68 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -343,6 +343,15 @@ int NXTransDialog(const char *caption, const char *message, } } + #ifdef TEST + *logofs << "NXTransDialog: WARNING! Could not display dialog.\n" + << logofs_flush; + #endif + + #ifdef WARNING + cerr << "Warning" << ": Could not display dialog.\n"; + #endif + // // Hopefully useless. // -- cgit v1.2.3 From 5dcb19b3d7ae4910f3d3cd1015b0840e7d4bf11d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 28 Feb 2021 21:50:48 +0100 Subject: nxagent: fix RESIZE dialog text to not end with a linefeed It was the only dialog that had a linefeed a the end. --- nx-X11/programs/Xserver/hw/nxagent/Dialog.h | 4 +--- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.h b/nx-X11/programs/Xserver/hw/nxagent/Dialog.h index b11df5045..d0295f81c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.h @@ -192,9 +192,7 @@ by dragging the desktop with the mouse while pressing\n\ Ctrl+Alt or use the keystrokes listed below. Press\n\ %s again to return to the desktop resize mode.\n\ \n\ -Use these keystrokes to navigate:\n\ -%s\ -" +Use these keystrokes to navigate:%s" #define DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE "ok" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 9a7c1cd65..aff2e56ab 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -513,13 +513,13 @@ char *nxagentFindMatchingKeystrokes(char *name) { char *tmp; char *tmp1 = nxagentGetSingleKeystrokeString(cur); - if (-1 == asprintf(&tmp, "%s %-*s : %s\n", res, maxlen, + if (-1 == asprintf(&tmp, "%s\n %-*s : %s", res, maxlen, nxagentSpecialKeystrokeNames[cur->stroke], tmp1)) { SAFE_free(tmp1); #ifdef TEST - fprintf(stderr, "%s: returning incomplete result:\n%s", __func__, res); + fprintf(stderr, "%s: returning incomplete result:%s\n", __func__, res); #endif return res; } -- cgit v1.2.3