From 1330167fa2026e4d2ad1d470ebfde9977d131ab3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 23 Jul 2019 20:08:16 +0200 Subject: Utils.h: add SAFE_free macro --- nx-X11/programs/Xserver/hw/nxagent/Utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Utils.h b/nx-X11/programs/Xserver/hw/nxagent/Utils.h index c0ad03345..0aebda839 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Utils.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Utils.h @@ -45,5 +45,6 @@ static inline const char * validateString(const char *str) { } #define SAFE_XFree(what) do {if (what) {XFree(what); what = NULL;}} while (0) +#define SAFE_free(what) do {free(what); what = NULL;} while (0) #endif /* __Utils_H__ */ -- cgit v1.2.3 From b8411180ed1f3567ab5ca11d70834907fc54d711 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 18:16:20 +0200 Subject: Display.c: safe some lines by calling SAFE_XFree and SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 65 +++++++--------------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 127874962..1c18ad1a3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -71,6 +71,7 @@ is" without express or implied warranty. #include "Init.h" #include "Args.h" #include "Image.h" +#include "Utils.h" #define Pixmap XlibPixmap #include "Icons.h" @@ -1543,7 +1544,7 @@ void nxagentInitVisuals(void) nxagentNumVisuals * sizeof(XVisualInfo)); } - XFree(viList); + SAFE_XFree(viList); if (nxagentNumVisuals == 0 || nxagentVisuals == NULL) { @@ -1765,20 +1766,11 @@ void nxagentCloseDisplay(void) * traffic */ - free(nxagentDefaultColormaps); - nxagentDefaultColormaps = NULL; - - XFree(nxagentVisuals); - nxagentVisuals = NULL; - - free(nxagentDepths); - nxagentDepths = NULL; - - XFree(nxagentPixmapFormats); - nxagentPixmapFormats = NULL; - - XFree(nxagentRemotePixmapFormats); - nxagentRemotePixmapFormats = NULL; + SAFE_free(nxagentDefaultColormaps); + SAFE_free(nxagentDepths); + SAFE_XFree(nxagentVisuals); + SAFE_XFree(nxagentPixmapFormats); + SAFE_XFree(nxagentRemotePixmapFormats); nxagentFreeFontCache(); /* @@ -2017,11 +2009,7 @@ void nxagentBackupDisplayInfo(void) nxagentNumDefaultColormapsRecBackup = nxagentNumDefaultColormaps; nxagentVisualsRecBackup = nxagentVisuals; nxagentNumVisualsRecBackup = nxagentNumVisuals; - if (nxagentVisualHasBeenIgnored) - { - free(nxagentVisualHasBeenIgnored); - nxagentVisualHasBeenIgnored = NULL; - } + SAFE_free(nxagentVisualHasBeenIgnored); nxagentVisualHasBeenIgnored = malloc(nxagentNumVisuals * sizeof(Bool)); nxagentDefaultDepthRecBackup = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); nxagentDisplayWidthRecBackup = DisplayWidth(nxagentDisplay, DefaultScreen(nxagentDisplay)); @@ -2033,20 +2021,11 @@ void nxagentBackupDisplayInfo(void) void nxagentCleanupBackupDisplayInfo(void) { - free(nxagentDepthsRecBackup); - nxagentNumDepthsRecBackup = 0; + SAFE_free(nxagentDepthsRecBackup); + SAFE_free(nxagentVisualsRecBackup); + SAFE_free(nxagentVisualHasBeenIgnored); nxagentNumDefaultColormapsRecBackup = 0; - - free(nxagentVisualsRecBackup); - nxagentNumVisualsRecBackup = 0; - - if (nxagentVisualHasBeenIgnored) - { - free(nxagentVisualHasBeenIgnored); - nxagentVisualHasBeenIgnored = NULL; - } - nxagentDefaultDepthRecBackup = 0; nxagentDisplayWidthRecBackup = 0; nxagentDisplayHeightRecBackup = 0; @@ -2054,7 +2033,6 @@ void nxagentCleanupBackupDisplayInfo(void) if (nxagentDisplayBackup) { XCloseDisplay(nxagentDisplayBackup); - nxagentDisplayBackup = NULL; } @@ -2066,7 +2044,7 @@ void nxagentCleanupBackupDisplayInfo(void) } else { - free(nxagentBitmapGCBackup); + SAFE_free(nxagentBitmapGCBackup); } nxagentBitmapGCBackup = NULL; @@ -2569,7 +2547,7 @@ FIXME: Should the visual be ignored in this case? } } - XFree(viList); + SAFE_XFree(viList); if (compatible) { @@ -2585,7 +2563,7 @@ FIXME: Should the visual be ignored in this case? fprintf(stderr, "nxagentInitAndCheckVisuals: New visuals don't match with old visuals.\n"); #endif - free(newVisuals); + SAFE_free(newVisuals); } return compatible; @@ -2766,19 +2744,8 @@ Bool nxagentReconnectDisplay(void *p0) * will be reallocated in nxagentInitPixmapFormats(). */ - if (nxagentPixmapFormats != NULL) - { - XFree(nxagentPixmapFormats); - - nxagentPixmapFormats = NULL; - } - - if (nxagentRemotePixmapFormats != NULL) - { - XFree(nxagentRemotePixmapFormats); - - nxagentRemotePixmapFormats = NULL; - } + SAFE_XFree(nxagentPixmapFormats); + SAFE_XFree(nxagentRemotePixmapFormats); /* * Check if all the required pixmap -- cgit v1.2.3 From ebc2ea79f7343c4ced8277b80178091a3226ea72 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 18:10:12 +0200 Subject: Events.c: safe some lines by calling SAFE_XFree --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 35 ++++++----------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index d8bf4df60..74781f638 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -329,7 +329,7 @@ void nxagentRemoteWindowID(Window window, Bool newline) else if (winName) { fprintf(stderr, " \"%s\" ", winName); - XFree(winName); + SAFE_XFree(winName); } #else @@ -477,10 +477,7 @@ void nxagentRemoteWindowsTree(Window window, int level) nxagentRemoteWindowsTree(childList[i], level + 1); } - if (childList) - { - XFree((char *) childList); - } + SAFE_XFree((char *) childList); } #endif @@ -3128,10 +3125,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) #endif } - if (children_return) - { - XFree(children_return); - } + SAFE_XFree(children_return); #if 0 fprintf(stderr, "nxagentCheckWindowConfiguration: Trees match: %s\n", @@ -3513,11 +3507,7 @@ int nxagentHandleReparentNotify(XEvent* X) result = XQueryTree(nxagentDisplay, w, &root_return, &parent_return, &children_return, &nchildren_return); - if (children_return) - { - XFree(children_return); - children_return = NULL; - } + SAFE_XFree(children_return); if (!result) { @@ -3555,11 +3545,7 @@ int nxagentHandleReparentNotify(XEvent* X) #endif } - if (children_return) - { - XFree(children_return); - children_return = NULL; - } + SAFE_XFree(children_return); } else { @@ -3623,11 +3609,7 @@ int nxagentHandleReparentNotify(XEvent* X) result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn, &childrenReturn, &nchildrenReturn); - if (childrenReturn) - { - XFree(childrenReturn); - childrenReturn = NULL; - } + SAFE_XFree(childrenReturn); if (parentReturn == rootReturn || parentReturn == 0 || result == 0) { @@ -4024,10 +4006,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) #endif } - if (pszReturnData != NULL) - { - XFree(pszReturnData); - } + SAFE_XFree(pszReturnData); return; } -- cgit v1.2.3 From d8012d2a87ca4d1e7c3b0a04a58b4e4e0cc83abd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 18:11:59 +0200 Subject: Screen.c: safe some lines by calling SAFE_XFree --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 73 ++++++++++++----------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index d1dc37dc2..62634de60 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -304,8 +304,7 @@ Bool nxagentIsParentOf(Display *d, XlibWindow possible_parent, XlibWindow candid if (XQueryTree(d, candidate, &root, &parent, &children, &num_children)) { - if (children) - XFree((char *)children); + SAFE_XFree(children); #ifdef TEST fprintf(stderr, "%s: parent of full screen window [%p] root [%p] possible_parent [%p] candidate [%p]\n", __func__, parent, root, possible_parent, candidate); @@ -490,11 +489,8 @@ Window nxagentCreateIconWindow(void) window_name, window_name, NULL , 0 , sizeHints, wmHints, NULL); - if (sizeHints) - XFree(sizeHints); - - if (wmHints) - XFree(wmHints); + SAFE_XFree(sizeHints); + SAFE_XFree(wmHints); /* * Enable events from the icon window. @@ -895,10 +891,9 @@ void freeDepths(DepthPtr depths, int num) #ifdef DEBUG fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids); #endif - free(depths[i].vids); - depths[i].vids = NULL; + SAFE_free(depths[i].vids); } - free(depths); + SAFE_free(depths); } Bool nxagentOpenScreen(ScreenPtr pScreen, @@ -1393,7 +1388,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!pFrameBufferBits) { freeDepths(depths, numDepths); - free(visuals); + SAFE_free(visuals); return FALSE; } @@ -1416,7 +1411,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) { freeDepths(depths, numDepths); - free(visuals); + SAFE_free(visuals); return FALSE; } @@ -1457,7 +1452,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, pScreen -> numDepths = numDepths; pScreen -> rootDepth = rootDepth; - free(pScreen -> visuals); + SAFE_free(pScreen -> visuals); pScreen -> visuals = visuals; pScreen -> numVisuals = numVisuals; pScreen -> rootVisual = defaultVisual; @@ -1898,8 +1893,8 @@ N/A hint.res_class = strdup("NXAgent"); } XSetClassHint(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &hint); - free(hint.res_name); - free(hint.res_class); + SAFE_free(hint.res_name); + SAFE_free(hint.res_class); } if (nxagentOption(Fullscreen)) @@ -1983,17 +1978,8 @@ N/A nxagentWindowName, argv , argc , sizeHints, wmHints, NULL); - if (sizeHints) - { - XFree(sizeHints); - sizeHints = NULL; - } - - if (wmHints) - { - XFree(wmHints); - wmHints = NULL; - } + SAFE_XFree(sizeHints); + SAFE_XFree(wmHints); /* * Clear the window but let it unmapped. We'll map it @@ -2205,9 +2191,9 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) * Free the frame buffer. */ - free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); - free(pScreen->devPrivate);pScreen->devPrivate = NULL; - free(pScreen->visuals); pScreen->visuals = NULL; + SAFE_free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); + SAFE_free(pScreen->devPrivate); + SAFE_free(pScreen->visuals); fbCloseScreen(pScreen); @@ -3167,7 +3153,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr length = nxagentImageLength(width, height, ZPixmap, 0, nxagentMasterDepth); - free(tBuffer); + SAFE_free(tBuffer); tBuffer = malloc(length); @@ -3224,7 +3210,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr RegionUnion(&nxagentShadowUpdateRegion, &nxagentShadowUpdateRegion, &updateRegion); } - free(tBuffer); + SAFE_free(tBuffer); RegionUninit(&updateRegion); } @@ -3442,7 +3428,7 @@ void nxagentShadowAdaptDepth(unsigned int width, unsigned int height, cBuffer = (unsigned char *) *buffer; *buffer = (char *) icBuffer; - free(cBuffer); + SAFE_free(cBuffer); } #ifdef NXAGENT_ARTSD @@ -3625,7 +3611,7 @@ FIXME: The port information is not used at the moment and produces a strlen(local_buf), local_buf, 1); } - free(local_buf); + SAFE_free(local_buf); } } } @@ -4049,7 +4035,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) #endif number = 1; - free(screeninfo); + SAFE_free(screeninfo); if (!(screeninfo = malloc(sizeof(XineramaScreenInfo)))) { return FALSE; @@ -4318,8 +4304,7 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) } /* release allocated memory */ - free(screeninfo); - screeninfo = NULL; + SAFE_free(screeninfo); #ifdef DEBUG for (i = 0; i < pScrPriv->numCrtcs; i++) { @@ -4434,7 +4419,7 @@ void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); - free((char *) pRects); + SAFE_free(pRects); extents = *RegionExtents(&cleanRegion); @@ -4580,7 +4565,7 @@ void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); - free(pRects); + SAFE_free(pRects); extents = *RegionExtents(clipRegion); @@ -4660,7 +4645,7 @@ void nxagentSetWMNormalHints(int screen, int width, int height) XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[screen], sizeHints); - XFree(sizeHints); + SAFE_XFree(sizeHints); } /* @@ -4679,7 +4664,7 @@ void nxagentSetWMNormalHintsMaxsize(ScreenPtr pScreen, int maxwidth, int maxheig sizeHints->max_height = maxheight; XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], sizeHints); - XFree(sizeHints); + SAFE_XFree(sizeHints); } } @@ -4820,7 +4805,7 @@ FIXME fprintf(stderr, "nxagentShowPixmap: XGetImage failed.\n"); #endif - free(data); + SAFE_free(data); return; } @@ -4853,7 +4838,7 @@ FIXME XDestroyImage(image); } - free(data); + SAFE_free(data); /* FIXME @@ -4905,7 +4890,7 @@ void nxagentFbRestoreArea(PixmapPtr pPixmap, WindowPtr pWin, int xSrc, int ySrc, fprintf(stderr, "nxagentFbRestoreArea: XGetImage failed.\n"); #endif - free(data); + SAFE_free(data); return; } @@ -4965,7 +4950,7 @@ FIXME /* FIXME - free(data); + SAFE_free(data); */ } -- cgit v1.2.3 From a4700c9d0cde2003a8bf8dafdb3e9357d510206b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:27:10 +0200 Subject: Font.c: use SAFE_XFree and SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Font.c | 63 +++++++++++++------------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index fb441d431..7370bc56d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -188,11 +188,11 @@ void nxagentFreeFontCache(void) nxagentFreeFont(CACHE_FSTRUCT(i)); } - free(CACHE_NAME(i)); - free(CACHE_ENTRY(i)); + SAFE_free(CACHE_NAME(i)); + SAFE_free(CACHE_ENTRY(i)); } - free(CACHE_ENTRY_PTR); + SAFE_free(CACHE_ENTRY_PTR); CACHE_ENTRY_PTR = NULL; CACHE_INDEX = 0; CACHE_SIZE = 0; @@ -324,8 +324,7 @@ void nxagentListRemoteAddName(const char *name, int status) if (nxagentRemoteFontList.list[pos]->name == NULL) { fprintf(stderr, "Font: remote list name memory allocation failed!.\n"); - free(nxagentRemoteFontList.list[pos]); - nxagentRemoteFontList.list[pos] = NULL; + SAFE_free(nxagentRemoteFontList.list[pos]); return; } } @@ -351,18 +350,14 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec) { if (listRec -> list[l]) { - free(listRec -> list[l] -> name); - listRec -> list[l] -> name = NULL; - - free(listRec -> list[l]); - listRec -> list[l] = NULL; + SAFE_free(listRec -> list[l] -> name); + SAFE_free(listRec -> list[l]); } } listRec -> length = listRec -> listSize = 0; - free(listRec -> list); - listRec -> list = NULL; + SAFE_free(listRec -> list); return; } @@ -434,7 +429,7 @@ Bool nxagentFontLookUp(const char *name) { result = nxagentFontFind(scalable, &i); - free(scalable); + SAFE_free(scalable); } } @@ -448,7 +443,7 @@ Bool nxagentFontLookUp(const char *name) { result = nxagentFontFind(scalable, &i); - free(scalable); + SAFE_free(scalable); } } @@ -813,7 +808,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP for (j = 0; j < numSearchFields; j++) { - free(searchFields[j]); + SAFE_free(searchFields[j]); } } } @@ -830,7 +825,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP for (j = 0; j < numFontFields; j++) { - free(fontNameFields[j]); + SAFE_free(fontNameFields[j]); } return fontStruct; @@ -890,10 +885,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL) { - free(nxagentFailedToReconnectFonts.font); - nxagentFailedToReconnectFonts.font = NULL; - free(nxagentFailedToReconnectFonts.id); - nxagentFailedToReconnectFonts.id = NULL; + SAFE_free(nxagentFailedToReconnectFonts.font); + SAFE_free(nxagentFailedToReconnectFonts.id); FatalError("Font: font not reconnected memory allocation failed!.\n"); } @@ -1050,7 +1043,7 @@ static void nxagentCleanCacheAfterReconnect(void) { if(CACHE_FSTRUCT(i) == NULL) { - XFree(CACHE_NAME(i)); + SAFE_XFree(CACHE_NAME(i)); real_size--; } } @@ -1223,11 +1216,8 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFreeFailedToReconnectFonts(void) { - free(nxagentFailedToReconnectFonts.font); - nxagentFailedToReconnectFonts.font = NULL; - - free(nxagentFailedToReconnectFonts.id); - nxagentFailedToReconnectFonts.id = NULL; + SAFE_free(nxagentFailedToReconnectFonts.font); + SAFE_free(nxagentFailedToReconnectFonts.id); nxagentFailedToReconnectFonts.size = 0; nxagentFailedToReconnectFonts.index = 0; @@ -1321,7 +1311,7 @@ Bool nxagentReconnectFailedFonts(void *p0) nxagentListRemoteFonts("*", nxagentMaxFontNames); XFreeFontPath(fontPaths); - free(newFontPaths); + SAFE_free(newFontPaths); return False; } @@ -1332,7 +1322,7 @@ Bool nxagentReconnectFailedFonts(void *p0) XSetFontPath(nxagentDisplay, fontPaths, nPaths); XFreeFontPath(fontPaths); - free(newFontPaths); + SAFE_free(newFontPaths); nxagentCleanCacheAfterReconnect(); @@ -1442,7 +1432,7 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir) if (rc == -1) return; - free(*dest); + SAFE_free(*dest); *dest = tmppath; tmppath = NULL; } @@ -1554,7 +1544,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo fprintf(stderr, "nxagentLoadQueryFont: WARNING! Font not found '%s'.\n", name); #endif - free(fs); + SAFE_free(fs); return (XFontStruct *) NULL; } @@ -1588,7 +1578,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo fprintf(stderr, "nxagentLoadQueryFont: WARNING! Failed allocation of XFontProp."); #endif - free((char *) fs); + SAFE_free(fs); return (XFontStruct *) NULL; } @@ -1622,18 +1612,17 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo int nxagentFreeFont(XFontStruct *fs) { - if (fs -> per_char) + if (fs->per_char) { #ifdef USE_XF86BIGFONT _XF86BigfontFreeFontMetrics(fs); #else - free ((char *) fs->per_char); + SAFE_free(fs->per_char); #endif } - free (fs->properties); - - XFree(fs); + SAFE_free(fs->properties); + SAFE_XFree(fs); return 1; } @@ -1769,7 +1758,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) MakeScalableFontNameError: - free(scalableFontName); + SAFE_free(scalableFontName); #ifdef DEBUG fprintf(stderr, "nxagentMakeScalableFontName: Invalid font name.\n"); -- cgit v1.2.3 From 4a826d30f911dbf4552b92192dbbb2d91d34e33f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:29:31 +0200 Subject: Rootless.c: use SAFE_free and SAFE_XFree --- nx-X11/programs/Xserver/hw/nxagent/Rootless.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index c2611c194..6908799b6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -281,10 +281,7 @@ Bool nxagentRootlessTreesMatch(void) } } - if (children_return) - { - XFree(children_return); - } + SAFE_XFree(children_return); return treesMatch; } @@ -332,7 +329,7 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren) if (!ntoplevel) { - free(toplevel); + SAFE_free(toplevel); return; } @@ -397,7 +394,7 @@ void nxagentRootlessRestack(unsigned long children[], unsigned int nchildren) #endif - free(toplevel); + SAFE_free(toplevel); return; } @@ -818,7 +815,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) if (freeMem) { - free(output); + SAFE_free(output); } return export; @@ -1131,7 +1128,7 @@ void nxagentImportProperty(Window window, if (freeMem) { - free(output); + SAFE_free(output); } return; @@ -1183,7 +1180,7 @@ void nxagentRemovePropertyFromList(void) nxagentPropertyList.last = NULL; } - free(tmp); + SAFE_free(tmp); } } -- cgit v1.2.3 From d0a6c98cb2465203e852f466127442cd79dc2662 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:32:58 +0200 Subject: Window.c: use SAFE_free and SAFE_XFree --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 40 ++++++++++++----------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 7d390872e..357c6efbd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -63,6 +63,7 @@ #include "Init.h" #include "Composite.h" #include "Events.h" +#include "Utils.h" #include #include "compext/Compext.h" @@ -1482,10 +1483,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) fprintf(stderr, "nxagentConfigureWindow: Failed QueryTree request.\n "); } - if (children_return) - { - XFree(children_return); - } + SAFE_XFree(children_return); } #endif } @@ -3183,7 +3181,7 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer &hints); #ifdef _XSERVER64 - free(data64); + SAFE_free(data64); #endif } } @@ -3430,7 +3428,7 @@ Bool nxagentCheckWindowIntegrity(WindowPtr pWin) XDestroyImage(image); } - free(data); + SAFE_free(data); } else { @@ -3519,14 +3517,14 @@ void nxagentFlushConfigureWindow(void) if (index == nxagentConfiguredWindowList) { - free(index); + SAFE_free(index); break; } else { ConfiguredWindowStruct *tmp = index; index = index -> prev; - free(tmp); + SAFE_free(tmp); } } @@ -3676,16 +3674,14 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin) { if (index -> prev == NULL && index -> next == NULL) { - free(nxagentConfiguredWindowList); - nxagentConfiguredWindowList = NULL; - + SAFE_free(nxagentConfiguredWindowList); return; } else if (index -> prev == NULL) { tmp = nxagentConfiguredWindowList; index = nxagentConfiguredWindowList = tmp -> next; - free(tmp); + SAFE_free(tmp); nxagentConfiguredWindowList -> prev = NULL; continue; @@ -3694,7 +3690,7 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin) { tmp = index; index = index -> prev; - free(tmp); + SAFE_free(tmp); index -> next = NULL; return; @@ -3705,7 +3701,7 @@ void nxagentDeleteConfiguredWindow(WindowPtr pWin) index = index -> next; previous -> next = index; index -> prev = previous; - free(tmp); + SAFE_free(tmp); continue; } @@ -3747,16 +3743,14 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence) { if (index -> prev == NULL && index -> next == NULL) { - free(nxagentStaticResizedWindowList); - nxagentStaticResizedWindowList = NULL; - + SAFE_free(nxagentStaticResizedWindowList); return; } else if (index -> prev == NULL) { tmp = nxagentStaticResizedWindowList; index = nxagentStaticResizedWindowList = tmp -> next; - free(tmp); + SAFE_free(tmp); nxagentStaticResizedWindowList -> prev = NULL; continue; @@ -3765,7 +3759,7 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence) { tmp = index; index = index -> prev; - free(tmp); + SAFE_free(tmp); index -> next = NULL; return; @@ -3776,7 +3770,7 @@ void nxagentDeleteStaticResizedWindow(unsigned long sequence) index = index -> next; previous -> next = index; index -> prev = previous; - free(tmp); + SAFE_free(tmp); continue; } @@ -3909,8 +3903,7 @@ int nxagentRemoveItemBSPixmapList(unsigned long pixmapId) if ((nxagentBSPixmapList[i] != NULL) && (nxagentBSPixmapList[i] -> storingPixmapId == pixmapId)) { - free(nxagentBSPixmapList[i]); - nxagentBSPixmapList[i] = NULL; + SAFE_free(nxagentBSPixmapList[i]); if (i < BSPIXMAPLIMIT - 1) { @@ -3948,8 +3941,7 @@ int nxagentEmptyBSPixmapList(void) { for (int i = 0; i < BSPIXMAPLIMIT; i++) { - free(nxagentBSPixmapList[i]); - nxagentBSPixmapList[i] = NULL; + SAFE_free(nxagentBSPixmapList[i]); } return 1; -- cgit v1.2.3 From 156533439445173e488d648354a94103f578cfa0 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:33:54 +0200 Subject: Cursor.c: use SAFE_XFree --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index a67115cec..75382d4e8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -61,6 +61,7 @@ is" without express or implied warranty. #include "Events.h" #include "Render.h" #include "Client.h" +#include "Utils.h" #include "windowstr.h" #include "resource.h" @@ -211,7 +212,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) XPutImage(nxagentDisplay, source, nxagentBitmapGC, image, 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - XFree(image); + SAFE_XFree(image); image = XCreateImage(nxagentDisplay, nxagentDefaultVisual(pScreen), @@ -229,7 +230,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) XPutImage(nxagentDisplay, mask, nxagentBitmapGC, image, 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - XFree(image); + SAFE_XFree(image); fg_color.red = pCursor->foreRed; fg_color.green = pCursor->foreGreen; @@ -264,14 +265,12 @@ Bool nxagentUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) if (nxagentCursorUsesRender(pCursor, pScreen)) { PicturePtr pPicture = nxagentCursorPicture(pCursor, pScreen); - FreePicture(pPicture, pPicture -> id); } if (nxagentCursor(pCursor, pScreen) != None) { XFreeCursor(nxagentDisplay, nxagentCursor(pCursor, pScreen)); - nxagentCursor(pCursor, pScreen) = None; } -- cgit v1.2.3 From fd4fa4e9646bb3f5a9091dc571b158a861b6127e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:34:42 +0200 Subject: Keyboard.c: use SAFE_XFree and SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 70 +++++++++++++-------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 6fbc66481..b7ed38ca3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -58,6 +58,7 @@ is" without express or implied warranty. #include "Options.h" #include "Error.h" #include "Init.h" +#include "Utils.h" #include "compext/Compext.h" @@ -657,7 +658,7 @@ N/A { keymap[i] = keymap64[i]; } - XFree(keymap64); + SAFE_XFree(keymap64); } #else /* #ifdef _XSERVER64 */ @@ -762,7 +763,7 @@ XkbError: #ifdef TEST fprintf(stderr, "%s: changing nxagentKeyboard from [null/null] to [clone].\n", __func__); #endif - free(nxagentKeyboard); + SAFE_free(nxagentKeyboard); nxagentKeyboard = strdup("clone"); } @@ -809,7 +810,7 @@ XkbError: layout = strdup(strsep(&tmp, sep)); variant = strdup(strsep(&tmp, sep)); options = strdup(strsep(&tmp, sep)); - free(rmlvo); + SAFE_free(rmlvo); } else { @@ -864,11 +865,11 @@ XkbError: /* Only setup keycode conversion if we are NOT in clone mode */ if (nxagentKeyboard && (strcmp(nxagentKeyboard, "clone") == 0)) { - free(rules); rules = strdup(nxagentRemoteRules); - free(model); model = strdup(nxagentRemoteModel); - free(layout); layout = strdup(nxagentRemoteLayout); - free(variant); variant = strdup(nxagentRemoteVariant); - free(options); options = strdup(nxagentRemoteOptions); + SAFE_free(rules); rules = strdup(nxagentRemoteRules); + SAFE_free(model); model = strdup(nxagentRemoteModel); + SAFE_free(layout); layout = strdup(nxagentRemoteLayout); + SAFE_free(variant); variant = strdup(nxagentRemoteVariant); + SAFE_free(options); options = strdup(nxagentRemoteOptions); /* * when cloning we do not want X2Go to set the keyboard * via a keyboard file generated by nxagent. The defined @@ -947,9 +948,9 @@ XkbError: NXShadowInitKeymap(&(pDev->key->curKeySyms)); } - free(rules); - free(variant); - free(options); + SAFE_free(rules); + SAFE_free(variant); + SAFE_free(options); } if (xkb) @@ -958,8 +959,8 @@ XkbError: xkb = NULL; } - free(model); - free(layout); + SAFE_free(model); + SAFE_free(layout); #endif #ifdef WATCH @@ -980,9 +981,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #endif #ifdef _XSERVER64 - free(keymap); + SAFE_free(keymap); #else - XFree(keymap); + SAFE_XFree(keymap); #endif break; case DEVICE_ON: @@ -1182,7 +1183,7 @@ int nxagentResetKeyboard(void) nxagentFreeKeyboardDeviceData(devBackup); - free(devBackup); + SAFE_free(devBackup); return 1; } @@ -1315,18 +1316,15 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) } #endif - free(dev->key->curKeySyms.map); - free(dev->key->modifierKeyMap); - free(dev->key); - - dev->key = NULL; + SAFE_free(dev->key->curKeySyms.map); + SAFE_free(dev->key->modifierKeyMap); + SAFE_free(dev->key); } if (dev->focus) { - free(dev->focus->trace); - free(dev->focus); - dev->focus = NULL; + SAFE_free(dev->focus->trace); + SAFE_free(dev->focus); } if (dev->kbdfeed) @@ -1338,7 +1336,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) if (k->xkb_sli) XkbFreeSrvLedInfo(k->xkb_sli); #endif - free(k); + SAFE_free(k); } dev->kbdfeed = NULL; } @@ -1571,11 +1569,11 @@ void nxagentTuneXkbWrapper(void) void nxagentXkbClearNames(void) { - free(nxagentRemoteRules); nxagentRemoteRules = NULL; - free(nxagentRemoteModel); nxagentRemoteModel = NULL; - free(nxagentRemoteLayout); nxagentRemoteLayout = NULL; - free(nxagentRemoteVariant); nxagentRemoteVariant = NULL; - free(nxagentRemoteOptions); nxagentRemoteOptions = NULL; + SAFE_free(nxagentRemoteRules); + SAFE_free(nxagentRemoteModel); + SAFE_free(nxagentRemoteLayout); + SAFE_free(nxagentRemoteVariant); + SAFE_free(nxagentRemoteOptions); } static void nxagentXkbGetNames(void) @@ -1618,7 +1616,7 @@ static void nxagentXkbGetNames(void) { if (data) { - XFree(data); + SAFE_XFree(data); return; } } @@ -1655,7 +1653,7 @@ static void nxagentXkbGetNames(void) name += strlen(name) + 1; } - XFree(data); + SAFE_XFree(data); return; } @@ -1686,12 +1684,12 @@ static char* getKeyboardFilePath(void) { if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1)) { - free(sessionpath); + SAFE_free(sessionpath); FatalError("malloc for keyboard file path failed."); } else { - free(sessionpath); + SAFE_free(sessionpath); } } else @@ -1720,7 +1718,7 @@ static void nxagentWriteKeyboardDir(void) { fprintf(stderr, "Info: keyboard blocking directory created: '%s'\n", keyboard_file_path); } - free(keyboard_file_path); + SAFE_free(keyboard_file_path); } } @@ -1748,7 +1746,7 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha int save_err = errno; fprintf(stderr, "Error: keyboard file not created: %s\n", strerror(save_err)); } - free(keyboard_file_path); + SAFE_free(keyboard_file_path); } } } -- cgit v1.2.3 From 34bd0942baf5fedc038ded7507b130446edd611a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:44:25 +0200 Subject: Reconnect.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index b78c01e30..47f636316 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -53,6 +53,7 @@ #include "Splash.h" #include "Error.h" #include "Keystroke.h" +#include "Utils.h" #ifdef XKB #include "XKBsrv.h" @@ -448,8 +449,7 @@ Bool nxagentReconnectSession(void) return 0; } - free(nxagentKeyboard); - nxagentKeyboard = NULL; + SAFE_free(nxagentKeyboard); } nxagentSaveOptions(); @@ -464,7 +464,7 @@ Bool nxagentReconnectSession(void) fprintf(stderr, "nxagentReconnect: changing nxagentKeyboard from [null/null] to [clone].\n"); #endif - free(nxagentKeyboard); + SAFE_free(nxagentKeyboard); nxagentKeyboard = strdup("clone"); } @@ -635,8 +635,7 @@ Bool nxagentReconnectSession(void) nxagentXkbState.Initialized = 0; - free(nxagentOldKeyboard); - nxagentOldKeyboard = NULL; + SAFE_free(nxagentOldKeyboard); nxagentInitPointerMap(); @@ -760,8 +759,7 @@ nxagentReconnectError: nxagentDisconnectDisplay(); } - free(nxagentOldKeyboard); - nxagentOldKeyboard = NULL; + SAFE_free(nxagentOldKeyboard); return 0; } -- cgit v1.2.3 From 8b74ff1c11f42943fbfdf247446676536d16f480 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:45:25 +0200 Subject: Pixmap.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 653426ebb..58fea6c05 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -49,6 +49,7 @@ #include "Events.h" #include "Holder.h" #include "Args.h" +#include "Utils.h" #include "compext/Compext.h" #include @@ -501,7 +502,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) FreeResource(pPixmapPriv -> mid, RT_NONE); } - free(pPixmap); + SAFE_free(pPixmap); return True; } @@ -1092,7 +1093,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) { FatalError("XGetImage: Failed.\n"); - free(data); + SAFE_free(data); return False; } @@ -1168,7 +1169,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) XDestroyImage(image); } - free(data); + SAFE_free(data); } else { @@ -1265,7 +1266,7 @@ void nxagentSynchronizeShmPixmap(DrawablePtr pDrawable, int xPict, int yPict, nxagentPutImage(pDrawable, pGC, depth, xPict, yPict, width, height, 0, format, data); - free(data); + SAFE_free(data); } #ifdef WARNING else @@ -1413,7 +1414,7 @@ FIXME: If the pixmap has a different depth from the window, the fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n"); #endif - free(data); + SAFE_free(data); return False; } @@ -1572,7 +1573,7 @@ Bool nxagentFbOnShadowDisplay(void) fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n"); #endif - free(data); + SAFE_free(data); return False; } -- cgit v1.2.3 From 458538010837633483409700f42a81d4650f2169 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:50:19 +0200 Subject: Render.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Render.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index 9d91b1ff1..ebc1fe287 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -45,6 +45,7 @@ #include "Drawable.h" #include "Trap.h" #include "Args.h" +#include "Utils.h" #define Atom XlibAtom #define Pixmap XlibPixmap @@ -2528,7 +2529,7 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi, if (normalizedImages != images) { - free(normalizedImages); + SAFE_free(normalizedImages); } #ifdef DEBUG @@ -2636,7 +2637,7 @@ FIXME: Is this useful or just a waste of bandwidth? nparams); #endif - free(szFilter); + SAFE_free(szFilter); } -- cgit v1.2.3 From dde4e7636bb48360696b1886978c7c4626dd40f3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 21:53:20 +0200 Subject: Image.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index a5e19724b..a7bacaf85 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -455,7 +455,7 @@ FIXME: Here the split trap is always set and so the caching of if (nxagentUnpackAlpha[resource] != NULL) { - free(nxagentUnpackAlpha[resource] -> data); + SAFE_free(nxagentUnpackAlpha[resource] -> data); } else if ((nxagentUnpackAlpha[resource] = malloc(sizeof(UnpackAlphaRec))) == NULL) { @@ -463,7 +463,7 @@ FIXME: Here the split trap is always set and so the caching of fprintf(stderr, "nxagentSetUnpackAlpha: PANIC! Can't allocate data for the alpha structure.\n"); #endif - free(data); + SAFE_free(data); return; } @@ -483,7 +483,7 @@ FIXME: Here the split trap is always set and so the caching of resource, size); #endif - free(data); + SAFE_free(data); } } @@ -1567,20 +1567,20 @@ nxagentPutSubImageEnd: nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded); #endif - free(packedChecksum); + SAFE_free(packedChecksum); if (packedImage != NULL) { if (packedImage -> data != NULL && packedImage -> data != plainImage -> data) { - free(packedImage -> data); + SAFE_free(packedImage -> data); } - free(packedImage); + SAFE_free(packedImage); } - free(plainImage); + SAFE_free(plainImage); } void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, @@ -1634,11 +1634,8 @@ void nxagentResetAlphaCache(void) { if (nxagentUnpackAlpha[i]) { - free(nxagentUnpackAlpha[i] -> data); - - free(nxagentUnpackAlpha[i]); - - nxagentUnpackAlpha[i] = NULL; + SAFE_free(nxagentUnpackAlpha[i] -> data); + SAFE_free(nxagentUnpackAlpha[i]); } } } @@ -1716,7 +1713,7 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, if (newImage -> data == NULL) { - free(newImage); + SAFE_free(newImage); #ifdef PANIC fprintf(stderr, "nxagentScaleImage: PANIC! Failed to create the target image data.\n"); @@ -1784,8 +1781,8 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, } } - free((char *) image -> obdata); - free((char *) image); + SAFE_free(image -> obdata); + SAFE_free(image); *pImage = newImage; -- cgit v1.2.3 From 122fbd3e1b49b4eca142052350336694dae17585 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:17:25 +0200 Subject: Error.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index bc58ef849..0d4ef3107 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -42,6 +42,7 @@ #include "Error.h" #include "Args.h" +#include "Utils.h" /* * Set here the required log level. @@ -425,7 +426,7 @@ char *nxagentGetRootPath(void) "home directory '%s'.\n", homeEnv); #endif - free(homeEnv); + SAFE_free(homeEnv); return NULL; } @@ -436,7 +437,7 @@ char *nxagentGetRootPath(void) snprintf(nxagentRootDir, DEFAULT_STRING_LENGTH, "%s/.nx", homeEnv); - free(homeEnv); + SAFE_free(homeEnv); /* * Create the NX root directory. @@ -534,14 +535,14 @@ char *nxagentGetSessionPath(void) nxagentSessionDir); #endif - free(rootPath); + SAFE_free(rootPath); return NULL; } snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s/C-%s", rootPath, nxagentSessionId); - free(rootPath); + SAFE_free(rootPath); if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT)) { @@ -595,14 +596,14 @@ void nxagentGetClientsPath(void) fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n"); #endif - free(sessionPath); + SAFE_free(sessionPath); return; } snprintf(nxagentClientsLogName, NXAGENTCLIENTSLOGNAMELENGTH, "%s/clients", sessionPath); - free(sessionPath); + SAFE_free(sessionPath); } return; -- cgit v1.2.3 From 633d040971ad470e8cd74d31fc203d1312ec5550 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:19:15 +0200 Subject: Args.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 161403cd0..1d8beca3d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -195,7 +195,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { char *basec = strdup(argv[0]); nxagentProgName = strdup(basename(basec)); - free(basec); + SAFE_free(basec); /* * Check if we are running as X2Go Agent @@ -270,7 +270,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { nxagentParseOptionString(envOptions); - free(envOptions); + SAFE_free(envOptions); } for (j = 0; j < argc; j++) @@ -378,8 +378,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { if (++i < argc) { - free(nxagentOptionsFilenameOrString); - nxagentOptionsFilenameOrString = NULL; + SAFE_free(nxagentOptionsFilenameOrString); if (-1 == asprintf(&nxagentOptionsFilenameOrString, "%s", argv[i])) { @@ -716,8 +715,7 @@ int ddxProcessArgument(int argc, char *argv[], int i) { if (++i < argc) { - free(nxagentKeyboard); - nxagentKeyboard = NULL; + SAFE_free(nxagentKeyboard); nxagentKeyboard = strdup(argv[i]); if (nxagentKeyboard == NULL) @@ -1574,7 +1572,7 @@ static void nxagentParseSingleOption(char *name, char *value) ddxProcessArgument(argc, argv, 0); - free(argv[0]); + SAFE_free(argv[0]); } static void nxagentParseOptionString(char *string) @@ -1761,7 +1759,7 @@ void nxagentProcessOptionsFile(char * filename) nxagentProcessOptionsFileExit: - free(data); + SAFE_free(data); if (file) { -- cgit v1.2.3 From 43e300ecdd7d960012f278fc8ee178cae4c81728 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:20:47 +0200 Subject: Colormap.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Colormap.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c index 401f05b94..33b0738ec 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c @@ -54,6 +54,7 @@ is" without express or implied warranty. #include "Visual.h" #include "Windows.h" #include "Args.h" +#include "Utils.h" #define PANIC #define WARNING @@ -120,7 +121,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) pCmap->red[i].co.local.green = colors[i].red; pCmap->red[i].co.local.blue = colors[i].red; } - free(colors); + SAFE_free(colors); break; case StaticColor: /* read only */ @@ -133,7 +134,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) pCmap->red[i].co.local.green = colors[i].green; pCmap->red[i].co.local.blue = colors[i].blue; } - free(colors); + SAFE_free(colors); break; case TrueColor: /* read only */ @@ -157,7 +158,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) pCmap->green[i].co.local.green = colors[i].green; pCmap->blue[i].co.local.blue = colors[i].blue; } - free(colors); + SAFE_free(colors); break; case GrayScale: /* read and write */ @@ -176,7 +177,7 @@ Bool nxagentCreateColormap(ColormapPtr pCmap) void nxagentDestroyColormap(ColormapPtr pCmap) { XFreeColormap(nxagentDisplay, nxagentColormap(pCmap)); - free(pCmap->devPriv); + SAFE_free(pCmap->devPriv); } #define SEARCH_PREDICATE \ @@ -254,10 +255,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) numWindows = 0; } - free(icws.cmapIDs); + SAFE_free(icws.cmapIDs); if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) { - free(nxagentOldInstalledColormapWindows); + SAFE_free(nxagentOldInstalledColormapWindows); #ifdef _XSERVER64 { @@ -268,7 +269,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) windows[i] = icws.windows[i]; XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], windows, numWindows); - free(windows); + SAFE_free(windows); } #else XSetWMColormapWindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], @@ -317,12 +318,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) #endif /* DUMB_WINDOW_MANAGERS */ } else - free(icws.windows); + SAFE_free(icws.windows); } void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen) { - free(nxagentOldInstalledColormapWindows); + SAFE_free(nxagentOldInstalledColormapWindows); #ifdef _XSERVER64 { @@ -454,7 +455,7 @@ void nxagentStoreColors(ColormapPtr pCmap, int nColors, xColorItem *pColors) pColors64[i].flags = pColors[i].flags; } XStoreColors(nxagentDisplay, nxagentColormap(pCmap), pColors64, nColors); - free(pColors64); + SAFE_free(pColors64); } #else XStoreColors(nxagentDisplay, nxagentColormap(pCmap), -- cgit v1.2.3 From a9819436d8014e61c2d557bcd62124fe593be096 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:22:31 +0200 Subject: Drawable.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Drawable.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c index 88f3da3a9..7574ec7b0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c @@ -42,6 +42,7 @@ #include "Pixels.h" #include "Reconnect.h" #include "GCOps.h" +#include "Utils.h" #include "compext/Compext.h" @@ -365,7 +366,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner); nxagentSynchronizeDrawableDataEnd: - free(data); + SAFE_free(data); return success; } @@ -861,7 +862,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #endif } - free(cmpData); + SAFE_free(cmpData); } } else @@ -1058,7 +1059,7 @@ nxagentSynchronizeRegionFree: nxagentFreeRegion(pDrawable, clipRegion); } - free(data); + SAFE_free(data); RegionUninit(&exposeRegion); @@ -2158,7 +2159,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) fprintf(stderr, "nxagentGetColor: WARNING! Failed to create the XImage.\n"); #endif - free(data); + SAFE_free(data); return -1; } @@ -2384,7 +2385,7 @@ void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion) XFillRectangles(nxagentDisplay, nxagentDrawable(pDrawable), nxagentGC(pGC), pRects, nrects); - free(pRects); + SAFE_free(pRects); } } -- cgit v1.2.3 From 6378d5ade724a43fb21a38f843f2496a367e517f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:24:37 +0200 Subject: GC.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 2fac2f100..df9c4ad0a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -61,6 +61,7 @@ is" without express or implied warranty. #include "Trap.h" #include "Screen.h" #include "Pixels.h" +#include "Utils.h" #include "../../fb/fb.h" @@ -694,7 +695,7 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y, pRects, nRects, Unsorted); - free((char *) pRects); + SAFE_free(pRects); } break; @@ -778,7 +779,7 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clientClip = (void *) RegionFromRects(nRects, (xRectangle *)pValue, type); - free(pValue); + SAFE_free(pValue); pValue = pGC->clientClip; @@ -912,9 +913,8 @@ static void nxagentFreeGCRec(struct nxagentGCRec *t) (void *) t, (void *) t -> gc); #endif - free(t -> gc); - - free(t); + SAFE_free(t -> gc); + SAFE_free(t); } static void nxagentRestoreGCRec(struct nxagentGCRec *t) @@ -924,11 +924,11 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t) (void*)t, (void*)t -> gc); #endif - free(nxagentGC(t -> pGC)); + SAFE_free(nxagentGC(t -> pGC)); nxagentGC(t -> pGC) = t -> gc; - free(t); + SAFE_free(t); } static void nxagentAddGCToList(GCPtr pGC) @@ -1303,7 +1303,7 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y, pRects, nRects, Unsorted); - free((char *) pRects); + SAFE_free(pRects); } else { @@ -1374,7 +1374,7 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clientClip = (void *) RegionFromRects(nRects, (xRectangle *)pValue, type); - free(pValue); + SAFE_free(pValue); pValue = pGC->clientClip; type = CT_REGION; -- cgit v1.2.3 From 8080ad26a72f8e72fb4c405f5e8a8d1b82c1e30d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:25:40 +0200 Subject: GCOps.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index beb9ef05f..6ab46c424 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -57,6 +57,7 @@ is" without express or implied warranty. #include "Holder.h" #include "Args.h" #include "Screen.h" +#include "Utils.h" #include "compext/Compext.h" @@ -787,7 +788,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, srcx, srcy, width, height); #endif - free(data); + SAFE_free(data); /* * If the source is a shared memory pixmap, the @@ -1007,7 +1008,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, srcx, srcy, width, height); #endif - free(data); + SAFE_free(data); /* * If the source is a shared memory pixmap, the @@ -1545,7 +1546,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, RESET_GC_TRAP(); } - free(newPoints); + SAFE_free(newPoints); } void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, -- cgit v1.2.3 From 7d25771da3eed13a2779792fa53fdac01d567bd4 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 22 Jul 2019 22:26:46 +0200 Subject: Keystroke.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index 662da6b04..d524e9e0b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -294,7 +294,7 @@ void nxagentInitKeystrokes(Bool force) if (force) { if (map != default_map) { - free(map); + SAFE_free(map); map = default_map; } fprintf(stderr, "Info: re-reading keystrokes configuration\n"); @@ -414,7 +414,7 @@ void nxagentInitKeystrokes(Bool force) #endif filename = NULL; } - free(homepath); + SAFE_free(homepath); if (map == default_map) { -- cgit v1.2.3 From 4421f787ddf102889ee65cd310cc50369540dbc8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 23 Jul 2019 20:10:43 +0200 Subject: Atoms.c: use SAFE_XFree and SAFE_free macros --- nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index c36c38e2f..2ee67b9bb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -43,6 +43,7 @@ #include "Screen.h" #include "Options.h" #include "Agent.h" +#include "Utils.h" /* * Set here the required log level. @@ -53,11 +54,6 @@ #undef TEST #undef DEBUG -#ifdef DEBUG -/* for validateString() */ -#include "Utils.h" -#endif - /* * These values should be moved in * the option repository. @@ -482,8 +478,8 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) fprintf(stderr, "nxagentInitAtomMap: WARNING! XInternAtoms request failed.\n"); #endif - free(atom_list); - free(name_list); + SAFE_free(atom_list); + SAFE_free(name_list); return 0; } @@ -523,8 +519,8 @@ static int nxagentInitAtomMap(char **atomNameList, int count, Atom *atomsRet) } } - free(atom_list); - free(name_list); + SAFE_free(atom_list); + SAFE_free(name_list); nxagentPrintAtomMapInfo("nxagentInitAtomMap: Exiting"); @@ -794,7 +790,7 @@ Atom nxagentRemoteToLocalAtom(Atom remote) #ifdef TEST fprintf(stderr, "%s: remote [%d (%s)] -> local [%d]\n", __func__, remote, string, local); #endif - XFree(string); + SAFE_XFree(string); return local; } -- cgit v1.2.3 From 504b1400eaf0fe5f2b0544857021484213825b01 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 23 Jul 2019 20:12:31 +0200 Subject: Clipboard.c: use SAFE_free --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 9c518801b..024d685ba 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -1783,8 +1783,7 @@ int nxagentInitClipboard(WindowPtr pWin) fprintf(stderr, "%s: Got called.\n", __func__); #endif - free(lastSelectionOwner); - lastSelectionOwner = NULL; + SAFE_free(lastSelectionOwner); lastSelectionOwner = (SelectionOwner *) malloc(nxagentMaxSelections * sizeof(SelectionOwner)); -- cgit v1.2.3 From e7451477e00896b188188af622ab1a870715203f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 28 Jun 2019 22:07:00 +0200 Subject: Events.c: refactor nxagentHandleKeypress --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 74781f638..c93842305 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2222,8 +2222,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) { - xEvent x; - if (nxagentXkbState.Initialized == 0) { if (X -> xkey.keycode == nxagentCapsLockKeycode) @@ -2255,15 +2253,15 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) nxagentXkbState.Num = (~nxagentXkbState.Num & 1); } + nxagentLastServerTime = X -> xkey.time; + nxagentLastEventTime = nxagentLastKeyPressTime = GetTimeInMillis(); - - memset(&x, 0, sizeof(xEvent)); + + xEvent x = {0}; x.u.u.type = KeyPress; x.u.u.detail = nxagentConvertKeycode(X -> xkey.keycode); x.u.keyButtonPointer.time = nxagentLastKeyPressTime; - nxagentLastServerTime = X -> xkey.time; - mieqEnqueue(&x); CriticalOutputPending = 1; -- cgit v1.2.3 From bcbf255104a1214c83e31a4266e38eb3c6369def Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 28 Jun 2019 22:09:23 +0200 Subject: Events.c: add more comments and TEST output --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index c93842305..89030b1b0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -1110,8 +1110,8 @@ FIXME: If we don't flush the queue here, it could happen /* FIXME: Don't enqueue the KeyRelease event if the key was not already pressed. This workaround avoids a fake - KeyPress is enqueued by the XKEYBOARD extension. - Another solution would be to let the events are + KeyPress being enqueued by the XKEYBOARD extension. + Another solution would be to let the events enqueued and to remove the KeyPress afterwards. */ if (BitIsOn(inputInfo.keyboard -> key -> down, @@ -1150,6 +1150,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was nxagentXkbNumTrap = 0; } + /* Calculate the time elapsed between this and the last event we + received. Add this delta to time we recorded for the last + KeyPress event we passed on to our clients. */ memset(&x, 0, sizeof(xEvent)); x.u.u.type = KeyRelease; x.u.u.detail = nxagentConvertKeycode(X.xkey.keycode); @@ -1165,8 +1168,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was x.u.keyButtonPointer.time = nxagentLastEventTime; } - if (!(nxagentCheckSpecialKeystroke(&X.xkey, &result)) && sendKey == 1) + /* do not send a KeyRelease for a special keystroke since we + also did not send a KeyPress event in that case */ + if (!(nxagentCheckSpecialKeystroke(&X.xkey, &result)) && (sendKey == 1)) { + #ifdef TEST + fprintf(stderr, "%s: passing KeyRelease event to clients\n", __func__); + #endif + mieqEnqueue(&x); CriticalOutputPending = 1; @@ -1178,6 +1187,12 @@ FIXME: Don't enqueue the KeyRelease event if the key was NXShadowEvent(nxagentDisplay, X); } } + else + { + #ifdef TEST + fprintf(stderr, "%s: NOT passing KeyRelease event to clients\n", __func__); + #endif + } break; } @@ -2241,6 +2256,9 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) if (nxagentCheckSpecialKeystroke(&X -> xkey, result)) { + #ifdef TEST + fprintf(stderr, "%s: NOT passing KeyPress event to clients\n", __func__); + #endif return 1; } @@ -2262,6 +2280,10 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) x.u.u.detail = nxagentConvertKeycode(X -> xkey.keycode); x.u.keyButtonPointer.time = nxagentLastKeyPressTime; + #ifdef TEST + fprintf(stderr, "%s: passing KeyPress event to clients\n", __func__); + #endif + mieqEnqueue(&x); CriticalOutputPending = 1; -- cgit v1.2.3 From 1d32e5368ab8d94a100144f741b00f4506e6eeff Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 28 Jun 2019 22:10:23 +0200 Subject: Keystroke.c: fix wrong return code The effect of this was that special keystrokes where detected and passed to the nxagent. E.g. pressing ctrl-alt-f for Fullscreen also produced an "f" in the current input window inside the nxagent. --- nx-X11/programs/Xserver/hw/nxagent/Keystroke.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c index d524e9e0b..fe7e10d82 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keystroke.c @@ -480,6 +480,9 @@ static enum nxagentSpecialKeystroke find_keystroke(XKeyEvent *X) return ret; } +/* + * returns True if a special keystroke has been pressed. *result will contain the action. + */ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) { enum nxagentSpecialKeystroke stroke = find_keystroke(X); @@ -629,5 +632,5 @@ Bool nxagentCheckSpecialKeystroke(XKeyEvent *X, enum HandleEventResult *result) case KEYSTROKE_MAX: break; } - return (*result == doNothing); + return (*result != doNothing); } -- cgit v1.2.3 From 17495dd6aedd27fb8a083fc841a7f297e6a8da8f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 5 May 2018 18:56:35 +0200 Subject: nxagent: simplify nxagentWaitEvents() no more need to pass down a struct, we now only pass the milliseconds and let the function do the rest. --- nx-X11/programs/Xserver/hw/nxagent/Client.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Events.c | 43 ++++++++++++++------------- nx-X11/programs/Xserver/hw/nxagent/Events.h | 2 +- nx-X11/programs/Xserver/hw/nxagent/Handlers.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 6 +--- nx-X11/programs/Xserver/hw/nxagent/Split.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Window.c | 6 +--- nxcomp/src/Loop.cpp | 4 +++ 8 files changed, 32 insertions(+), 35 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index 206b6d8e3..6ea0c4fcf 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -400,7 +400,7 @@ void nxagentWaitWakeupBySplit(ClientPtr client) fprintf(stderr, "++++++nxagentWaitWakeupBySplit: Yielding control to the NX transport.\n"); #endif - nxagentWaitEvents(nxagentDisplay, NULL); + nxagentWaitEvents(nxagentDisplay, 0); } } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 89030b1b0..0223667c4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -3303,7 +3303,6 @@ int nxagentHandleConfigureNotify(XEvent* X) ScreenPtr pScreen = nxagentScreen(X -> xconfigure.window); Bool doRandR = False; - struct timeval timeout; if (X -> xconfigure.window == nxagentDefaultWindows[pScreen -> myNum]) { @@ -3339,10 +3338,7 @@ int nxagentHandleConfigureNotify(XEvent* X) { newEvents = False; - timeout.tv_sec = 0; - timeout.tv_usec = 500 * 1000; - - nxagentWaitEvents(nxagentDisplay, &timeout); + nxagentWaitEvents(nxagentDisplay, 500); /* * This should also flush the NX link for us. @@ -3809,7 +3805,7 @@ int nxagentWaitForResource(GetResourceFuncPtr pGetResource, PredicateFuncPtr pPr while ((resource = (*pGetResource)(nxagentDisplay)) == -1) { - if (nxagentWaitEvents(nxagentDisplay, NULL) == -1) + if (nxagentWaitEvents(nxagentDisplay, 0) == -1) { return -1; } @@ -4490,14 +4486,11 @@ int nxagentPendingEvents(Display *dpy) } /* - * Blocks until an event becomes - * available. + * Blocks until an event becomes available. */ -int nxagentWaitEvents(Display *dpy, struct timeval *tm) +int nxagentWaitEvents(Display *dpy, useconds_t msec) { - XEvent ev; - #ifdef DEBUG fprintf(stderr, "nxagentWaitEvents called.\n"); #endif @@ -4505,33 +4498,41 @@ int nxagentWaitEvents(Display *dpy, struct timeval *tm) NXFlushDisplay(dpy, NXFlushLink); /* - * If the transport is not running we - * have to rely on Xlib to wait for an - * event. In this case the timeout is - * ignored. + * If the transport is not running we have to rely on Xlib to wait + * for an event. In this case the timeout is ignored. */ if (NXTransRunning(NX_FD_ANY) == 1) { - NXTransContinue(tm); + if (msec > 0) + { + struct timeval tm = { + .tv_sec = 0, + .tv_usec = msec * 1000 + }; + NXTransContinue(&tm); + } + else + { + NXTransContinue(NULL); + } } else { + XEvent ev; XPeekEvent(dpy, &ev); } /* - * Check if we encountered a display - * error. If we did, wait for the + * Check if we encountered a display error. If we did, wait for the * time requested by the caller. */ if (NXDisplayError(dpy) == 1) { - if (tm != NULL) + if (msec > 0) { - usleep(tm -> tv_sec * 1000 * 1000 + - tm -> tv_usec); + usleep(msec * 1000); } return -1; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.h b/nx-X11/programs/Xserver/hw/nxagent/Events.h index 5df0e1f05..8bc798945 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.h @@ -232,6 +232,6 @@ Bool nxagentPendingEvents(Display *dpy); #define nxagentCheckEvents(display, event, predicate, argument) \ XCheckIfEventNoFlush((display), (event), (predicate), (argument)) -int nxagentWaitEvents(Display *, struct timeval *); +int nxagentWaitEvents(Display *, useconds_t msec); #endif /* __Events_H__ */ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c index c9aea9cdd..7311889b7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c @@ -1255,7 +1255,7 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) while (nxagentTokens.pending == TOKENS_PENDING_LIMIT) { - if (nxagentWaitEvents(nxagentDisplay, NULL) == -1) + if (nxagentWaitEvents(nxagentDisplay, 0) == -1) { nxagentTokens.pending = 0; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 62634de60..8d578c084 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -364,7 +364,6 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after for (int i = 0; i < 100 && nxagentWMIsRunning; i++) { - struct timeval timeout; XEvent e; #ifdef TEST @@ -378,10 +377,7 @@ FIXME: We'll check for ReparentNotify and LeaveNotify events after XSync(nxagentDisplay, 0); - timeout.tv_sec = 0; - timeout.tv_usec = 50 * 1000; - - nxagentWaitEvents(nxagentDisplay, &timeout); + nxagentWaitEvents(nxagentDisplay, 50); } } else diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c index 11221ea99..d58d70bfd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Split.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c @@ -804,7 +804,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) fprintf(stderr, "nxagentWaitDrawable: Yielding control to the NX transport.\n"); #endif - nxagentWaitEvents(nxagentDisplay, NULL); + nxagentWaitEvents(nxagentDisplay, 0); } } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 357c6efbd..fc59973bd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -850,7 +850,6 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) * Change to fullscreen mode. */ - struct timeval timeout; int i; XEvent e; @@ -875,10 +874,7 @@ void nxagentSwitchAllScreens(ScreenPtr pScreen, Bool switchOn) XSync(nxagentDisplay, 0); - timeout.tv_sec = 0; - timeout.tv_usec = 50 * 1000; - - nxagentWaitEvents(nxagentDisplay, &timeout); + nxagentWaitEvents(nxagentDisplay, 50); } if (i < 100) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index ddffcd1ca..bb8a89d64 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -1565,6 +1565,10 @@ int NXTransRunning(int fd) return (control != NULL); } +// +// FIXME: why timeval? Passing milliseconds would be more convenient, +// the timeval struct/T_timestamp could be built on demand. +// int NXTransContinue(struct timeval *selectTs) { if (control != NULL) -- cgit v1.2.3 From d3869aa537a5711b680b5462569c141eab8109e7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 10 Aug 2019 23:42:45 +0200 Subject: nxagent: fix main window being garbled without inner windows Fixes ArcticaProject/nx-libs#733 --- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 0851daf97..f2b10fe45 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -255,8 +255,6 @@ InitRootWindow(WindowPtr pWin) else pWin->background.pixel = pScreen->whitePixel; backFlag |= CWBackPixel; - - MakeRootTile(pWin); #else if (!blackRoot && !whiteRoot) { MakeRootTile(pWin); -- cgit v1.2.3 From 817c3c6fc4fc8461668851803bfa3db77b7f7e6f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 10 Aug 2019 23:56:22 +0200 Subject: NXwindow.c: simplify window background code --- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index f2b10fe45..f67295c43 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -249,18 +249,14 @@ InitRootWindow(WindowPtr pWin) pWin->optional->cursor = rootCursor; rootCursor->refcnt++; -#ifdef NXAGENT_SPLASH - if (blackRoot) - pWin->background.pixel = pScreen->blackPixel; - else - pWin->background.pixel = pScreen->whitePixel; - backFlag |= CWBackPixel; -#else +#ifndef NXAGENT_SPLASH if (!blackRoot && !whiteRoot) { MakeRootTile(pWin); backFlag |= CWBackPixmap; } - else { + else +#else + { if (blackRoot) pWin->background.pixel = pScreen->blackPixel; else -- cgit v1.2.3 From 8eeaa40b1b0bb76e8bc74534576e8dca98063c3e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 11 Aug 2019 00:21:44 +0200 Subject: dix: add whiteroot flag Before there was no way of getting a white background despite having the approriate code. Backport of this commit: commit cb0a565d2b2cf8823abbd77b4426cc2237731dc1 Author: Daniel Stone Date: Fri Aug 18 17:04:48 2006 +0300 dix: add whiteroot flag Add a -wr option to use a white root window, and use a BackPixel rather than BackPixmap for both white and black root windows. Fixes ArcticaProject/nx-libs#832 --- nx-X11/programs/Xserver/hw/nxagent/Init.c | 3 ++- nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 | 6 ++++-- nx-X11/programs/Xserver/os/utils.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 1e24a618e..2a0bceaf5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -413,7 +413,8 @@ FIXME: These variables, if not removed at all because have probably * background. */ - blackRoot = TRUE; + if (!whiteRoot) + blackRoot = TRUE; nxagentInitKeystrokes(False); diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 index 6804032a2..34ac7d7d0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 +++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 @@ -142,8 +142,10 @@ to authenticate access. See also the \fIxdm\fP(1) and disables backing store support on all screens. .TP 8 .B \-br -sets the default root window to solid black instead of the standard root weave -pattern. +sets the default root window to solid black (default). +.TP 8 +.B \-wr +sets the default root window to solid white. .TP 8 .B \-c turns off key-click. diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 5634bb621..4d81ff927 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -634,6 +634,7 @@ void UseMsg(void) ErrorF("v video blanking for screen-saver\n"); ErrorF("-v screen-saver without video blanking\n"); ErrorF("-wm WhenMapped default backing-store\n"); + ErrorF("-wr create root window with white background\n"); ErrorF("-maxbigreqsize set maximal bigrequest size \n"); #ifdef PANORAMIX ErrorF("+xinerama Enable XINERAMA (PanoramiX) extension\n"); @@ -996,6 +997,8 @@ ProcessCommandLine(int argc, char *argv[]) defaultScreenSaverBlanking = DontPreferBlanking; else if ( strcmp( argv[i], "-wm") == 0) defaultBackingStore = WhenMapped; + else if ( strcmp( argv[i], "-wr") == 0) + whiteRoot = TRUE; else if ( strcmp( argv[i], "-maxbigreqsize") == 0) { if(++i < argc) { long reqSizeArg = atol(argv[i]); -- cgit v1.2.3 From 9cd602b271cc846d654f7f5d9a455368e9ca2612 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 11 Aug 2019 01:47:16 +0200 Subject: Splash.c: do not wait in nxagent mode The splash window is only shown in x2go mode. In nxagent mode the splash window was also shown, but empty (and thus invisible). And the code waited for the splash window to disappear. Fix this by skipping _all_ the splash stuff in nxagent mode. --- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 5 ++++- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 15 ++++++--------- nx-X11/programs/Xserver/hw/nxagent/Window.c | 17 ++++++++++------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index f67295c43..3cd8d0ce9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -138,11 +138,14 @@ extern void nxagentSetVersionProperty(WindowPtr pWin); void nxagentClearSplash(WindowPtr pW) { + if (!pW) + return; + ScreenPtr pScreen = pW->drawable.pScreen; if (pW->backgroundState == BackgroundPixmap) { - (*pScreen->DestroyPixmap)(pW->background.pixmap); + (*pScreen->DestroyPixmap)(pW->background.pixmap); } pW->backgroundState = BackgroundPixel; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index bc86fed36..e2e88674b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -85,6 +85,12 @@ int nxagentShowSplashWindow(Window parentWindow) XSetWindowAttributes attributes; GC gc; + /* + * Show splash window only when running as X2Go Agent + */ + if(!nxagentX2go) + return False; + #ifdef TEST fprintf(stderr, "nxagentShowSplashWindow: Got called.\n"); #endif @@ -175,15 +181,6 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) XPoint rect[4]; int w, h, c, w2, h2; - /* - * Show only X2GO Logo when running as X2Go Agent - */ - if(! nxagentX2go) - { - nxagentPixmapLogo = 0L; - return; - } - #ifdef DEBUG fprintf(stderr, "nxagentPaintLogo: Got called.\n"); #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index fc59973bd..86ae1d607 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -670,15 +670,18 @@ Bool nxagentDestroyWindow(WindowPtr pWin) nxagentSplashCount); #endif - if (nxagentSplashCount == 1) + if (nxagentRootTileWindow) { - XClearWindow(nxagentDisplay, nxagentWindowPriv(nxagentRootTileWindow) -> window); - } + if (nxagentSplashCount == 1) + { + XClearWindow(nxagentDisplay, nxagentWindowPriv(nxagentRootTileWindow) -> window); + } - if (pWin == nxagentRootTileWindow) - { - nxagentWindowPriv(nxagentRootTileWindow)->window = None; - nxagentRootTileWindow = None; + if (pWin == nxagentRootTileWindow) + { + nxagentWindowPriv(nxagentRootTileWindow)->window = None; + nxagentRootTileWindow = None; + } } pWindowPriv->window = None; -- cgit v1.2.3 From 208e58fb7594b24dc6eb8f287092d5080edabab5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 11 Aug 2019 01:51:37 +0200 Subject: Splash.c: drop return code of nxagentShowSplashWindow nobody was checking it. --- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 6 ++---- nx-X11/programs/Xserver/hw/nxagent/Splash.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index e2e88674b..387c859ae 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -78,7 +78,7 @@ extern Atom nxagentWMStart; extern Atom serverCutProperty; -int nxagentShowSplashWindow(Window parentWindow) +void nxagentShowSplashWindow(Window parentWindow) { XWindowAttributes getAttributes; XWindowChanges values; @@ -89,7 +89,7 @@ int nxagentShowSplashWindow(Window parentWindow) * Show splash window only when running as X2Go Agent */ if(!nxagentX2go) - return False; + return; #ifdef TEST fprintf(stderr, "nxagentShowSplashWindow: Got called.\n"); @@ -172,8 +172,6 @@ int nxagentShowSplashWindow(Window parentWindow) GetTimeInMillis() - startTime); } #endif - - return True; } void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.h b/nx-X11/programs/Xserver/hw/nxagent/Splash.h index 444f1eed0..2057390fc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.h @@ -47,7 +47,7 @@ extern Window nxagentSplashWindow; extern int nxagentWMPassed; -extern int nxagentShowSplashWindow(Window); +extern void nxagentShowSplashWindow(Window); extern void nxagentRemoveSplashWindow(WindowPtr pWin); -- cgit v1.2.3 From 48c43c8370ba1a2b246c41e48adcffad7fdc0b9a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 11 Aug 2019 01:59:42 +0200 Subject: Splash.c: code cleanup --- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 387c859ae..e983048eb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -64,7 +64,7 @@ int nxagentLogoRed; int nxagentLogoBlack; int nxagentLogoGray; -void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); +static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); /* * From Screen.c. @@ -92,14 +92,14 @@ void nxagentShowSplashWindow(Window parentWindow) return; #ifdef TEST - fprintf(stderr, "nxagentShowSplashWindow: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif #ifdef NXAGENT_TIMESTAMP { extern unsigned long startTime; - fprintf(stderr, "nxagentShowSplashWindow: Initializing splash start at [%d] milliseconds.\n", + fprintf(stderr, "%s: Initializing splash start at [%d] milliseconds.\n", __func__, GetTimeInMillis() - startTime); } #endif @@ -139,7 +139,7 @@ void nxagentShowSplashWindow(Window parentWindow) getAttributes.height = nxagentOption(RootHeight); #ifdef TEST - fprintf(stderr, "nxagentShowSplashWindow: Going to create new splash window.\n"); + fprintf(stderr, "%s: Going to create new splash window.\n", __func__); #endif nxagentSplashWindow = @@ -152,7 +152,7 @@ void nxagentShowSplashWindow(Window parentWindow) BlackPixel (nxagentDisplay, 0)); #ifdef TEST - fprintf(stderr, "nxagentShowSplashWindow: Created new splash window with id [%ld].\n", + fprintf(stderr, "%s: Created new splash window with id [%ld].\n", __func__, nxagentSplashWindow); #endif @@ -168,7 +168,7 @@ void nxagentShowSplashWindow(Window parentWindow) #ifdef NXAGENT_TIMESTAMP { extern unsigned long startTime; - fprintf(stderr, "nxagentShowSplashWindow: Splash ends [%d] milliseconds.\n", + fprintf(stderr, "%s: Splash ends [%d] milliseconds.\n", __func__, GetTimeInMillis() - startTime); } #endif @@ -176,26 +176,25 @@ void nxagentShowSplashWindow(Window parentWindow) void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) { - XPoint rect[4]; - int w, h, c, w2, h2; - #ifdef DEBUG - fprintf(stderr, "nxagentPaintLogo: Got called.\n"); + fprintf(stderr, "%s: Got called.\n", __func__); #endif #ifdef NXAGENT_LOGO_DEBUG - fprintf(stderr, "nxagentPaintLogo: begin\n"); - fprintf(stderr, "nxagentPaintLogo: gen params are: w=%d h=%d d=%d r=%x w=%x b=%x\n",width, height, + fprintf(stderr, "%s: begin\n", __func__); + fprintf(stderr, "%s: gen params are: w=%d h=%d d=%d r=%x w=%x b=%x\n", __func__, + width, height, nxagentLogoDepth, nxagentLogoRed, nxagentLogoWhite, nxagentLogoBlack); #endif - w = width/scale; - h = height/scale; + int w = width/scale; + int h = height/scale; - w2 = w/2; - h2 = h/2; + int w2 = w/2; + int h2 = h/2; + int c; if (height > width) { c = w/30; @@ -205,6 +204,7 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) c = w/48; } + XPoint rect[4]; rect[0].x = 0; rect[0].y = 0; rect[1].x = 0; rect[1].y = h; rect[2].x = w; rect[2].y = h; @@ -225,7 +225,7 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) XFillPolygon(nxagentDisplay, nxagentPixmapLogo, gc, rect, 4, Convex, CoordModeOrigin); #ifdef NXAGENT_LOGO_DEBUG - fprintf(stderr, "filled first poly\n"); + fprintf(stderr, "%s: filled first poly\n", __func__); #endif XSetForeground(nxagentDisplay, gc, nxagentLogoRed); @@ -374,16 +374,17 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) XSetWindowBackgroundPixmap(nxagentDisplay, win, nxagentPixmapLogo); #ifdef NXAGENT_LOGO_DEBUG - fprintf(stderr, "nxagentPaintLogo: end\n"); + fprintf(stderr, "%s: end\n", __func__); #endif } void nxagentRemoveSplashWindow(WindowPtr pWin) { - if (nxagentReconnectTrap) return; + if (nxagentReconnectTrap) + return; #ifdef TEST - fprintf(stderr, "nxagentRemoveSplashWindow: Destroying the splash window.\n"); + fprintf(stderr, "%s: Destroying the splash window.\n", __func__); #endif if (!nxagentWMPassed) @@ -402,7 +403,7 @@ void nxagentRemoveSplashWindow(WindowPtr pWin) nxagentRefreshWindows(screenInfo.screens[0]->root); #ifdef TEST - fprintf(stderr, "nxagentRemoveSplashWindow: setting the ownership of %s (%d) on window 0x%lx\n", + fprintf(stderr, "%s: setting the ownership of %s (%d) on window 0x%lx\n", __func__ "NX_CUT_BUFFER_SERVER", (int)serverCutProperty, nxagentWindow(screenInfo.screens[0]->root)); #endif @@ -413,7 +414,6 @@ void nxagentRemoveSplashWindow(WindowPtr pWin) if (nxagentPixmapLogo) { XFreePixmap(nxagentDisplay, nxagentPixmapLogo); - nxagentPixmapLogo = (Pixmap) 0; } } -- cgit v1.2.3 From bfb4e9ac991271e9b4149094f1cc1aaa79987c74 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 15 Aug 2019 22:04:07 +0200 Subject: Splash.c: nxagentRemoveSplashWindow: drop unused parameter --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Splash.h | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 339994e6c..7020a679e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -380,7 +380,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio if (!nxagentWMPassed && (nxagentWMtimeout < currentDispatch)) { - nxagentRemoveSplashWindow(NULL); + nxagentRemoveSplashWindow(); } nxagentClients = nClients; @@ -590,7 +590,7 @@ ProcReparentWindow(register ClientPtr client) if (!nxagentWMPassed) { - nxagentRemoveSplashWindow(pWin); + nxagentRemoveSplashWindow(); } pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 47f636316..e29fc3200 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -680,7 +680,7 @@ Bool nxagentReconnectSession(void) #endif saveAgentState("RUNNING"); - nxagentRemoveSplashWindow(NULL); + nxagentRemoveSplashWindow(); /* * We let the proxy flush the link on our behalf diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 8d578c084..111a3fdaa 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3108,7 +3108,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr { if (!nxagentWMPassed) { - nxagentRemoveSplashWindow(NULL); + nxagentRemoveSplashWindow(); } NXShadowExportChanges(&numRects, &ptBox); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index e983048eb..74322648a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -378,7 +378,7 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) #endif } -void nxagentRemoveSplashWindow(WindowPtr pWin) +void nxagentRemoveSplashWindow(void) { if (nxagentReconnectTrap) return; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.h b/nx-X11/programs/Xserver/hw/nxagent/Splash.h index 2057390fc..52adbc340 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.h @@ -48,7 +48,6 @@ extern Window nxagentSplashWindow; extern int nxagentWMPassed; extern void nxagentShowSplashWindow(Window); - -extern void nxagentRemoveSplashWindow(WindowPtr pWin); +extern void nxagentRemoveSplashWindow(); #endif /* __Splash_H__ */ -- cgit v1.2.3 From e12983a677c84794f5ff34e5b14c3feb78878a9c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 15 Aug 2019 22:06:14 +0200 Subject: nxagent: drop nxagentRootTileWindow We either use a solid black or a white background and no backround pixmap. So nxagentRootTileWindow is always empty and we can drop all stuff around it. remove nxagentSplashCount, too, since it is no longer checked anywhere. --- nx-X11/programs/Xserver/dix/window.c | 2 - nx-X11/programs/Xserver/hw/nxagent/Events.c | 15 ----- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 86 ++------------------------- nx-X11/programs/Xserver/hw/nxagent/Window.c | 51 ---------------- 4 files changed, 4 insertions(+), 150 deletions(-) diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c index 79045767f..ee146d783 100644 --- a/nx-X11/programs/Xserver/dix/window.c +++ b/nx-X11/programs/Xserver/dix/window.c @@ -305,7 +305,6 @@ SetWindowToDefaults(register WindowPtr pWin) #endif } -#ifndef NXAGENT_SERVER static void MakeRootTile(WindowPtr pWin) { @@ -348,7 +347,6 @@ MakeRootTile(WindowPtr pWin) FreeScratchGC(pGC); } -#endif /* NXAGENT_SERVER */ WindowPtr AllocateWindow(ScreenPtr pScreen) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 0223667c4..553eaccd6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -124,7 +124,6 @@ extern Bool nxagentOnce; extern WindowPtr nxagentRootTileWindow; -extern int nxagentSplashCount; extern int nxagentLastClipboardClient; @@ -2450,20 +2449,6 @@ FIXME: This can be maybe optimized by consuming the } } - if (nxagentRootTileWindow != NULL) - { - if (nxagentWindowPriv(nxagentRootTileWindow) -> window == nxagentWindowPriv(pWin) -> window && - nxagentSplashCount == 1 && X -> xexpose.count == 0) - { - #ifdef DEBUG - fprintf(stderr, "nxagentHandleExposeEvent: Clearing root tile window id [%u].\n", - nxagentWindowPriv(nxagentRootTileWindow) -> window); - #endif - - XClearWindow(nxagentDisplay, nxagentWindowPriv(nxagentRootTileWindow) -> window); - } - } - RegionUninit(&sum); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 3cd8d0ce9..3dcb552e5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -114,10 +114,6 @@ Equipment Corporation. #include "Drawable.h" #include "Colormap.h" -/* prototypes (only MakeRootTile() required here) */ - -static void MakeRootTile(WindowPtr pWin); - #include "../../dix/window.c" extern Bool nxagentWMIsRunning; @@ -132,72 +128,8 @@ extern Bool nxagentScreenTrap; #undef TEST #undef DEBUG -WindowPtr nxagentRootTileWindow; - extern void nxagentSetVersionProperty(WindowPtr pWin); -void nxagentClearSplash(WindowPtr pW) -{ - if (!pW) - return; - - ScreenPtr pScreen = pW->drawable.pScreen; - - if (pW->backgroundState == BackgroundPixmap) - { - (*pScreen->DestroyPixmap)(pW->background.pixmap); - } - - pW->backgroundState = BackgroundPixel; - pW->background.pixel = nxagentLogoBlack; - - (*pScreen->ChangeWindowAttributes)(pW, CWBackPixmap|CWBackPixel); -} - -static void -MakeRootTile(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - GCPtr pGC; - unsigned char back[128]; - int len = BitmapBytePad(sizeof(long)); - register unsigned char *from, *to; - register int i, j; - - pWin->background.pixmap = (*pScreen->CreatePixmap)(pScreen, 4, 4, - pScreen->rootDepth, 0); - - pWin->backgroundState = BackgroundPixmap; - pGC = GetScratchGC(pScreen->rootDepth, pScreen); - if (!pWin->background.pixmap || !pGC) - FatalError("could not create root tile"); - - { - CARD32 attributes[2]; - - attributes[0] = pScreen->whitePixel; - attributes[1] = pScreen->blackPixel; - - (void)ChangeGC(pGC, GCForeground | GCBackground, attributes); - } - - ValidateGC((DrawablePtr)pWin->background.pixmap, pGC); - - from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb; - to = back; - - for (i = 4; i > 0; i--, from++) - for (j = len; j > 0; j--) - *to++ = *from; - - (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1, - 0, 0, len, 4, 0, XYBitmap, (char *)back); - - FreeScratchGC(pGC); - - nxagentRootTileWindow = pWin; -} - void InitRootWindow(WindowPtr pWin) { @@ -252,21 +184,11 @@ InitRootWindow(WindowPtr pWin) pWin->optional->cursor = rootCursor; rootCursor->refcnt++; -#ifndef NXAGENT_SPLASH - if (!blackRoot && !whiteRoot) { - MakeRootTile(pWin); - backFlag |= CWBackPixmap; - } + if (blackRoot) + pWin->background.pixel = pScreen->blackPixel; else -#else - { - if (blackRoot) - pWin->background.pixel = pScreen->blackPixel; - else - pWin->background.pixel = pScreen->whitePixel; - backFlag |= CWBackPixel; - } -#endif + pWin->background.pixel = pScreen->whitePixel; + backFlag |= CWBackPixel; pWin->backingStore = defaultBackingStore; pWin->forcedBS = (defaultBackingStore != NotUseful); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 86ae1d607..fe6efb52c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -119,12 +119,6 @@ extern WindowPtr nxagentRootTileWindow; extern Bool nxagentReportPrivateWindowIds; -/* - * Also referenced in Events.c. - */ - -int nxagentSplashCount = 0; - #define RECTLIMIT 25 #define BSPIXMAPLIMIT 128 @@ -156,12 +150,6 @@ Bool nxagentIsIconic(WindowPtr); int GetWindowProperty(WindowPtr, Atom, long, long, Bool, Atom, Atom*, int*, unsigned long*, unsigned long*, unsigned char**); -/* - * From NXwindow.c. - */ - -void nxagentClearSplash(WindowPtr pWin); - /* * Other local functions. */ @@ -269,16 +257,6 @@ Bool nxagentCreateWindow(WindowPtr pWin) return True; } - nxagentSplashCount++; - - if (nxagentSplashCount == 2) - { - nxagentClearSplash(nxagentRootTileWindow); - } - #ifdef NXAGENT_LOGO_DEBUG - fprintf(stderr, "nxagentCreateWindow: nxagentSplashCount [%d]\n", nxagentSplashCount); - #endif - if (pWin->drawable.class == InputOnly) { mask = CWEventMask; @@ -488,14 +466,6 @@ Bool nxagentCreateWindow(WindowPtr pWin) nxagentWindowPriv(pWin)->siblingAbove = None; nxagentWindowPriv(pWin)->pPicture = NULL; - if (nxagentRootTileWindow) - { - if (nxagentWindowPriv(pWin)->window != nxagentWindowPriv(nxagentRootTileWindow)->window) - { - XClearWindow(nxagentDisplay, nxagentWindowPriv(nxagentRootTileWindow)->window); - } - } - if (pWin->nextSib) { nxagentWindowPriv(pWin->nextSib)->siblingAbove = nxagentWindow(pWin); @@ -663,27 +633,6 @@ Bool nxagentDestroyWindow(WindowPtr pWin) nxagentRootlessDelTopLevelWindow(pWin); } - nxagentSplashCount--; - - #ifdef DEBUG - fprintf(stderr, "nxagentDestroyWindow: The splash counter is now [%d].\n", - nxagentSplashCount); - #endif - - if (nxagentRootTileWindow) - { - if (nxagentSplashCount == 1) - { - XClearWindow(nxagentDisplay, nxagentWindowPriv(nxagentRootTileWindow) -> window); - } - - if (pWin == nxagentRootTileWindow) - { - nxagentWindowPriv(nxagentRootTileWindow)->window = None; - nxagentRootTileWindow = None; - } - } - pWindowPriv->window = None; if (pWin -> optional) -- cgit v1.2.3 From 41bfed975b3145f1ac345893d118deb98ca00cc0 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 15 Aug 2019 22:10:45 +0200 Subject: Splash.c: remove global variables for colors Make them defines. Also determine the screen depth dynamically. --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 16 ---------------- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 16 ++++++++-------- nx-X11/programs/Xserver/hw/nxagent/Splash.h | 6 ------ 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 1c18ad1a3..c25afc597 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1387,15 +1387,6 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. nxagentChangeOption(BorderWidth, 1); } - nxagentLogoDepth = DefaultDepth(nxagentDisplay, - DefaultScreen(nxagentDisplay) - ); - - nxagentLogoBlack = 0x000000; - nxagentLogoRed = 0xff0000; - nxagentLogoWhite = 0xffffff; - nxagentLogoGray = 0x222222; - #ifdef WATCH fprintf(stderr, "nxagentOpenDisplay: Watchpoint 5.1.\n"); @@ -2827,13 +2818,6 @@ Bool nxagentReconnectDisplay(void *p0) nxagentConfineWindow); #endif - nxagentLogoDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); - - nxagentLogoBlack = 0x000000; - nxagentLogoRed = 0xff0000; - nxagentLogoWhite = 0xffffff; - nxagentLogoGray = 0x222222; - useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape); /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 74322648a..91f599cc6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -58,11 +58,10 @@ * Colors used to paint the splash screen. */ -int nxagentLogoDepth; -int nxagentLogoWhite; -int nxagentLogoRed; -int nxagentLogoBlack; -int nxagentLogoGray; +#define nxagentLogoWhite 0xffffff +#define nxagentLogoRed 0xff0000 +#define nxagentLogoBlack 0x000000 +#define nxagentLogoGray 0x222222 static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); @@ -176,6 +175,8 @@ void nxagentShowSplashWindow(Window parentWindow) void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) { + int depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); + #ifdef DEBUG fprintf(stderr, "%s: Got called.\n", __func__); #endif @@ -183,9 +184,8 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) #ifdef NXAGENT_LOGO_DEBUG fprintf(stderr, "%s: begin\n", __func__); fprintf(stderr, "%s: gen params are: w=%d h=%d d=%d r=%x w=%x b=%x\n", __func__, - width, height, - nxagentLogoDepth, nxagentLogoRed, - nxagentLogoWhite, nxagentLogoBlack); + width, height, depth, + nxagentLogoRed, nxagentLogoWhite, nxagentLogoBlack); #endif int w = width/scale; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.h b/nx-X11/programs/Xserver/hw/nxagent/Splash.h index 52adbc340..5f7547e57 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.h @@ -37,12 +37,6 @@ extern int XdmcpTimeOutRtx; extern int XdmcpStartTime; extern int nxagentXdmcpUp; -extern int nxagentLogoDepth; -extern int nxagentLogoWhite; -extern int nxagentLogoRed; -extern int nxagentLogoBlack; -extern int nxagentLogoGray; - extern Window nxagentSplashWindow; extern int nxagentWMPassed; -- cgit v1.2.3 From 5bb5adc8a137833db7c6cba3ba1bc2f25960b048 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 15 Aug 2019 22:33:35 +0200 Subject: Splash.c: make Splash logo work with white background (-wr) mode, too --- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 53 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 91f599cc6..2945717c4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -58,10 +58,10 @@ * Colors used to paint the splash screen. */ -#define nxagentLogoWhite 0xffffff -#define nxagentLogoRed 0xff0000 -#define nxagentLogoBlack 0x000000 -#define nxagentLogoGray 0x222222 +#define nxagentLogoWhite 0xffffff +#define nxagentLogoBlack 0x000000 +#define nxagentLogoDarkGray 0x222222 +#define nxagentLogoLightGray 0xbbbbbb static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); @@ -183,9 +183,9 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) #ifdef NXAGENT_LOGO_DEBUG fprintf(stderr, "%s: begin\n", __func__); - fprintf(stderr, "%s: gen params are: w=%d h=%d d=%d r=%x w=%x b=%x\n", __func__, + fprintf(stderr, "%s: gen params are: w=%d h=%d d=%d w=%x b=%x g1=%x g2=%x \n", __func__, width, height, depth, - nxagentLogoRed, nxagentLogoWhite, nxagentLogoBlack); + nxagentLogoWhite, nxagentLogoBlack, nxagentLogoDarkGray, nxagentLogoLightGray); #endif int w = width/scale; @@ -204,43 +204,52 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) c = w/48; } - XPoint rect[4]; - rect[0].x = 0; rect[0].y = 0; - rect[1].x = 0; rect[1].y = h; - rect[2].x = w; rect[2].y = h; - rect[3].x = w; rect[3].y = 0; - XSetFunction(nxagentDisplay, gc, GXcopy); XSetFillStyle(nxagentDisplay, gc, FillSolid); - XSetForeground(nxagentDisplay, gc, nxagentLogoBlack); - XSetBackground(nxagentDisplay, gc, nxagentLogoRed); - - nxagentPixmapLogo = XCreatePixmap(nxagentDisplay, win, width, height, nxagentLogoDepth); + nxagentPixmapLogo = XCreatePixmap(nxagentDisplay, win, width, height, depth); if (!nxagentPixmapLogo) { return; } + if (blackRoot) + { + XSetForeground(nxagentDisplay, gc, nxagentLogoBlack); + XSetBackground(nxagentDisplay, gc, nxagentLogoWhite); + } + else + { + XSetForeground(nxagentDisplay, gc, nxagentLogoWhite); + XSetBackground(nxagentDisplay, gc, nxagentLogoBlack); + } + + XPoint rect[4]; + rect[0].x = 0; rect[0].y = 0; + rect[1].x = 0; rect[1].y = h; + rect[2].x = w; rect[2].y = h; + rect[3].x = w; rect[3].y = 0; + + /* paint background */ XFillPolygon(nxagentDisplay, nxagentPixmapLogo, gc, rect, 4, Convex, CoordModeOrigin); #ifdef NXAGENT_LOGO_DEBUG fprintf(stderr, "%s: filled first poly\n", __func__); #endif - XSetForeground(nxagentDisplay, gc, nxagentLogoRed); - XSetBackground(nxagentDisplay, gc, nxagentLogoWhite); - /* * Draw X2GO Logo */ + if (blackRoot) + XSetForeground(nxagentDisplay, gc, nxagentLogoDarkGray); + else + XSetForeground(nxagentDisplay, gc, nxagentLogoLightGray); + /* - * Begin 'X'. + * Start 'X'. */ - XSetForeground(nxagentDisplay, gc, nxagentLogoGray); - XSetBackground(nxagentDisplay, gc, nxagentLogoWhite); rect[0].x = w2-7*c; rect[0].y = h2-5*c; rect[1].x = w2-8*c; rect[1].y = h2-5*c; rect[2].x = w2-4*c; rect[2].y = h2+3*c; -- cgit v1.2.3 From bd002ffc51350dab01b188fdabbdcf6218497956 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 12:38:53 +0200 Subject: Splash.c: move some variables to Splash.c They belong there... --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 -- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 111a3fdaa..1298dc9ea 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -147,8 +147,6 @@ Window nxagentScreenSaverWindows[MAXSCREENS]; #ifdef NXAGENT_ONSTART Atom nxagentWMStart; -Window nxagentSplashWindow = None; -Pixmap nxagentPixmapLogo; #endif ScreenPtr nxagentDefaultScreen = NULL; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 2945717c4..28c5599af 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -63,6 +63,9 @@ #define nxagentLogoDarkGray 0x222222 #define nxagentLogoLightGray 0xbbbbbb +Pixmap nxagentPixmapLogo; +Window nxagentSplashWindow = None; + static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); /* -- cgit v1.2.3 From 784846317f89d9fb9a4bfefffcc914a8895b231f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 12:46:21 +0200 Subject: nxagent: rename nxagentWMStart to nxagentReadyAtom This better reflects its purpose: Tell listeners we are ready. --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 1298dc9ea..27f72d566 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -146,7 +146,7 @@ Window nxagentInputWindows[MAXSCREENS]; Window nxagentScreenSaverWindows[MAXSCREENS]; #ifdef NXAGENT_ONSTART -Atom nxagentWMStart; +Atom nxagentReadyAtom; #endif ScreenPtr nxagentDefaultScreen = NULL; @@ -927,7 +927,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, nxagentQueryAtoms(pScreen); #ifdef NXAGENT_ONSTART - nxagentWMStart = nxagentAtoms[3]; /* WM_NX_READY */ + nxagentReadyAtom = nxagentAtoms[3]; /* WM_NX_READY */ #endif /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 28c5599af..c3f6f101e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -72,7 +72,7 @@ static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height * From Screen.c. */ -extern Atom nxagentWMStart; +extern Atom nxagentReadyAtom; /* * From Clipboard.c. @@ -106,7 +106,7 @@ void nxagentShowSplashWindow(Window parentWindow) } #endif - XSetSelectionOwner(nxagentDisplay, nxagentWMStart, None, CurrentTime); + XSetSelectionOwner(nxagentDisplay, nxagentReadyAtom, None, CurrentTime); nxagentWMPassed = False; @@ -401,7 +401,7 @@ void nxagentRemoveSplashWindow(void) if (!nxagentWMPassed) { - XSetSelectionOwner(nxagentDisplay, nxagentWMStart, + XSetSelectionOwner(nxagentDisplay, nxagentReadyAtom, nxagentDefaultWindows[0], CurrentTime); nxagentWMPassed = True; -- cgit v1.2.3 From 0f5e873dc312a6f2c88989d5379d3c4f442ef34d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 12:54:10 +0200 Subject: nxagent: drop NXAGENT_SPLASH There was only one (commented) section using it. --- nx-X11/programs/Xserver/hw/nxagent/Imakefile | 1 - nx-X11/programs/Xserver/hw/nxagent/Window.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile index 5a3a999f4..b3450440e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile +++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile @@ -240,7 +240,6 @@ DEFINES = \ -DNXAGENT_VISIBILITY \ -DNXAGENT_WAKEUP=1000 \ -DNXAGENT_ONSTART \ - -DNXAGENT_SPLASH \ -DNXAGENT_ARTSD \ -DNXAGENT_RANDR_MODE_PREFIX \ -UNX_DEBUG_INPUT \ diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index fe6efb52c..59b33b6be 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -1436,7 +1436,6 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) #endif } - #ifdef NXAGENT_SPLASH /* * This should bring again the splash window * on top, so why the else clause? Is this @@ -1462,7 +1461,6 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) * } * } */ - #endif /* NXAGENT_SPLASH */ if (mask & CW_RootlessRestack) { -- cgit v1.2.3 From db4c220b2aef5d2c5a8bc9def2558491ac3d7655 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 12:55:28 +0200 Subject: nxagent: add NXAGENT_ONSTART where missing There were some locations referenceing a variable that was only availabe with NXAGENT_ONSTART set --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 2 ++ nx-X11/programs/Xserver/hw/nxagent/Splash.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 7020a679e..c49cae51e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -141,7 +141,9 @@ void nxagentWaitDisplay(void); void nxagentListRemoteFonts(const char *, int); +#ifdef NXAGENT_ONSTART unsigned int nxagentWMtimeout = 0; +#endif Bool nxagentWMPassed = False; /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index c3f6f101e..6fa092a7d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -72,7 +72,9 @@ static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height * From Screen.c. */ +#ifdef NXAGENT_ONSTART extern Atom nxagentReadyAtom; +#endif /* * From Clipboard.c. @@ -106,7 +108,9 @@ void nxagentShowSplashWindow(Window parentWindow) } #endif + #ifdef NXAGENT_ONSTART XSetSelectionOwner(nxagentDisplay, nxagentReadyAtom, None, CurrentTime); + #endif nxagentWMPassed = False; @@ -401,8 +405,10 @@ void nxagentRemoveSplashWindow(void) if (!nxagentWMPassed) { + #ifdef NXAGENT_ONSTART XSetSelectionOwner(nxagentDisplay, nxagentReadyAtom, nxagentDefaultWindows[0], CurrentTime); + #endif nxagentWMPassed = True; } -- cgit v1.2.3 From 60a3c9b0ab58d2ab1574de84b421f0f9e5136b75 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 13:02:01 +0200 Subject: nxagent: move nxagentWMPassed to Splash.c It is only relevant there. --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 10 +++------- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 5 +---- nx-X11/programs/Xserver/hw/nxagent/Splash.c | 4 ++++ nx-X11/programs/Xserver/hw/nxagent/Splash.h | 2 -- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index c49cae51e..0ad26b0bb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -144,7 +144,6 @@ void nxagentListRemoteFonts(const char *, int); #ifdef NXAGENT_ONSTART unsigned int nxagentWMtimeout = 0; #endif -Bool nxagentWMPassed = False; /* * Timeouts based on screen saver time. @@ -380,9 +379,9 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio * that the agent is ready. */ - if (!nxagentWMPassed && (nxagentWMtimeout < currentDispatch)) + if (nxagentWMtimeout < currentDispatch) { - nxagentRemoveSplashWindow(); + nxagentRemoveSplashWindow(); } nxagentClients = nClients; @@ -590,10 +589,7 @@ ProcReparentWindow(register ClientPtr client) if (!pWin) return(BadWindow); - if (!nxagentWMPassed) - { - nxagentRemoveSplashWindow(); - } + nxagentRemoveSplashWindow(); pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client, DixWriteAccess); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 27f72d566..434389504 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3104,10 +3104,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr if (result == 1) { - if (!nxagentWMPassed) - { - nxagentRemoveSplashWindow(); - } + nxagentRemoveSplashWindow(); NXShadowExportChanges(&numRects, &ptBox); pBox = (BoxRec *)ptBox; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.c b/nx-X11/programs/Xserver/hw/nxagent/Splash.c index 6fa092a7d..8f3bc1ede 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.c @@ -65,6 +65,7 @@ Pixmap nxagentPixmapLogo; Window nxagentSplashWindow = None; +Bool nxagentWMPassed = False; static void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height); @@ -396,6 +397,9 @@ void nxagentPaintLogo(Window win, GC gc, int scale, int width, int height) void nxagentRemoveSplashWindow(void) { + if (nxagentWMPassed) + return; + if (nxagentReconnectTrap) return; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Splash.h b/nx-X11/programs/Xserver/hw/nxagent/Splash.h index 5f7547e57..a43801469 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Splash.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Splash.h @@ -39,8 +39,6 @@ extern int nxagentXdmcpUp; extern Window nxagentSplashWindow; -extern int nxagentWMPassed; - extern void nxagentShowSplashWindow(Window); extern void nxagentRemoveSplashWindow(); -- cgit v1.2.3 From 4202d5094c72de28fe48fcfb165366bc8bdf68e7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 13:08:42 +0200 Subject: NXdispatch.c: drop currentDispatch variable was only used once --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 0ad26b0bb..da7a55b69 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -244,8 +244,6 @@ Dispatch(void) register HWEventQueuePtr* icheck = checkForInput; long start_tick; - unsigned long currentDispatch = 0; - nextFreeClientID = 1; InitSelections(); nClients = 0; @@ -371,18 +369,15 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio #ifdef NXAGENT_ONSTART - currentDispatch = GetTimeInMillis(); - - /* - * If the timeout is expired set the - * selection informing the NX client - * that the agent is ready. - */ + /* + * If the timeout is expired set the selection informing the + * NX client that the agent is ready. + */ - if (nxagentWMtimeout < currentDispatch) - { - nxagentRemoveSplashWindow(); - } + if (nxagentWMtimeout < GetTimeInMillis()) + { + nxagentRemoveSplashWindow(); + } nxagentClients = nClients; -- cgit v1.2.3 From f39b81d31bc7d0427ea9cca04d0e4a21579d7383 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 16 Aug 2019 13:11:38 +0200 Subject: NXdispatch.c: move nxagentWMtimeout into the function it is only used there, no need for a global variable --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index da7a55b69..10616834e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -141,10 +141,6 @@ void nxagentWaitDisplay(void); void nxagentListRemoteFonts(const char *, int); -#ifdef NXAGENT_ONSTART -unsigned int nxagentWMtimeout = 0; -#endif - /* * Timeouts based on screen saver time. */ @@ -264,12 +260,11 @@ Dispatch(void) #ifdef NXAGENT_ONSTART /* - * Set NX_WM property (used by NX client to identify - * the agent's window) three seconds since the first - * client connects. + * Set NX_WM property (used by NX client to identify the agent's + * window) three seconds since the first client connects. */ - nxagentWMtimeout = GetTimeInMillis() + 3000; + unsigned int nxagentWMtimeout = GetTimeInMillis() + 3000; #endif -- cgit v1.2.3