From 29be5cc07bdaa22086da6d0607a1c86b07e95875 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Sat, 2 Jul 2016 21:49:10 +0000 Subject: {nx-X11/programs/Xserver/hw/nxagent/{Args.c,Options.{c,h}},nxcomp/{Loop,Misc}.cpp}: add tolerancechecks parameter as an nx/nx option and ReconnectTolerance as an nxagentOption. --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 76 ++++++++++++++++++++++++++++ nx-X11/programs/Xserver/hw/nxagent/Options.c | 2 + nx-X11/programs/Xserver/hw/nxagent/Options.h | 17 +++++++ nxcomp/Loop.cpp | 3 +- nxcomp/Misc.cpp | 4 +- 5 files changed, 100 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 832595786..9e54c0073 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1405,6 +1405,82 @@ static void nxagentParseOptions(char *name, char *value) return; } + else if (!strcmp(name, "tolerancechecks")) + { + if (strcmp(value, "strict") == 0) + { + nxagentChangeOption(ReconnectTolerance, ToleranceChecksStrict); + } + else if (strcmp(value, "safe") == 0) + { + nxagentChangeOption(ReconnectTolerance, ToleranceChecksSafe); + } + else if (strcmp(value, "risky") == 0) + { + nxagentChangeOption(ReconnectTolerance, ToleranceChecksRisky); + } + else if (strcmp(value, "none") == 0) + { + nxagentChangeOption(ReconnectTolerance, ToleranceChecksBypass); + } + else + { + /* + * Check for a matching integer. Or any integer, really. + */ + long tolerance_parse = 0; + + errno = 0; + tolerance_parse = strtol(value, NULL, 10); + + if ((errno) && (0 == tolerance_parse)) + { + fprintf(stderr, "nxagentParseOptions: Unable to convert value [%s] of option [%s]. " + "Ignoring option.\n", + validateString(value), validateString(name)); + + return; + } + + if ((long) UINT_MAX < tolerance_parse) + { + tolerance_parse = UINT_MAX; + + fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + "out of range, clamped to [%u].\n", + validateString(value), validateString(name), tolerance_parse); + } + + if (0 > tolerance_parse) + { + tolerance_parse = 0; + + fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + "out of range, clamped to [%u].\n", + validateString(value), validateString(name), tolerance_parse); + } + + #ifdef TEST + switch (tolerance_parse) { + case ToleranceChecksStrict: + case ToleranceChecksSafe: + case ToleranceChecksRisky: + case ToleranceChecksBypass: + break; + default: + fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of " + "option [%s] unknown, will be mapped to " + "\"Bypass\" [%u] value internally.\n", + validateString(value), validateString(name), + (unsigned int)ToleranceChecksBypass); + } + #endif + + nxagentChangeOption(ReconnectTolerance, tolerance_parse); + } + + return; + } else { #ifdef DEBUG diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index 0a894f9a4..978f3ab95 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -166,6 +166,8 @@ void nxagentInitOptions() nxagentOptions.Xinerama = 1; nxagentOptions.SleepTime = DEFAULT_SLEEP_TIME; + + nxagentOptions.ReconnectTolerance = DEFAULT_TOLERANCE; } /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.h b/nx-X11/programs/Xserver/hw/nxagent/Options.h index df6f8b65b..20616a90b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.h @@ -67,6 +67,17 @@ typedef enum _ClientOsType } ClientOsType; +typedef enum _ToleranceChecksMode +{ + ToleranceChecksStrict = 0, + ToleranceChecksSafe = 1, + ToleranceChecksRisky = 2, + ToleranceChecksBypass = 3 +} ToleranceChecksMode; + + +#define DEFAULT_TOLERANCE ToleranceChecksStrict + /* * Set of options affecting agent operations. */ @@ -414,6 +425,12 @@ typedef struct _AgentOptions unsigned int SleepTime; + /* + * Tolerance - tightens or loosens reconnect checks. + */ + + ToleranceChecksMode ReconnectTolerance; + } AgentOptionsRec; typedef AgentOptionsRec *AgentOptionsPtr; diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp index c0951ee19..10026967a 100644 --- a/nxcomp/Loop.cpp +++ b/nxcomp/Loop.cpp @@ -9063,7 +9063,8 @@ int ParseEnvironmentOptions(const char *env, int force) strcasecmp(name, "clipboard") == 0 || strcasecmp(name, "streaming") == 0 || strcasecmp(name, "backingstore") == 0 || - strcasecmp(name, "sleep") == 0) + strcasecmp(name, "sleep") == 0 || + strcasecmp(name, "tolerancechecks") == 0) { #ifdef DEBUG *logofs << "Loop: Ignoring agent option '" << name diff --git a/nxcomp/Misc.cpp b/nxcomp/Misc.cpp index ca062ebed..c94dc8b9c 100644 --- a/nxcomp/Misc.cpp +++ b/nxcomp/Misc.cpp @@ -325,7 +325,9 @@ shadowmode=s\n\ defer=n\n\ tile=s\n\ menu=n\n\ -sleep=n These options are interpreted by the NX agent. They\n\ +sleep=n\n\ +tolerancecehcks=s\n\ + These options are interpreted by the NX agent. They\n\ are ignored by the proxy.\n\ \n\ Environment:\n\ -- cgit v1.2.3 From 6effea543d04150ca0d5aa6d4b5edadfd320ea17 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Tue, 28 Jun 2016 23:51:14 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: use new ReconnectTolerance nxagentOption in nxagentCheckForDefaultDepthCompatibility() and modify behavior based on this value. Recognized values: - Strict means that the old and new default depth values must match exactly. - Safe or Risky means that the default depth values might differ, but the new default depth value must be at least as high as the former default depth value. This is recommended, because it allows clients with a higher default depth value to still connect, but not lose functionality. - Bypass or higher means that all of these checks are essentially deactivated. This is probably a very bad idea. Note that the default ReconnectTolerance value is still Strict. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 43 +++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 5943fbf77..ea58437ea 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2175,10 +2175,40 @@ void nxagentDisconnectDisplay(void) static int nxagentCheckForDefaultDepthCompatibility() { + /* + * Depending on the (reconnect) tolerance checks value, this + * function checks stricter or looser: + * - Strict means that the old and new default depth values + * must match exactly. + * - Safe or Risky means that the default depth values might differ, + * but the new default depth value must be at least as + * high as the former default depth value. This is + * recommended, because it allows clients with a + * higher default depth value to still connect, but + * not lose functionality. + * - Bypass or higher means that all of these checks are + * essentially deactivated. This is probably a very + * bad idea. + */ + int dDepth; dDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); + const unsigned int tolerance = nxagentOption(ReconnectTolerance); + + if (ToleranceChecksBypass <= tolerance) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForDefaultDepthCompatibility: WARNING! Not proceeding with any checks, " + "because tolerance [%u] higher than or equal [%u]. New default depth value " + "is [%d], former default depth value is [%d].\n", tolerance, + ToleranceChecksBypass, dDepth, nxagentDefaultDepthRecBackup); + #endif + + return 1; + } + if (nxagentDefaultDepthRecBackup == dDepth) { #ifdef TEST @@ -2188,11 +2218,22 @@ static int nxagentCheckForDefaultDepthCompatibility() return 1; } + else if ((ToleranceChecksSafe <= tolerance) && (nxagentDefaultDepthRecBackup < dDepth)) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForDefaultDepthCompatibility: WARNING! New default depth [%d] " + "higher than the old default depth [%d] at tolerance [%u].\n", dDepth, + nxagentDefaultDepthRecBackup, tolerance); + #endif + + return 1; + } else { #ifdef WARNING fprintf(stderr, "nxagentCheckForDefaultDepthCompatibility: WARNING! New default depth [%d] " - "doesn't match with old default depth [%d].\n", dDepth, nxagentDefaultDepthRecBackup); + "doesn't match with old default depth [%d] at tolerance [%u].\n", dDepth, + nxagentDefaultDepthRecBackup, tolerance); #endif return 0; -- cgit v1.2.3 From bb9b50bfcf9c656367b7a9b6b5c73fea6c21a718 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Tue, 28 Jun 2016 23:54:17 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: use new ReconnectTolerance nxagentOption value in nxagentCheckForDepthsCompatibility() and modify behavior based on this value. Recognized values: - Strict means that the number of old and new depths must match exactly and every old depth value must be available in the new depth array. - Safe means that the number of depths might diverge, but all former depth must also be included in the new depth array. This is recommended, because it allows clients with more depths to still connect, but not lose functionality. - Risky means that the new depths array is allowed to be smaller than the old depths array, but at least one depth value must be included in both. This is potentially unsafe. - Bypass or higher means that all of these checks are essentially deactivated. This is a very bad idea. Note that the default ReconnectTolerance value is still Strict. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 142 ++++++++++++++++++++++----- 1 file changed, 118 insertions(+), 24 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index ea58437ea..aa8ab26d1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -45,6 +45,7 @@ is" without express or implied warranty. #include #include #include +#include #include #include @@ -178,7 +179,7 @@ static void nxagentInitDepths(void); static void nxagentInitPixmapFormats(void); static int nxagentCheckForDefaultDepthCompatibility(void); -static int nxagentCheckForDepthsCompatibility(int flexibility); +static int nxagentCheckForDepthsCompatibility(void); static int nxagentCheckForPixmapFormatsCompatibility(void); static int nxagentInitAndCheckVisuals(int flexibility); static int nxagentCheckForColormapsCompatibility(int flexibility); @@ -2240,69 +2241,162 @@ static int nxagentCheckForDefaultDepthCompatibility() } } -static int nxagentCheckForDepthsCompatibility(int flexibility) +static int nxagentCheckForDepthsCompatibility() { - int i, j; - int matched; - int compatible; + /* + * Depending on the (reconnect) tolerance checks value, this + * function checks stricter or looser: + * - Strict means that the number of old and new depths must + * match exactly and every old depth value must be + * available in the new depth array. + * - Safe means that the number of depths might diverge, + * but all former depth must also be included in the + * new depth array. This is recommended, because + * it allows clients with more depths to still + * connect, but not lose functionality. + * - Risky means that the new depths array is allowed to be + * smaller than the old depths array, but at least + * one depth value must be included in both. + * This is potentially unsafe. + * - Bypass or higher means that all of these checks are + * essentially deactivated. This is a very bad idea. + */ + + const unsigned int tolerance = nxagentOption(ReconnectTolerance); + + if (ToleranceChecksBypass <= tolerance) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! Not proceeding with any checks, " + "because tolerance [%u] higher than or equal [%u]. Number of newly available depths " + "is [%d], number of old depths is [%d].\n", tolerance, ToleranceChecksBypass, + nxagentNumDepths, nxagentNumDepthsRecBackup); + #endif + + return 1; + } - if (nxagentNumDepths != nxagentNumDepthsRecBackup) + if ((ToleranceChecksStrict == tolerance) && (nxagentNumDepths != nxagentNumDepthsRecBackup)) { #ifdef WARNING - fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! Number of new available depths [%d] " - "doesn't match with old depths [%d].\n", nxagentNumDepths, - nxagentNumDepthsRecBackup); + fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! No tolerance allowed and " + "number of new available depths [%d] doesn't match with number of old " + "depths [%d].\n", nxagentNumDepths, + nxagentNumDepthsRecBackup); #endif return 0; } - compatible = 1; + if ((ToleranceChecksSafe == tolerance) && (nxagentNumDepths < nxagentNumDepthsRecBackup)) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! Tolerance [%u] not " + "high enough and number of new available depths [%d] " + "lower than number of old depths [%d].\n", tolerance, + nxagentNumDepths, nxagentNumDepthsRecBackup); + #endif + + return 0; + } + + /* + * By now the tolerance is either: + * - Strict and both depth numbers match + * - Safe and: + * o the number of old and new depths matches exactly, or + * o the number of old depths is lower than the number + * of new depths + * - Risky + */ + + bool compatible = true; + bool one_match = false; + bool matched = false; + int total_matches = 0; - for (i = 0; i < nxagentNumDepths; i++) + /* + * FIXME: within this loop, we try to match all "new" depths + * against the "old" depths. Depending upon the flexibility + * value, either all "new" depths must have a corresponding + * counterpart in the "old" array, or at least one value + * must be included in both. + * Is this safe enough though? + * Shouldn't we better try to match entries in the "old" + * depths array against the "new" depths array, such that + * we know that all "old" values are covered by "new" + * values? Or is it more important that "new" values are + * covered by "old" ones, with potentially more "old" + * values lingering around that cannot be displayed by the + * connected client? + * + * This section probably needs a revisit at some point in time. + */ + for (int i = 0; i < nxagentNumDepths; ++i) { - matched = 0; + matched = false; - for (j = 0; j < nxagentNumDepthsRecBackup; j++) + for (int j = 0; j < nxagentNumDepthsRecBackup; ++j) { if (nxagentDepths[i] == nxagentDepthsRecBackup[j]) { - matched = 1; + matched = true; + one_match = true; + ++total_matches; break; } } - if (matched == 0) + if ((ToleranceChecksRisky > tolerance) && (!matched)) { #ifdef WARNING - fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! Failed to match available depth [%d].\n", - nxagentDepths[i]); + fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! Tolerance [%u] too low and " + "failed to match available depth [%d].\n", tolerance, nxagentDepths[i]); #endif - compatible = 0; + compatible = false; break; } } + /* + * At Risky tolerance, only one match is necessary to be "compatible". + */ + if (ToleranceChecksRisky == tolerance) + { + compatible = one_match; + } - if (compatible == 1) + int ret = (!(!compatible)); + + if (compatible) { #ifdef TEST fprintf(stderr, "nxagentCheckForDepthsCompatibility: Internal depths match with " - "remote depths.\n"); + "remote depths at tolerance [%u].\n", tolerance); #endif + + if (total_matches != nxagentNumDepths) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForDepthsCompatibility: only some [%d] of the new depths [%d] " + "match with old depths [%d] at tolerance [%u].\n", total_matches, nxagentNumDepths, + nxagentNumDepthsRecBackup, tolerance); + #endif + } } else { #ifdef WARNING - fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! New available depths don't match with " - "old depths.\n"); + fprintf(stderr, "nxagentCheckForDepthsCompatibility: WARNING! New available depths [%d] don't match " + "with old depths [%d] at tolerance [%u]. Only [%d] depth values matched.\n", + nxagentNumDepths, nxagentNumDepthsRecBackup, tolerance, total_matches); #endif } - return compatible; + return (ret); } static int nxagentCheckForPixmapFormatsCompatibility() @@ -2633,7 +2727,7 @@ Bool nxagentReconnectDisplay(void *p0) reconnectDisplayState = GOT_DEPTH_LIST; - if (nxagentCheckForDepthsCompatibility(flexibility) == 0) + if (nxagentCheckForDepthsCompatibility() == 0) { nxagentSetReconnectError(FAILED_RESUME_DEPTHS_ALERT, "Couldn't restore all the required depths."); -- cgit v1.2.3 From 6618271493f86109103a2ade74912d34172ba569 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Wed, 29 Jun 2016 02:13:03 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: use new ReconnectTolerance nxagentOption value in nxagentCheckForPixmapFormatsCompatibility() and modify behavior based on this value. Recognized values: - Strict means that the number of internal and external pixmap formats must match exactly and every internal pixmap format must be available in the external pixmap format array. - Safe means that the number of pixmap formats might diverge, but all internal pixmap formats must also be included in the external pixmap formats array. This is recommended, because it allows clients with more pixmap formats to still connect, but not lose functionality. - Risky means that the internal pixmap formats array is allowed to be smaller than the external pixmap formats array, but at least one pixmap format must be included in both. This is potentially unsafe. - Bypass or higher means that all of these checks are essentially deactivated. This is a very bad idea. Note that the default ReconnectTolerance value is still Strict. Also, the return value of this function is currently not used or passed through to other functions at all. An upcoming commit will change this behavior and actually enable the checks. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 128 ++++++++++++++++++++++----- 1 file changed, 105 insertions(+), 23 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index aa8ab26d1..382cdf3c1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2401,60 +2401,139 @@ static int nxagentCheckForDepthsCompatibility() static int nxagentCheckForPixmapFormatsCompatibility() { - int i, j; - int matched; - int compatible; + /* + * Depending on the (reconnect) tolerance checks value, this + * function checks stricter or looser: + * - Strict means that the number of internal and external + * pixmap formats must match exactly and every + * internal pixmap format must be available in the + * external pixmap format array. + * - Safe means that the number of pixmap formats might + * diverge, but all internal pixmap formats must + * also be included in the external pixmap formats + * array. This is recommended, because it allows + * clients with more pixmap formats to still connect, + * but not lose functionality. + * - Risky means that the internal pixmap formats array is + * allowed to be smaller than the external pixmap + * formats array, but at least one pixmap format must + * be included in both. This is potentially unsafe. + * - Bypass or higher means that all of these checks are + * essentially deactivated. This is a very bad idea. + */ - compatible = 1; + const unsigned int tolerance = nxagentOption(ReconnectTolerance); - if (nxagentNumPixmapFormats != nxagentRemoteNumPixmapFormats) + if (ToleranceChecksBypass <= tolerance) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Not proceeding with any checks, " + "because tolerance [%u] higher than or equal [%u]. Number of internally available " + "pixmap formats is [%d], number of externally available pixmap formats is [%d].\n", + tolerance, ToleranceChecksBypass, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); + #endif + + return 1; + } + + if ((ToleranceChecksStrict == tolerance) && (nxagentNumPixmapFormats != nxagentRemoteNumPixmapFormats)) { #ifdef DEBUG - fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Number of internal pixmap formats [%d] " - "doesn't match with remote formats [%d].\n", nxagentNumPixmapFormats, - nxagentRemoteNumPixmapFormats); + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! No tolerance allowed and number " + "of internal pixmap formats [%d] doesn't match with number of remote formats [%d].\n", + nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); #endif + + return 0; } - for (i = 0; i < nxagentNumPixmapFormats; i++) + if ((ToleranceChecksSafe == tolerance) && (nxagentNumPixmapFormats > nxagentRemoteNumPixmapFormats)) { - matched = 0; + #ifdef DEBUG + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Tolerance [%u] too low " + "and number of internal pixmap formats [%d] higher than number of external formats [%d].\n", + tolerance, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); + #endif + + return 0; + } + + /* + * By now the tolerance is either: + * - Strict + * - Safe and: + * o the number of internal and external pixmap formats + * matches exactly, or + * o the number of external pixmap formats is higher than + * the number of internal pixmap formats, + * - Risky + */ + + bool compatible = true; + bool one_match = false; + bool matched = false; + int total_matches = 0; - for (j = 0; j < nxagentRemoteNumPixmapFormats; j++) + for (int i = 0; i < nxagentNumPixmapFormats; ++i) + { + matched = false; + + for (int j = 0; j < nxagentRemoteNumPixmapFormats; ++j) { if (nxagentPixmapFormats[i].depth == nxagentRemotePixmapFormats[j].depth && nxagentPixmapFormats[i].bits_per_pixel == nxagentRemotePixmapFormats[j].bits_per_pixel && nxagentPixmapFormats[i].scanline_pad == nxagentRemotePixmapFormats[j].scanline_pad) { - matched = 1; + matched = true; + one_match = true; + ++total_matches; break; } } - if (matched == 0) + if ((ToleranceChecksRisky > tolerance) && (!matched)) { #ifdef WARNING - fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Failed to match internal " - "pixmap format depth [%d] bpp [%d] pad [%d].\n", nxagentPixmapFormats[i].depth, - nxagentPixmapFormats[i].bits_per_pixel, nxagentPixmapFormats[i].scanline_pad); + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Tolerance [%u] too low " + "and failed to match internal pixmap format (depth [%d] bpp [%d] pad [%d]).\n", + tolerance, nxagentPixmapFormats[i].depth, nxagentPixmapFormats[i].bits_per_pixel, + nxagentPixmapFormats[i].scanline_pad); #endif - compatible = 0; + compatible = false; } } - #ifdef TEST + int ret = !(!(compatible)); - if (compatible == 1) + if (compatible) { + #ifdef TEST fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: Internal pixmap formats match with " - "remote pixmap formats.\n"); - } + "remote pixmap formats at tolerance [%u].\n", tolerance); + #endif - #endif + if (total_matches != nxagentNumPixmapFormats) + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: Only some [%d] of the internal " + "pixmap formats [%d] match with external pixmap formats [%d] at tolerance [%u].\n", + total_matches, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats, tolerance); + #endif + } + } + else + { + #ifdef WARNING + fprintf(stderr, "nxagentCheckForPixmapFormatsCompatibility: WARNING! Internally available " + "pixmap formats [%d] don't match with external pixmap formats [%d] " + "at tolerance [%u]. Only [%d] depth values matched.\n", + nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats, tolerance, total_matches); + #endif + } - return compatible; + return (ret); } static int nxagentInitAndCheckVisuals(int flexibility) @@ -2759,6 +2838,9 @@ Bool nxagentReconnectDisplay(void *p0) * formats are supported. */ + /* + * FIXME: add an actual check here (and pass check value through nxagentInitPixmapFormats().) + */ nxagentInitPixmapFormats(); reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST; -- cgit v1.2.3 From e61c8c85cc11dad063da23fb2f1d031c574166f5 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Sat, 9 Jul 2016 03:28:27 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: split up nxagentCheckForPixmapFormatsCompatibility() and nxagentInitPixmapFormats(). Don't implicitly call the checking function in the init function (and throw away the checking functions result...) Instead, explicitly use the checking function after the init function in other parts of the code and throw away the checking functions return value selectively or actually use it while reconnecting. This is totally different behavior compared to the original one. Hopefully it doesn't cause any problems (i.e., hopefully there was no good reason for never using the checking functions return value, but an oversight.) --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 382cdf3c1..1cd3c25d9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1347,6 +1347,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. nxagentInitDepths(); nxagentInitPixmapFormats(); + (void) nxagentCheckForPixmapFormatsCompatibility(); /* * Create a pixmap for each depth matching the @@ -1727,8 +1728,6 @@ XXX: Some X server doesn't list 1 among available depths... } } #endif - - nxagentCheckForPixmapFormatsCompatibility(); } void nxagentSetDefaultDrawables() @@ -2838,11 +2837,16 @@ Bool nxagentReconnectDisplay(void *p0) * formats are supported. */ - /* - * FIXME: add an actual check here (and pass check value through nxagentInitPixmapFormats().) - */ nxagentInitPixmapFormats(); + if (nxagentCheckForPixmapFormatsCompatibility() == 0) + { + nxagentSetReconnectError(FAILED_RESUME_PIXMAPS_ALERT, + "Couldn't restore all the required pixmap formats."); + + return False; + } + reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST; /* -- cgit v1.2.3 From 5ec7e48ac70fc88b1285e3615f7651dad1247c37 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Sun, 3 Jul 2016 23:52:06 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: add FIXME comment to nxagentInitAndCheckVisuals(). Maybe needs special strictness handling as well. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 1cd3c25d9..df6159000 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2537,6 +2537,7 @@ static int nxagentCheckForPixmapFormatsCompatibility() static int nxagentInitAndCheckVisuals(int flexibility) { + /* FIXME: does this also need work? */ XVisualInfo viTemplate; XVisualInfo *viList; XVisualInfo *newVisuals; -- cgit v1.2.3 From 64a83d1e08fd8224a065d6e3548be6323127d4df Mon Sep 17 00:00:00 2001 From: Mihai Moldovan <ïonic@ionic.de> Date: Sun, 3 Jul 2016 23:52:43 +0000 Subject: nx-X11/programs/Xserver/hw/nxagent/Display.c: add FIXME comment to nxagentCheckForColormapsCompatibility(). Maybe needs special strictness handling as well. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index df6159000..5d258fd44 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2647,6 +2647,7 @@ FIXME: Should the visual be ignored in this case? static int nxagentCheckForColormapsCompatibility(int flexibility) { + /* FIXME: does this also need work? */ if (nxagentNumDefaultColormaps == nxagentNumDefaultColormapsRecBackup) { #ifdef TEST -- cgit v1.2.3