From 95940104a1695f3f334328bcca66da3c37d04ddf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 21:44:03 +0200 Subject: GCOps.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 107 ++++++++++++----------------- 1 file changed, 43 insertions(+), 64 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index 7db1aff58..f776a368d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -216,17 +216,12 @@ RegionPtr nxagentBitBlitHelper(GC *pGC) int nxagentWindowIsPopup(DrawablePtr pDrawable) { - WindowPtr parent; - - int windowIsPopup; - int level; - if (pDrawable -> type != DRAWABLE_WINDOW) { return 0; } - windowIsPopup = 0; + int windowIsPopup = 0; if (((WindowPtr) pDrawable) -> overrideRedirect == 1) { @@ -234,7 +229,7 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable) } else { - parent = ((WindowPtr) pDrawable) -> parent; + WindowPtr parent = ((WindowPtr) pDrawable) -> parent; /* * Go up on the tree until a parent @@ -243,7 +238,7 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable) * up children's popup. */ - level = 0; + int level = 0; while (parent != NULL && ++level <= 4) { @@ -255,7 +250,6 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable) if (parent -> overrideRedirect == 1) { windowIsPopup = 1; - break; } @@ -280,10 +274,6 @@ int nxagentDeferCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty) { - RegionPtr pSrcRegion; - RegionPtr pClipRegion, pCorruptedRegion; - RegionRec corruptedRegion, tmpRegion; - /* * If the destination drawable is a popup * window, we try to synchronize the source @@ -306,7 +296,7 @@ FIXME: The popup could be synchronized with one nxagentPixmapContainTrapezoids((PixmapPtr) pSrcDrawable) == 1 && nxagentWindowIsPopup(pDstDrawable) == 1) { - pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); + RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); #ifdef DEBUG fprintf(stderr, "nxagentDeferCopyArea: Copying to a popup menu. Source region [%d,%d,%d,%d].\n", @@ -314,6 +304,8 @@ FIXME: The popup could be synchronized with one pSrcRegion -> extents.x2, pSrcRegion -> extents.y2); #endif + RegionRec corruptedRegion; + RegionInit(&corruptedRegion, NullBox, 1); RegionIntersect(&corruptedRegion, @@ -349,8 +341,8 @@ FIXME: The popup could be synchronized with one if ((pDstDrawable -> type == DRAWABLE_PIXMAP && nxagentOption(DeferLevel) > 0) || nxagentOption(DeferLevel) >= 3) { - pClipRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, - width, height); + RegionPtr pClipRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, + width, height); /* * We called this variable pCorruptedRegion @@ -360,8 +352,8 @@ FIXME: The popup could be synchronized with one * narrow the destination. */ - pCorruptedRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, - width, height); + RegionPtr pCorruptedRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, + width, height); #ifdef DEBUG fprintf(stderr, "nxagentDeferCopyArea: Copy area source region is [%d,%d,%d,%d].\n", @@ -393,6 +385,8 @@ FIXME: The popup could be synchronized with one } else { + RegionRec tmpRegion; + RegionInit(&tmpRegion, NullBox, 1); #ifdef DEBUG @@ -455,10 +449,6 @@ FIXME: The popup could be synchronized with one if (RegionNil(pClipRegion) == 0) { - GCPtr targetGC; - - CARD32 targetAttributes[2]; - Bool pClipRegionFree = True; /* @@ -468,7 +458,7 @@ FIXME: The popup could be synchronized with one * setting a new clip mask. */ - targetGC = GetScratchGC(pDstDrawable -> depth, pDstDrawable -> pScreen); + GCPtr targetGC = GetScratchGC(pDstDrawable -> depth, pDstDrawable -> pScreen); ValidateGC(pDstDrawable, targetGC); @@ -495,6 +485,8 @@ FIXME: The popup could be synchronized with one } else { + CARD32 targetAttributes[2]; + /* * Setting the clip mask origin. This * operation must precede the clip chan- @@ -563,7 +555,9 @@ FIXME: The popup could be synchronized with one } else { - pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); + RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); + + RegionRec corruptedRegion; #ifdef DEBUG fprintf(stderr, "nxagentDeferCopyArea: Source region [%d,%d,%d,%d].\n", @@ -598,12 +592,6 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty) { - int leftPad = 0; - unsigned int format; - unsigned long planeMask = 0xffffffff; - - RegionPtr pDstRegion; - int skip = 0; #ifdef TEST @@ -754,13 +742,14 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, nxagentIsShmPixmap((PixmapPtr) pSrcDrawable)) { char *data; - int depth, length; - depth = pSrcDrawable -> depth; + int depth = pSrcDrawable -> depth; - format = (depth == 1) ? XYPixmap : ZPixmap; + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - length = nxagentImageLength(width, height, format, leftPad, depth); + int leftPad = 0; + + int length = nxagentImageLength(width, height, format, leftPad, depth); if ((data = malloc(length)) == NULL) { @@ -771,6 +760,8 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, return NullRegion; } + unsigned long planeMask = 0xffffffff; + fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* @@ -831,7 +822,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, if (nxagentDrawableStatus(pDstDrawable) == NotSynchronized) { - pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); + RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); nxagentUnmarkCorruptedRegion(pDstDrawable, pDstRegion); @@ -918,13 +909,6 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, unsigned long plane) { - unsigned int format; - int leftPad = 0; - unsigned long planeMask = 0xffffffff; - - RegionPtr pSrcRegion, pDstRegion; - RegionRec corruptedRegion; - int skip = 0; #ifdef TEST @@ -974,13 +958,14 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, nxagentIsShmPixmap((PixmapPtr) pSrcDrawable)) { char *data; - int depth, length; - depth = pSrcDrawable -> depth; + int depth = pSrcDrawable -> depth; + + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - format = (depth == 1) ? XYPixmap : ZPixmap; + int leftPad = 0; - length = nxagentImageLength(width, height, format, leftPad, depth); + int length = nxagentImageLength(width, height, format, leftPad, depth); if ((data = malloc(length)) == NULL) { @@ -991,6 +976,8 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, return 0; } + unsigned long planeMask = 0xffffffff; + fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* @@ -1024,7 +1011,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, if (pDstDrawable -> type == DRAWABLE_PIXMAP && nxagentOption(DeferLevel) > 0) { - pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); + RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); nxagentMarkCorruptedRegion(pDstDrawable, pDstRegion); @@ -1034,7 +1021,9 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } else { - pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); + RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); + + RegionRec corruptedRegion; RegionInit(&corruptedRegion, NullBox, 1); @@ -1050,7 +1039,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, nxagentSynchronizeRegion(pSrcDrawable, &corruptedRegion /*pSrcRegion*/, NEVER_BREAK, NULL); - pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); + RegionPtr pDstRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, width, height); nxagentUnmarkCorruptedRegion(pDstDrawable, pDstRegion); @@ -1471,8 +1460,6 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, if (mode == CoordModeOrigin) { - int i; - mode = CoordModePrevious; newPoints = malloc(nPoints * sizeof(xPoint)); @@ -1491,7 +1478,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, * tive to the previous point. */ - for (i = 1; i < nPoints; i++) + for (int i = 1; i < nPoints; i++) { newPoints[i].x = pPoints[i].x - pPoints[i-1].x; newPoints[i].y = pPoints[i].y - pPoints[i-1].y; @@ -1551,10 +1538,6 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nRectangles, xRectangle *pRectangles) { - RegionPtr rectRegion; - - int inheritCorruptedRegion; - #ifdef TEST if (nRectangles == 1) @@ -1594,7 +1577,7 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, * intersecting the target will be cleared. */ - inheritCorruptedRegion = 0; + int inheritCorruptedRegion = 0; if (pGC -> fillStyle == FillTiled && pGC -> tileIsPixel == 0 && pGC -> tile.pixmap != NULL) @@ -1616,7 +1599,7 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, if (inheritCorruptedRegion == 1 || nxagentDrawableStatus(pDrawable) == NotSynchronized) { - rectRegion = RegionFromRects(nRectangles, pRectangles, CT_REGION); + RegionPtr rectRegion = RegionFromRects(nRectangles, pRectangles, CT_REGION); if (pGC -> clientClip != NULL) { @@ -1784,8 +1767,6 @@ void nxagentPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *string) { - int width; - /* * While the session is suspended * the font structure is NULL. @@ -1796,7 +1777,7 @@ int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, return x; } - width = XTextWidth(nxagentFontStruct(pGC->font), string, count); + int width = XTextWidth(nxagentFontStruct(pGC->font), string, count); if (nxagentGCTrap == 1) { @@ -1857,8 +1838,6 @@ int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int nxagentPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *string) { - int width; - /* * While the session is suspended * the font structure is NULL. @@ -1869,7 +1848,7 @@ int nxagentPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, return x; } - width = XTextWidth16(nxagentFontStruct(pGC->font), (XChar2b *)string, count); + int width = XTextWidth16(nxagentFontStruct(pGC->font), (XChar2b *)string, count); if (nxagentGCTrap == 1) { -- cgit v1.2.3 From 53f4386b974faa0ffbf9727fa036fd78b4ef4625 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:15:42 +0200 Subject: GC.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 76 +++++++++++---------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index b53428f96..2c2613419 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -142,8 +142,6 @@ static GCOps nxagentOps = Bool nxagentCreateGC(GCPtr pGC) { - FbGCPrivPtr pPriv; - pGC->clientClipType = CT_NONE; pGC->clientClip = NULL; @@ -178,7 +176,7 @@ Bool nxagentCreateGC(GCPtr pGC) fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC); #endif - pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; + FbGCPrivPtr pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; fbGetRotatedPixmap(pGC) = 0; fbGetExpose(pGC) = 1; @@ -214,8 +212,6 @@ Bool nxagentCreateGC(GCPtr pGC) void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) { - PixmapPtr lastTile, lastStipple; - DrawablePtr pVirtual = (pDrawable -> type == DRAWABLE_PIXMAP) ? nxagentVirtualDrawable(pDrawable) : pDrawable; @@ -233,9 +229,9 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) pGC -> tile.pixmap = nxagentVirtualPixmap(pGC -> tile.pixmap); } - lastTile = pGC -> tile.pixmap; + PixmapPtr lastTile = pGC -> tile.pixmap; - lastStipple = pGC->stipple; + PixmapPtr lastStipple = pGC->stipple; if (lastStipple) { @@ -510,9 +506,6 @@ void nxagentDestroyGC(GCPtr pGC) void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) { - int i, size; - BoxPtr pBox; - XRectangle *pRects; int clipsMatch = 0; #ifdef TEST @@ -577,12 +570,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) { if (clipsMatch == 0 && nxagentGCTrap == 0) { + XRectangle *pRects; nRects = RegionNumRects((RegionPtr)pValue); - size = nRects * sizeof(*pRects); + int size = nRects * sizeof(*pRects); pRects = (XRectangle *) malloc(size); - pBox = RegionRects((RegionPtr)pValue); + BoxPtr pBox = RegionRects((RegionPtr)pValue); - for (i = nRects; i-- > 0;) + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -742,8 +736,6 @@ void nxagentDestroyClipHelper(GCPtr pGC) void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) { - RegionPtr pRgn; - #ifdef TEST fprintf(stderr, "nxagentCopyClip: Going to copy clip from GC [%p] to GC [%p]\n", (void *) pGCDst, (void *) pGCSrc); @@ -754,7 +746,7 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) case CT_REGION: if (nxagentGCPriv(pGCSrc)->pPixmap == NULL) { - pRgn = RegionCreate(NULL, 1); + RegionPtr pRgn = RegionCreate(NULL, 1); RegionCopy(pRgn, pGCSrc->clientClip); nxagentChangeClip(pGCDst, CT_REGION, pRgn, 0); } @@ -1029,7 +1021,6 @@ static void nxagentReconnectGC(void *param0, XID param1, void * param2) Bool nxagentReconnectAllGCs(void *p0) { - int cid; Bool GCSuccess = True; #ifdef DEBUG @@ -1044,7 +1035,7 @@ Bool nxagentReconnectAllGCs(void *p0) FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, nxagentReconnectGC, &GCSuccess); - for (cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++) + for (int cid = 0; (cid < MAXCLIENTS) && GCSuccess; cid++) { if (clients[cid]) { @@ -1090,7 +1081,6 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2) Bool nxagentDisconnectAllGCs(void) { - int cid; Bool success = True; #ifdef DEBUG @@ -1106,7 +1096,7 @@ Bool nxagentDisconnectAllGCs(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, (FindResType) nxagentDisconnectGC, &success); - for (cid = 0; (cid < MAXCLIENTS) && success; cid++) + for (int cid = 0; (cid < MAXCLIENTS) && success; cid++) { if (clients[cid]) { @@ -1132,10 +1122,6 @@ Bool nxagentDisconnectAllGCs(void) static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) { - int i, size; - BoxPtr pBox; - XRectangle *pRects; - #ifdef TEST fprintf(stderr, "nxagentReconnectClip: going to change clip on GC [%p]\n", (void *) pGC); @@ -1156,11 +1142,12 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_REGION: if (nxagentGCPriv(pGC)->pPixmap == NULL) { + XRectangle *pRects; nRects = RegionNumRects((RegionPtr)pValue); - size = nRects * sizeof(*pRects); + int size = nRects * sizeof(*pRects); pRects = (XRectangle *) malloc(size); - pBox = RegionRects((RegionPtr)pValue); - for (i = nRects; i-- > 0;) { + BoxPtr pBox = RegionRects((RegionPtr)pValue); + for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; pRects[i].width = pBox[i].x2 - pBox[i].x1; @@ -1262,8 +1249,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) { - int i; - /* * It returns 1 if regions are equal, 0 otherwise */ @@ -1292,7 +1277,7 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) else if ((*RegionExtents(r1)).y2 != (*RegionExtents(r2)).y2) return 0; else { - for (i = 0; i < RegionNumRects(r1); i++) + for (int i = 0; i < RegionNumRects(r1); i++) { if (RegionRects(r1)[i].x1 != RegionRects(r2)[i].x1) return 0; else if (RegionRects(r1)[i].x2 != RegionRects(r2)[i].x2) return 0; @@ -1394,10 +1379,7 @@ void nxagentFreeScratchGC(GCPtr pGC) GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) { - int i; - int result; - - for (i = 0; i < nxagentGraphicContextsSize; i++) + for (int i = 0; i < nxagentGraphicContextsSize; i++) { if (pDrawable -> depth == nxagentGraphicContexts[i].depth) { @@ -1416,7 +1398,7 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) fprintf(stderr, "nxagentGetGraphicContext: Going to reconnect the GC.\n"); #endif - result = 1; + int result = 1; nxagentReconnectGC(nxagentGraphicContexts[i].pGC, (XID) 0, &result); @@ -1441,18 +1423,12 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) GCPtr nxagentCreateGraphicContext(int depth) { - GCPtr pGC; - - nxagentGraphicContextsPtr nxagentGCs; - - XID attributes[2]; - /* * We have not found a GC, so we have * to spread the list and add a new GC. */ - nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec)); + nxagentGraphicContextsPtr nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec)); if (nxagentGCs == NULL) { @@ -1465,7 +1441,7 @@ GCPtr nxagentCreateGraphicContext(int depth) nxagentGraphicContexts = nxagentGCs; - pGC = CreateScratchGC(nxagentDefaultScreen, depth); + GCPtr pGC = CreateScratchGC(nxagentDefaultScreen, depth); if (pGC == NULL) { @@ -1477,6 +1453,8 @@ GCPtr nxagentCreateGraphicContext(int depth) return NULL; } + XID attributes[2]; + /* * Color used in nxagentFillRemoteRegion(). */ @@ -1520,13 +1498,9 @@ GCPtr nxagentCreateGraphicContext(int depth) void nxagentAllocateGraphicContexts(void) { - int *depths; - - int i; + int *depths = nxagentDepths; - depths = nxagentDepths; - - for (i = 0; i < nxagentNumDepths; i++) + for (int i = 0; i < nxagentNumDepths; i++) { nxagentCreateGraphicContext(*depths); @@ -1536,9 +1510,7 @@ void nxagentAllocateGraphicContexts(void) void nxagentDisconnectGraphicContexts(void) { - int i; - - for (i = 0; i < nxagentGraphicContextsSize; i++) + for (int i = 0; i < nxagentGraphicContextsSize; i++) { nxagentGraphicContexts[i].dirty = 1; } -- cgit v1.2.3 From f0742c7fa78bea772fd3c44e2c11192d0da81b3c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:57:18 +0200 Subject: Cursor.c: scope improvements + use of designated initializers --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 129 +++++++++++++--------------- 1 file changed, 60 insertions(+), 69 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index 75382d4e8..55abefffd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -131,9 +131,7 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) * inherits the parent's cursor. */ - Cursor cursor; - - cursor = (pCursor != rootCursor) ? nxagentCursor(pCursor, pScreen): None; + Cursor cursor = (pCursor != rootCursor) ? nxagentCursor(pCursor, pScreen): None; if (nxagentOption(Rootless) == False) { @@ -152,49 +150,45 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { - XImage *image; - Pixmap source, mask; - XColor fg_color, bg_color; - unsigned long valuemask; - XGCValues values; - #ifdef TEST fprintf(stderr, "nxagentRealizeCursor: Called for cursor at [%p].\n", (void *) pCursor); #endif - valuemask = GCFunction | - GCPlaneMask | - GCForeground | - GCBackground | - GCClipMask; + unsigned long valuemask = GCFunction | + GCPlaneMask | + GCForeground | + GCBackground | + GCClipMask; - values.function = GXcopy; - values.plane_mask = AllPlanes; - values.foreground = 1L; - values.background = 0L; - values.clip_mask = None; + XGCValues values = { + .function = GXcopy, + .plane_mask = AllPlanes, + .foreground = 1L, + .background = 0L, + .clip_mask = None + }; XChangeGC(nxagentDisplay, nxagentBitmapGC, valuemask, &values); - source = XCreatePixmap(nxagentDisplay, - nxagentDefaultWindows[pScreen->myNum], - pCursor->bits->width, - pCursor->bits->height, - 1); - - mask = XCreatePixmap(nxagentDisplay, - nxagentDefaultWindows[pScreen->myNum], - pCursor->bits->width, - pCursor->bits->height, - 1); - - image = XCreateImage(nxagentDisplay, - nxagentDefaultVisual(pScreen), - 1, XYBitmap, 0, - (char *)pCursor->bits->source, - pCursor->bits->width, - pCursor->bits->height, - BitmapPad(nxagentDisplay), 0); + Pixmap source = XCreatePixmap(nxagentDisplay, + nxagentDefaultWindows[pScreen->myNum], + pCursor->bits->width, + pCursor->bits->height, + 1); + + Pixmap mask = XCreatePixmap(nxagentDisplay, + nxagentDefaultWindows[pScreen->myNum], + pCursor->bits->width, + pCursor->bits->height, + 1); + + XImage *image = XCreateImage(nxagentDisplay, + nxagentDefaultVisual(pScreen), + 1, XYBitmap, 0, + (char *)pCursor->bits->source, + pCursor->bits->width, + pCursor->bits->height, + BitmapPad(nxagentDisplay), 0); /* * If we used nxagentImageNormalize() here, @@ -232,13 +226,17 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) SAFE_XFree(image); - fg_color.red = pCursor->foreRed; - fg_color.green = pCursor->foreGreen; - fg_color.blue = pCursor->foreBlue; + XColor fg_color = { + .red = pCursor->foreRed, + .green = pCursor->foreGreen, + .blue = pCursor->foreBlue + }; - bg_color.red = pCursor->backRed; - bg_color.green = pCursor->backGreen; - bg_color.blue = pCursor->backBlue; + XColor bg_color = { + .red = pCursor->backRed, + .green = pCursor->backGreen, + .blue = pCursor->backBlue + }; pCursor->devPriv[pScreen->myNum] = (void *) malloc(sizeof(nxagentPrivCursor)); @@ -282,15 +280,17 @@ Bool nxagentUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) void nxagentRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed) { - XColor fg_color, bg_color; - - fg_color.red = pCursor->foreRed; - fg_color.green = pCursor->foreGreen; - fg_color.blue = pCursor->foreBlue; - - bg_color.red = pCursor->backRed; - bg_color.green = pCursor->backGreen; - bg_color.blue = pCursor->backBlue; + XColor fg_color = { + .red = pCursor->foreRed, + .green = pCursor->foreGreen, + .blue = pCursor->foreBlue + }; + + XColor bg_color = { + .red = pCursor->backRed, + .green = pCursor->backGreen, + .blue = pCursor->backBlue + }; XRecolorCursor(nxagentDisplay, nxagentCursor(pCursor, pScreen), @@ -323,9 +323,6 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) Bool* pBool = (Bool*)p2; CursorPtr pCursor = (CursorPtr) p0; - AnimCurPtr ac; - int j; - #ifdef TEST fprintf(stderr, "nxagentReconnectCursor: pCursor at [%p]\n", pCursor); #endif @@ -347,9 +344,9 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) fprintf(stderr, "nxagentReconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor); #endif - ac = nxagentGetAnimCursor(pCursor); + AnimCurPtr ac = nxagentGetAnimCursor(pCursor); - for (j = 0; j < ac->nelt; j++) + for (int j = 0; j < ac->nelt; j++) { nxagentReconnectCursor (ac->elts[j].pCursor, x1, p2); @@ -405,7 +402,6 @@ void nxagentReDisplayCurrentCursor(void) Bool nxagentReconnectAllCursor(void *p0) { - int i; Bool r = True; GrabPtr grab = inputInfo.pointer -> grab; @@ -414,7 +410,7 @@ Bool nxagentReconnectAllCursor(void *p0) fprintf(stderr, "nxagentReconnectAllCursor\n"); #endif - for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { @@ -445,9 +441,6 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) Bool* pBool = (Bool *) p2; CursorPtr pCursor = (CursorPtr) p0; - AnimCurPtr ac; - int j; - if (!*pBool || !pCursor) { return; @@ -461,9 +454,9 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) fprintf(stderr, "nxagentDisconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor); #endif - ac = nxagentGetAnimCursor(pCursor); + AnimCurPtr ac = nxagentGetAnimCursor(pCursor); - for (j = 0; j < ac->nelt; j++) + for (int j = 0; j < ac->nelt; j++) { nxagentDisconnectCursor (ac->elts[j].pCursor, x1, p2); @@ -519,7 +512,6 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) Bool nxagentDisconnectAllCursor(void) { - int i; Bool r = True; GrabPtr grab = inputInfo.pointer -> grab; @@ -528,7 +520,7 @@ Bool nxagentDisconnectAllCursor(void) fprintf(stderr, "nxagentDisconnectAllCursor: Going to iterate through cursor resources.\n"); #endif - for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { @@ -572,10 +564,9 @@ void nxagentListCursor(void *p0, void *p1, void *p2) void nxagentListCursors(void) { - int i; Bool r; - for (i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { -- cgit v1.2.3 From d621557403c682d651d3df3c268f7aa3eb160569 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 23:44:14 +0200 Subject: Error.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 33 ++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 0d4ef3107..dfc96d3f0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -325,16 +325,13 @@ void nxagentEndRedirectToClientsLog(void) char *nxagentGetHomePath(void) { - char *homeEnv; - char *homePath; - if (*nxagentHomeDir == '\0') { /* * Check the NX_HOME environment. */ - homeEnv = getenv("NX_HOME"); + char *homeEnv = getenv("NX_HOME"); if (homeEnv == NULL || *homeEnv == '\0') { @@ -369,7 +366,7 @@ char *nxagentGetHomePath(void) #endif } - homePath = strdup(nxagentHomeDir); + char *homePath = strdup(nxagentHomeDir); if (homePath == NULL) { @@ -385,19 +382,13 @@ char *nxagentGetHomePath(void) char *nxagentGetRootPath(void) { - char *rootEnv; - char *homeEnv; - char *rootPath; - - struct stat dirStat; - if (*nxagentRootDir == '\0') { /* * Check the NX_ROOT environment. */ - rootEnv = getenv("NX_ROOT"); + char *rootEnv = getenv("NX_ROOT"); if (rootEnv == NULL || *rootEnv == '\0') { @@ -411,7 +402,7 @@ char *nxagentGetRootPath(void) * settings. */ - homeEnv = nxagentGetHomePath(); + char *homeEnv = nxagentGetHomePath(); if (homeEnv == NULL) { @@ -443,6 +434,8 @@ char *nxagentGetRootPath(void) * Create the NX root directory. */ + struct stat dirStat; + if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT)) { if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST)) @@ -478,7 +471,7 @@ char *nxagentGetRootPath(void) } - rootPath = strdup(nxagentRootDir); + char *rootPath = strdup(nxagentRootDir); if (rootPath == NULL) { @@ -494,12 +487,6 @@ char *nxagentGetRootPath(void) char *nxagentGetSessionPath(void) { - - char *rootPath; - char *sessionPath; - - struct stat dirStat; - if (*nxagentSessionDir == '\0') { /* @@ -518,7 +505,7 @@ char *nxagentGetSessionPath(void) return NULL; } - rootPath = nxagentGetRootPath(); + char *rootPath = nxagentGetRootPath(); if (rootPath == NULL) { @@ -544,6 +531,8 @@ char *nxagentGetSessionPath(void) SAFE_free(rootPath); + struct stat dirStat; + if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT)) { if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST)) @@ -564,7 +553,7 @@ char *nxagentGetSessionPath(void) } - sessionPath = strdup(nxagentSessionDir); + char *sessionPath = strdup(nxagentSessionDir); if (sessionPath == NULL) { -- cgit v1.2.3 From d86cb00b6891d4afbb030eb32ccca1d1410c2e97 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 23 Oct 2019 00:14:12 +0200 Subject: Image.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 124 +++++++++-------------------- 1 file changed, 37 insertions(+), 87 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index e55ed2dd2..6c239012b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -330,21 +330,13 @@ char *nxagentImageCopy(XImage *source, XImage *destination) char *nxagentImageAlpha(XImage *image) { - char *pData; - - char *pSrcData; - char *pDstData; - - int size; - int offset; - /* * Use one byte per pixel. */ - size = (image -> bytes_per_line * image -> height) >> 2; + int size = (image -> bytes_per_line * image -> height) >> 2; - pData = malloc(size); + char *pData = malloc(size); if (pData == NULL) { @@ -356,10 +348,10 @@ char *nxagentImageAlpha(XImage *image) * server order. */ - offset = (image -> byte_order == MSBFirst) ? 0 : 3; + int offset = (image -> byte_order == MSBFirst) ? 0 : 3; - pSrcData = image -> data; - pDstData = pData; + char *pSrcData = image -> data; + char *pDstData = pData; while (size-- > 0) { @@ -496,8 +488,7 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int dstX, int dstY, int dstWidth, int dstHeight, int leftPad, int format, char *data) { - int length; - + /* will be checked at nxagentPutImageEnd */ RegionPtr pRegion = NullRegion; int resource = 0; @@ -517,15 +508,13 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, * to the framebuffer. */ - length = nxagentImageLength(dstWidth, dstHeight, format, leftPad, depth); + int length = nxagentImageLength(dstWidth, dstHeight, format, leftPad, depth); if (nxagentShadowCounter == 0 && NXDisplayError(nxagentDisplay) == 1 && nxagentOption(SleepTime) > 0) { - int us; - - us = nxagentOption(SleepTime) * 4 * (length / 1024); + int us = nxagentOption(SleepTime) * 4 * (length / 1024); us = (us < 10000 ? 10000 : (us > 1000000 ? 1000000 : us)); @@ -1408,19 +1397,16 @@ FIXME: There should be a callback registered by the agent that case PACK_BITMAP_16M_COLORS: { packedImage = NXEncodeBitmap(plainImage, packMethod, packQuality); - break; } case PACK_RGB_16M_COLORS: { packedImage = NXEncodeRgb(plainImage, packMethod, packQuality); - break; } default: { packedImage = NXEncodeRle(plainImage, packMethod, packQuality); - break; } } @@ -1618,9 +1604,7 @@ void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, void nxagentResetVisualCache(void) { - int i; - - for (i = 0; i < MAX_CONNECTIONS; i++) + for (int i = 0; i < MAX_CONNECTIONS; i++) { nxagentUnpackVisualId[i] = None; } @@ -1628,9 +1612,7 @@ void nxagentResetVisualCache(void) void nxagentResetAlphaCache(void) { - int i; - - for (i = 0; i < MAX_CONNECTIONS; i++) + for (int i = 0; i < MAX_CONNECTIONS; i++) { if (nxagentUnpackAlpha[i]) { @@ -1643,55 +1625,25 @@ void nxagentResetAlphaCache(void) int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, XImage **pImage, int *scaledx, int *scaledy) { - int x1; - int x2; - int y1; - int y2; - - int xx1; - int xx2; - int yy1; - int yy2; - - int newWidth; - int newHeight; - - int i; - int j; - int k; - int l; - - unsigned long val; - - XImage *newImage; XImage *image = *pImage; - #ifdef FAST_GET_PUT_PIXEL - - register char *srcPixel; - register char *dstPixel; - - int i; - - #endif - if (image == NULL) { return 0; } - x1 = (xRatio * x) >> PRECISION; - x2 = (xRatio * (x + image -> width)) >> PRECISION; + int x1 = (xRatio * x) >> PRECISION; + int x2 = (xRatio * (x + image -> width)) >> PRECISION; - y1 = (yRatio * y) >> PRECISION; - y2 = (yRatio * (y + image -> height)) >> PRECISION; + int y1 = (yRatio * y) >> PRECISION; + int y2 = (yRatio * (y + image -> height)) >> PRECISION; - newWidth = x2 - x1; - newHeight = y2 - y1; + int newWidth = x2 - x1; + int newHeight = y2 - y1; - newImage = XCreateImage(nxagentDisplay, NULL, image -> depth, image -> format, 0, NULL, - newWidth, newHeight, BitmapPad(nxagentDisplay), - PixmapBytePad(newWidth, image -> depth)); + XImage *newImage = XCreateImage(nxagentDisplay, NULL, image -> depth, image -> format, 0, NULL, + newWidth, newHeight, BitmapPad(nxagentDisplay), + PixmapBytePad(newWidth, image -> depth)); if (newImage == NULL) { @@ -1725,39 +1677,41 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, newImage -> width = newWidth; newImage -> height = newHeight; - for (j = y; j < y + image -> height; j++) + for (int j = y; j < y + image -> height; j++) { - yy1 = (yRatio * j) >> PRECISION; - yy2 = (yRatio * (j + 1)) >> PRECISION; + int yy1 = (yRatio * j) >> PRECISION; + int yy2 = (yRatio * (j + 1)) >> PRECISION; - for (i = x; i < x + image -> width; i++) + for (int i = x; i < x + image -> width; i++) { + unsigned long val; + #ifndef FAST_GET_PUT_PIXEL val = XGetPixel(image, i - x, j - y); #else - srcPixel = &image -> data[(j * image -> bytes_per_line) + + char *srcPixel = &image -> data[(j * image -> bytes_per_line) + ((i * image -> bits_per_pixel) >> 3)]; - dstPixel = (char *) &val; + char *dstPixel = (char *) &val; val = 0; - for (i = (image -> bits_per_pixel + 7) >> 3; --i >= 0; ) + for (int m = (image -> bits_per_pixel + 7) >> 3; --m >= 0; ) { *dstPixel++ = *srcPixel++; } #endif - xx1 = (xRatio * i) >> PRECISION; - xx2 = (xRatio * (i + 1)) >> PRECISION; + int xx1 = (xRatio * i) >> PRECISION; + int xx2 = (xRatio * (i + 1)) >> PRECISION; - for (l = yy1; l < yy2; l++) + for (int l = yy1; l < yy2; l++) { - for (k = xx1; k < xx2; k++) + for (int k = xx1; k < xx2; k++) { #ifndef FAST_GET_PUT_PIXEL @@ -1765,12 +1719,12 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, #else - dstPixel = &newImage -> data[((l - y1) * newImage -> bytes_per_line) + + char *dstPixel = &newImage -> data[((l - y1) * newImage -> bytes_per_line) + (((k - x1) * newImage -> bits_per_pixel) >> 3)]; - srcPixel = (char *) &val; + char *srcPixel = (char *) &val; - for (i = (newImage -> bits_per_pixel + 7) >> 3; --i >= 0; ) + for (int m = (newImage -> bits_per_pixel + 7) >> 3; --m >= 0; ) { *dstPixel++ = *srcPixel++; } @@ -1794,17 +1748,13 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, char *nxagentAllocateImageData(int width, int height, int depth, int *length, int *format) { - char *data; - - int leftPad; - - leftPad = 0; + int leftPad = 0; *format = (depth == 1) ? XYPixmap : ZPixmap; *length = nxagentImageLength(width, height, *format, leftPad, depth); - data = NULL; + char *data = NULL; if ((data = malloc(*length)) == NULL) { -- cgit v1.2.3 From 44138137bb2d15362c67056685a3e6caccbb0918 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 23 Oct 2019 00:19:22 +0200 Subject: Binder.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Binder.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Binder.c b/nx-X11/programs/Xserver/hw/nxagent/Binder.c index 1a6c4e969..247fb9d77 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Binder.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Binder.c @@ -46,19 +46,14 @@ int nxagentCheckBinder(int argc, char *argv[], int i) { if (++i < argc) { - char *display; - char *found; - - int port; - - display = argv[i]; + char *display = argv[i]; /* * Check if a display specification follows * the -B switch. */ - found = rindex(display, ':'); + char *found = rindex(display, ':'); if (found == NULL || *(found + 1) == '\0' || isdigit(*(found + 1)) == 0) @@ -69,7 +64,7 @@ int nxagentCheckBinder(int argc, char *argv[], int i) return 0; } - port = atoi(found + 1); + int port = atoi(found + 1); #ifdef TEST fprintf(stderr, "nxagentCheckBinder: Identified agent display port [%d].\n", -- cgit v1.2.3 From 7860401b02f3d8cfc2dadb1364aa4f653cb22285 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 23:42:44 +0200 Subject: Display.c: shorten code scope improvements, designated initializers --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 90 ++++++++++------------------ 1 file changed, 32 insertions(+), 58 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 6d62a978f..27e5aee79 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -371,13 +371,12 @@ static void nxagentSigchldHandler(int signal) { int pid = 0; int status; - int options; #ifdef TEST fprintf(stderr, "nxagentSigchldHandler: Going to check the children processes.\n"); #endif - options = WNOHANG | WUNTRACED; + int options = WNOHANG | WUNTRACED; /* * Try with the pid of the dialog process. @@ -732,8 +731,6 @@ int nxagentGetDataRate(void) static void nxagentDisplayFlushHandler(Display *display, int length) { - CARD32 time; - if (nxagentDisplay != NULL) { #ifdef TEST @@ -752,9 +749,7 @@ static void nxagentDisplayFlushHandler(Display *display, int length) { nxagentFlush = GetTimeInMillis(); - time = nxagentFlush; - - time = time - nxagentLastTime; + CARD32 time = nxagentFlush - nxagentLastTime; if (time < nxagentRateTime) { @@ -1126,9 +1121,8 @@ void nxagentResetSignalHandlers(void) void nxagentOpenDisplay(int argc, char *argv[]) { - int i; - - if (!nxagentDoFullGeneration) return; + if (!nxagentDoFullGeneration) + return; #ifdef NXAGENT_TIMESTAMP @@ -1230,7 +1224,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio nxagentDefaultColormaps = (Colormap *)malloc(nxagentNumDefaultColormaps * sizeof(Colormap)); - for (i = 0; i < nxagentNumDefaultColormaps; i++) + for (int i = 0; i < nxagentNumDefaultColormaps; i++) { nxagentDefaultColormaps[i] = XCreateColormap(nxagentDisplay, DefaultRootWindow(nxagentDisplay), @@ -1491,20 +1485,17 @@ void nxagentSetDefaultVisual(void) void nxagentInitVisuals(void) { - XVisualInfo vi; - XVisualInfo *viList = NULL; - - long mask; - int i, viNumList; - - mask = VisualScreenMask; - vi.screen = DefaultScreen(nxagentDisplay); - vi.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); - viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList); + long mask = VisualScreenMask; + XVisualInfo vi = { + .screen = DefaultScreen(nxagentDisplay), + .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)) + }; + int viNumList; + XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList); nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo)); nxagentNumVisuals = 0; - for (i = 0; i < viNumList; i++) + for (int i = 0; i < viNumList; i++) { if (viList[i].depth == vi.depth) { @@ -1547,10 +1538,6 @@ void nxagentInitVisuals(void) void nxagentInitDepths(void) { - #ifdef TEST - int i; - #endif - nxagentDepths = XListDepths(nxagentDisplay, DefaultScreen(nxagentDisplay), &nxagentNumDepths); @@ -1568,7 +1555,7 @@ void nxagentInitDepths(void) fprintf(stderr, "nxagentInitDepths: Got [%d] available depths:\n", nxagentNumDepths); - for (i = 0; i < nxagentNumDepths; i++) + for (int i = 0; i < nxagentNumDepths; i++) { fprintf(stderr, " [%d]", nxagentDepths[i]); } @@ -1580,9 +1567,6 @@ void nxagentInitDepths(void) void nxagentInitPixmapFormats(void) { - int i, j; - int depth; - /* * Formats are created with no care of which are supported * on the real display. Creating only formats supported @@ -1598,9 +1582,9 @@ XXX: Some X server doesn't list 1 among available depths... nxagentPixmapFormats = malloc((nxagentNumDepths + 1) * sizeof(XPixmapFormatValues)); - for (i = 1; i <= MAXDEPTH; i++) + for (int i = 1; i <= MAXDEPTH; i++) { - depth = 0; + int depth = 0; if (i == 1) { @@ -1608,7 +1592,7 @@ XXX: Some X server doesn't list 1 among available depths... } else { - for (j = 0; j < nxagentNumDepths; j++) + for (int j = 0; j < nxagentNumDepths; j++) { if (nxagentDepths[j] == i) { @@ -1667,14 +1651,12 @@ XXX: Some X server doesn't list 1 among available depths... void nxagentSetDefaultDrawables(void) { - int i, j; - - for (i = 0; i <= MAXDEPTH; i++) + for (int i = 0; i <= MAXDEPTH; i++) { nxagentDefaultDrawables[i] = None; } - for (i = 0; i < nxagentNumPixmapFormats; i++) + for (int i = 0; i < nxagentNumPixmapFormats; i++) { #ifdef TEST fprintf(stderr, "nxagentSetDefaultDrawables: Checking remote pixmap format [%d] with depth [%d] " @@ -1695,7 +1677,7 @@ void nxagentSetDefaultDrawables(void) } } - for (j = 0; j < nxagentNumDepths; j++) + for (int j = 0; j < nxagentNumDepths; j++) { #ifdef TEST fprintf(stderr, "nxagentSetDefaultDrawables: Checking depth at index [%d] with pixmap depth [%d] " @@ -1778,7 +1760,6 @@ FIXME: Is this needed? if (nxagentDisplay != NULL) { NXFreeCache(nxagentDisplay); - NXResetDisplay(nxagentDisplay); } @@ -1982,9 +1963,7 @@ static int nxagentCheckForDefaultDepthCompatibility(void) * deactivated. This is probably a very bad idea. */ - int dDepth; - - dDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); + int dDepth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); const unsigned int tolerance = nxagentOption(ReconnectTolerance); @@ -2327,28 +2306,24 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) static int nxagentInitAndCheckVisuals(int flexibility) { /* FIXME: does this also need work? */ - XVisualInfo viTemplate; - XVisualInfo *viList; - XVisualInfo *newVisuals; - - long viMask; - int i, n; bool matched; bool compatible = true; - int viNumList; - viMask = VisualScreenMask; - viTemplate.screen = DefaultScreen(nxagentDisplay); - viTemplate.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); - viList = XGetVisualInfo(nxagentDisplay, viMask, &viTemplate, &viNumList); + long viMask = VisualScreenMask; + XVisualInfo viTemplate = { + .screen = DefaultScreen(nxagentDisplay), + .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)) + }; + int viNumList; + XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, viMask, &viTemplate, &viNumList); - newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals); + XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals); - for (i = 0; i < nxagentNumVisuals; i++) + for (int i = 0; i < nxagentNumVisuals; i++) { matched = false; - for (n = 0; n < viNumList; n++) + for (int n = 0; n < viNumList; n++) { if (nxagentCompareVisuals(nxagentVisuals[i], viList[n]) == 1) { @@ -2458,7 +2433,6 @@ static int nxagentCheckForColormapsCompatibility(int flexibility) Bool nxagentReconnectDisplay(void *p0) { - int i; int flexibility = *(int*)p0; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_DISPLAY_DEBUG) @@ -2569,7 +2543,7 @@ Bool nxagentReconnectDisplay(void *p0) reconnectDisplayState = ALLOC_DEF_COLORMAP; - for (i = 0; i < nxagentNumDefaultColormaps; i++) + for (int i = 0; i < nxagentNumDefaultColormaps; i++) { if (nxagentVisualHasBeenIgnored[i]) { -- cgit v1.2.3 From b9a4dea51a5e9390abef9ef4d029fd44532f0fff Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 21:55:08 +0200 Subject: GCOps.c: reformat comments save some lines --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 198 ++++++++++++----------------- 1 file changed, 84 insertions(+), 114 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index f776a368d..450a3c24f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -192,9 +192,8 @@ RegionPtr nxagentBitBlitHelper(GC *pGC) #endif /* - * Force NullRegion. We consider enough the graphics - * expose events generated internally by the nxagent - * server. + * Force NullRegion. We consider enough the graphics expose events + * generated internally by the nxagent server. */ #ifdef TEST @@ -205,13 +204,12 @@ RegionPtr nxagentBitBlitHelper(GC *pGC) } /* - * The deferring of X_RenderCompositeTrapezoids caused - * an ugly effect on pulldown menu: as the background - * may be not synchronized, the text floats in an invi- - * sible window. To avoid such effects, we use a system - * to guess if the destination target of a copy area - * is a popup, by assuming that those kind of windows - * use the override redirect property. + * The deferring of X_RenderCompositeTrapezoids caused an ugly effect + * on pulldown menu: as the background may be not synchronized, the + * text floats in an invisible window. To avoid such effects, we use a + * system to guess if the destination target of a copy area is a + * popup, by assuming that those kind of windows use the override + * redirect property. */ int nxagentWindowIsPopup(DrawablePtr pDrawable) @@ -232,10 +230,8 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable) WindowPtr parent = ((WindowPtr) pDrawable) -> parent; /* - * Go up on the tree until a parent - * exists or 4 windows has been che- - * cked. This seems a good limit to - * up children's popup. + * Go up on the tree until a parent exists or 4 windows has been + * checked. This seems a good limit to up children's popup. */ int level = 0; @@ -266,8 +262,7 @@ int nxagentWindowIsPopup(DrawablePtr pDrawable) } /* - * This function returns 1 if the - * XCopyArea request must be skipped. + * This function returns 1 if the XCopyArea request must be skipped. */ int nxagentDeferCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, @@ -275,20 +270,17 @@ int nxagentDeferCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int height, int dstx, int dsty) { /* - * If the destination drawable is a popup - * window, we try to synchronize the source - * drawable to show a nice menu. Anyway if - * this synchronization breaks, the copy area - * is handled in the normal way. + * If the destination drawable is a popup window, we try to + * synchronize the source drawable to show a nice menu. Anyway if + * this synchronization breaks, the copy area is handled in the + * normal way. */ /* -FIXME: The popup could be synchronized with one - single put image, clipped to the corrup- - ted region. As an intermediate step, the - pixmap to synchronize could be copied on - a cleared scratch pixmap, in order to - have a solid color in the clipped regions. +FIXME: The popup could be synchronized with one single put image, + clipped to the corrupted region. As an intermediate step, the + pixmap to synchronize could be copied on a cleared scratch + pixmap, in order to have a solid color in the clipped regions. */ if (nxagentOption(DeferLevel) >= 2 && @@ -332,10 +324,9 @@ FIXME: The popup could be synchronized with one } /* - * We are going to decide if the source drawable - * must be synchronized before using it, or if - * the copy will be clipped to the synchronized - * source region. + * We are going to decide if the source drawable must be + * synchronized before using it, or if the copy will be clipped to + * the synchronized source region. */ if ((pDstDrawable -> type == DRAWABLE_PIXMAP && @@ -345,11 +336,9 @@ FIXME: The popup could be synchronized with one width, height); /* - * We called this variable pCorruptedRegion - * because in the worst case the corrupted - * region will be equal to the destination - * region. The GC's clip mask is used to - * narrow the destination. + * We called this variable pCorruptedRegion because in the worst + * case the corrupted region will be equal to the destination + * region. The GC's clip mask is used to narrow the destination. */ RegionPtr pCorruptedRegion = nxagentCreateRegion(pDstDrawable, pGC, dstx, dsty, @@ -413,9 +402,8 @@ FIXME: The popup could be synchronized with one } /* - * The corrupted region on the destination - * drawable is composed by the areas of the - * destination that we are not going to copy. + * The corrupted region on the destination drawable is composed by + * the areas of the destination that we are not going to copy. */ RegionSubtract(pCorruptedRegion, pCorruptedRegion, pClipRegion); @@ -433,8 +421,8 @@ FIXME: The popup could be synchronized with one #endif /* - * The destination drawable inherits both the - * synchronized and the corrupted region. + * The destination drawable inherits both the synchronized and the + * corrupted region. */ if (RegionNil(pClipRegion) == 0) @@ -452,9 +440,8 @@ FIXME: The popup could be synchronized with one Bool pClipRegionFree = True; /* - * As we want to copy only the synchronized - * areas of the source drawable, we create - * a new GC copying the original one and + * As we want to copy only the synchronized areas of the source + * drawable, we create a new GC copying the original one and * setting a new clip mask. */ @@ -488,10 +475,9 @@ FIXME: The popup could be synchronized with one CARD32 targetAttributes[2]; /* - * Setting the clip mask origin. This - * operation must precede the clip chan- - * ge, because the origin information is - * used in the XSetClipRectangles(). + * Setting the clip mask origin. This operation must precede + * the clip change, because the origin information is used in + * the XSetClipRectangles(). */ targetAttributes[0] = 0; @@ -506,8 +492,8 @@ FIXME: The popup could be synchronized with one nxagentChangeClip(targetGC, CT_REGION, pClipRegion, 0); /* - * Next call to nxagentChangeClip() will destroy - * pClipRegion, so it has not to be freed. + * Next call to nxagentChangeClip() will destroy pClipRegion, + * so it has not to be freed. */ pClipRegionFree = False; @@ -541,9 +527,8 @@ FIXME: The popup could be synchronized with one #endif /* - * The pClipRegion is destroyed calling nxagentChangeClip(), - * so we deallocate it explicitly only if we don't change - * the clip. + * The pClipRegion is destroyed calling nxagentChangeClip(), so + * we deallocate it explicitly only if we don't change the clip. */ nxagentFreeRegion(pSrcDrawable, pClipRegion); @@ -602,9 +587,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, #endif /* - * Here, before using fbDoCopy() called by fbCopyArea(), - * it should be provided that the cast in fbDoCopy() from - * int to short int would not cut off significative bits. + * Here, before using fbDoCopy() called by fbCopyArea(), it should be + * provided that the cast in fbDoCopy() from int to short int would + * not cut off significative bits. */ if (dstx + pDstDrawable->x + width > 32767) @@ -713,9 +698,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } /* - * Try to detect if the copy area is to a window - * that is unmapped or fully covered. Similarly - * to the check in Image.c, this is of little use. + * Try to detect if the copy area is to a window that is unmapped or + * fully covered. Similarly to the check in Image.c, this is of + * little use. */ if (nxagentOption(IgnoreVisibility) == 0 && pDstDrawable -> type == DRAWABLE_WINDOW && @@ -731,11 +716,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } /* - * If the pixmap is on shared memory, we can't - * know if the pixmap content is changed and - * so have to translate the operation in a put - * image operation. This can seriously affect - * the performance. + * If the pixmap is on shared memory, we can't know if the pixmap + * content is changed and so have to translate the operation in a + * put image operation. This can seriously affect the performance. */ if (pSrcDrawable -> type == DRAWABLE_PIXMAP && @@ -765,8 +748,8 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* - * If the source is a shared memory pixmap, - * put the image directly to the destination. + * If the source is a shared memory pixmap, put the image directly + * to the destination. */ nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty, @@ -781,10 +764,9 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, SAFE_free(data); /* - * If the source is a shared memory pixmap, the - * content of the framebuffer has been placed - * directly on the destination so we can skip - * the copy area operation. + * If the source is a shared memory pixmap, the content of the + * framebuffer has been placed directly on the destination so we + * can skip the copy area operation. */ skip = 1; @@ -816,8 +798,8 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, nxagentGC(pGC), srcx, srcy, width, height, dstx, dsty); /* - * The copy area restored the synchroni- - * zation status of destination drawable. + * The copy area restored the synchronization status of + * destination drawable. */ if (nxagentDrawableStatus(pDstDrawable) == NotSynchronized) @@ -867,8 +849,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, else if (pDstDrawable -> type == DRAWABLE_PIXMAP) { /* - * If we are here the source drawable - * must be a window. + * If we are here the source drawable must be a window. */ if (((WindowPtr) pSrcDrawable) -> viewable) @@ -885,8 +866,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, else { /* - * If we are here the source drawable - * must be a window. + * If we are here the source drawable must be a window. */ if (((WindowPtr) pSrcDrawable) -> viewable) @@ -947,11 +927,9 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } /* - * If the pixmap is on shared memory, we can't - * know if the pixmap content is changed and - * so have to translate the operation in a put - * image operation. This can seriously affect - * the performance. + * If the pixmap is on shared memory, we can't know if the pixmap + * content is changed and so have to translate the operation in a + * put image operation. This can seriously affect the performance. */ if (pSrcDrawable -> type == DRAWABLE_PIXMAP && @@ -981,8 +959,8 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* - * If the source is a shared memory pixmap, - * put the image directly to the destination. + * If the source is a shared memory pixmap, put the image directly + * to the destination. */ nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty, @@ -997,10 +975,9 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, SAFE_free(data); /* - * If the source is a shared memory pixmap, the - * content of the framebuffer has been placed - * directly on the destination so we can skip - * the copy plane operation. + * If the source is a shared memory pixmap, the content of the + * framebuffer has been placed directly on the destination so we + * can skip the copy plane operation. */ skip = 1; @@ -1453,9 +1430,9 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, } /* - * The coordinate-mode must be CoordModePrevious - * to make better use of differential encoding of - * X_FillPoly request by the side of proxy. + * The coordinate-mode must be CoordModePrevious to make better use + * of differential encoding of X_FillPoly request by the side of + * proxy. */ if (mode == CoordModeOrigin) @@ -1465,17 +1442,15 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape, newPoints = malloc(nPoints * sizeof(xPoint)); /* - * The first point is always relative - * to the drawable's origin. + * The first point is always relative to the drawable's origin. */ newPoints[0].x = pPoints[0].x; newPoints[0].y = pPoints[0].y; /* - * If coordinate-mode is CoordModePrevious, - * the points following the first are rela- - * tive to the previous point. + * If coordinate-mode is CoordModePrevious, the points following + * the first are relative to the previous point. */ for (int i = 1; i < nPoints; i++) @@ -1569,12 +1544,11 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, } /* - * The PolyFillRect acts in two ways: if the GC - * has a corrupted tile, the operation propagates - * the corrupted region on the destination. In - * other cases, because the PolyFillRect will - * cover the destination, any corrupted region - * intersecting the target will be cleared. + * The PolyFillRect acts in two ways: if the GC has a corrupted + * tile, the operation propagates the corrupted region on the + * destination. In other cases, because the PolyFillRect will cover + * the destination, any corrupted region intersecting the target + * will be cleared. */ int inheritCorruptedRegion = 0; @@ -1622,10 +1596,9 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, if (inheritCorruptedRegion == 1) { /* - * The fill style should affect the cor- - * rupted region propagation: if the tile - * is not completely corrupted the region - * should be 'tiled' over the destination. + * The fill style should affect the corrupted region + * propagation: if the tile is not completely corrupted the + * region should be 'tiled' over the destination. */ nxagentMarkCorruptedRegion(pDrawable, rectRegion); @@ -1639,11 +1612,10 @@ void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, else { /* - * The stipple mask computation could cause - * an high fragmentation of the destination - * region. An analysis should be done to exa- - * mine the better solution (e.g.rdesktop - * uses stipples to draw texts). + * The stipple mask computation could cause an high + * fragmentation of the destination region. An analysis should + * be done to examine the better solution (e.g.rdesktop uses + * stipples to draw texts). */ #ifdef TEST @@ -1768,8 +1740,7 @@ int nxagentPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *string) { /* - * While the session is suspended - * the font structure is NULL. + * While the session is suspended the font structure is NULL. */ if (nxagentFontStruct(pGC -> font) == NULL) @@ -1839,8 +1810,7 @@ int nxagentPolyText16(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, unsigned short *string) { /* - * While the session is suspended - * the font structure is NULL. + * While the session is suspended the font structure is NULL. */ if (nxagentFontStruct(pGC -> font) == NULL) -- cgit v1.2.3 From 9d1a12134b3c8d7fc5c1cfbc40698c1db383b390 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 21:56:11 +0200 Subject: GCOps.c: fix format length specifiers --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index 450a3c24f..ebb993229 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -409,12 +409,12 @@ FIXME: The popup could be synchronized with one single put image, RegionSubtract(pCorruptedRegion, pCorruptedRegion, pClipRegion); #ifdef DEBUG - fprintf(stderr, "nxagentDeferCopyArea: Recomputed clip region is [%d,%d,%d,%d][%ld].\n", + fprintf(stderr, "nxagentDeferCopyArea: Recomputed clip region is [%d,%d,%d,%d][%d].\n", pClipRegion -> extents.x1, pClipRegion -> extents.y1, pClipRegion -> extents.x2, pClipRegion -> extents.y2, RegionNumRects(pClipRegion)); - fprintf(stderr, "nxagentDeferCopyArea: Inherited corrupted region is [%d,%d,%d,%d][%ld].\n", + fprintf(stderr, "nxagentDeferCopyArea: Inherited corrupted region is [%d,%d,%d,%d][%d].\n", pCorruptedRegion -> extents.x1, pCorruptedRegion -> extents.y1, pCorruptedRegion -> extents.x2, pCorruptedRegion -> extents.y2, RegionNumRects(pCorruptedRegion)); -- cgit v1.2.3 From e0e602cf13366bf496148a340b682e19c9acdf2d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:01:16 +0200 Subject: GC.c: fix format specifiers and parameters --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 2c2613419..4c852bd14 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -469,7 +469,7 @@ void nxagentCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) { #ifdef TEST fprintf(stderr, "nxagentCopyGC: Copying the GC with source at [%p] destination " - "at [%p] mask [%lu].\n", pGCSrc, pGCDst, mask); + "at [%p] mask [%lu].\n", (void *)pGCSrc, (void *)pGCDst, mask); #endif /* @@ -888,7 +888,7 @@ int nxagentDestroyNewGCResourceType(void * p, XID id) */ #ifdef TEST - fprintf(stderr, "nxagentDestroyNewGCResourceType: Destroying mirror id [%ld] for GC at [%p].\n", + fprintf(stderr, "nxagentDestroyNewGCResourceType: Destroying mirror id [%u] for GC at [%p].\n", nxagentGCPriv((GCPtr) p) -> mid, (void *) p); #endif -- cgit v1.2.3 From c3a7e9b509bf803a1a2e36ba8dc16bad3c2b2fe3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:16:05 +0200 Subject: GC.c: reformat comments save some lines --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 92 ++++++++++++++------------------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 4c852bd14..469076d80 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -161,11 +161,9 @@ Bool nxagentCreateGC(GCPtr pGC) } /* - * We create the GC based on the default - * drawables. The proxy knows this and - * optimizes the encoding of the create - * GC message to include the id of the - * drawable in the checksum. + * We create the GC based on the default drawables. The proxy knows + * this and optimizes the encoding of the create GC message to + * include the id of the drawable in the checksum. */ nxagentGCPriv(pGC)->gc = XCreateGC(nxagentDisplay, @@ -247,8 +245,8 @@ void nxagentValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) if (pVirtual -> bitsPerPixel == 0) { /* - * Don't enter fbValidateGC() with 0 bpp - * or agent will block in a endless loop. + * Don't enter fbValidateGC() with 0 bpp or agent will block in a + * endless loop. */ #ifdef WARNING @@ -327,13 +325,11 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) nxagentGCTrap == 0) { /* - * If the tile is corrupted and is not too - * much large, it can be synchronized imme- - * diately. In the other cases, the tile is - * cleared with a solid color to become usa- - * ble. This approach should solve the high - * delay on slow links waiting for a back- - * ground tile to be synchronized. + * If the tile is corrupted and is not too much large, it can + * be synchronized imme- diately. In the other cases, the tile + * is cleared with a solid color to become usable. This + * approach should solve the high delay on slow links waiting + * for a background tile to be synchronized. */ if (nxagentOption(DeferLevel) >= 2 && @@ -481,8 +477,8 @@ void nxagentCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) XCopyGC(nxagentDisplay, nxagentGC(pGCSrc), mask, nxagentGC(pGCDst)); /* - * Copy the private foreground field - * of the GC if GCForeground is set. + * Copy the private foreground field of the GC if GCForeground is + * set. */ nxagentCopyGCPriv(GCForeground,foreground,pGCSrc,mask,pGCDst); @@ -663,9 +659,8 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_YXBANDED: { /* - * Other parts of the server can only - * deal with CT_NONE, CT_PIXMAP and - * CT_REGION client clips. + * Other parts of the server can only deal with CT_NONE, + * CT_PIXMAP and CT_REGION client clips. */ pGC->clientClip = (void *) RegionFromRects(nRects, @@ -1028,9 +1023,8 @@ Bool nxagentReconnectAllGCs(void *p0) #endif /* - * The resource type RT_NX_GC is created on the - * server client only, so we can avoid to loop - * through all the clients. + * The resource type RT_NX_GC is created on the server client only, + * so we can avoid to loop through all the clients. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, nxagentReconnectGC, &GCSuccess); @@ -1088,9 +1082,8 @@ Bool nxagentDisconnectAllGCs(void) #endif /* - * The resource type RT_NX_GC is created on the - * server client only, so we can avoid to loop - * through all the clients. + * The resource type RT_NX_GC is created on the server client only, + * so we can avoid to loop through all the clients. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_GC, @@ -1155,10 +1148,9 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) } /* - * Originally, the clip origin area were 0,0 - * but it didn't work with kedit and family, - * because it got the clip mask of the pixmap - * all traslated. + * Originally, the clip origin area were 0,0 but it didn't + * work with kedit and family, because it got the clip mask of + * the pixmap all traslated. */ XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y, @@ -1228,8 +1220,8 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_YXBANDED: /* - * other parts of server can only deal with CT_NONE, - * CT_PIXMAP and CT_REGION client clips. + * other parts of server can only deal with CT_NONE, CT_PIXMAP + * and CT_REGION client clips. */ pGC->clientClip = (void *) RegionFromRects(nRects, @@ -1290,18 +1282,15 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) } /* - * This function have to be called in the place - * of GetScratchGC if the GC will be used to per- - * form operations also on the remote X Server. - * This is why we call the XChangeGC at the end of - * the function. + * This function have to be called in the place of GetScratchGC if the + * GC will be used to perform operations also on the remote X Server. + * This is why we call the XChangeGC at the end of the function. */ GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen) { /* - * The GC trap is temporarily disabled in - * order to allow the remote clipmask reset - * requested by GetScratchGC(). + * The GC trap is temporarily disabled in order to allow the remote + * clipmask reset requested by GetScratchGC(). */ int nxagentSaveGCTrap = nxagentGCTrap; @@ -1353,8 +1342,7 @@ GCPtr nxagentGetScratchGC(unsigned depth, ScreenPtr pScreen) } /* - * This function is only a wrapper for - * FreeScratchGC. + * This function is only a wrapper for FreeScratchGC. */ void nxagentFreeScratchGC(GCPtr pGC) { @@ -1371,10 +1359,9 @@ void nxagentFreeScratchGC(GCPtr pGC) } /* - * The GCs belonging to this list are used - * only in the synchronization put images, - * to be sure they preserve the default va- - * lues and to avoid XChangeGC() requests. + * The GCs belonging to this list are used only in the synchronization + * put images, to be sure they preserve the default values and to + * avoid XChangeGC() requests. */ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) @@ -1424,8 +1411,8 @@ GCPtr nxagentGetGraphicContext(DrawablePtr pDrawable) GCPtr nxagentCreateGraphicContext(int depth) { /* - * We have not found a GC, so we have - * to spread the list and add a new GC. + * We have not found a GC, so we have to spread the list and add a + * new GC. */ nxagentGraphicContextsPtr nxagentGCs = realloc(nxagentGraphicContexts, (nxagentGraphicContextsSize + 1) * sizeof(nxagentGraphicContextsRec)); @@ -1467,9 +1454,8 @@ GCPtr nxagentCreateGraphicContext(int depth) } /* - * The IncludeInferiors property is useful to - * solve problems when synchronizing windows - * covered by an invisible child. + * The IncludeInferiors property is useful to solve problems when + * synchronizing windows covered by an invisible child. */ attributes[1] = IncludeInferiors; @@ -1491,9 +1477,9 @@ GCPtr nxagentCreateGraphicContext(int depth) } /* - * This initialization is called in the InitOutput() - * function immediately after opening the screen, - * which is used to create the GCs. + * This initialization is called in the InitOutput() function + * immediately after opening the screen, which is used to create the + * GCs. */ void nxagentAllocateGraphicContexts(void) -- cgit v1.2.3 From bbb23e586f9739be4ffe9a9c9dc2373fe326daa2 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:25:11 +0200 Subject: GC.c: condense code remove some empty lines to make the code more compact --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 36 ++------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 469076d80..df2fd2bb0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -183,24 +183,18 @@ Bool nxagentCreateGC(GCPtr pGC) pPriv->bpp = BitsPerPixel (pGC->depth); - nxagentGCPriv(pGC)->nClipRects = 0; - - memset(&(nxagentGCPriv(pGC) -> lastServerValues), 0, sizeof(XGCValues)); - /* * Init to default GC values. */ + memset(&(nxagentGCPriv(pGC) -> lastServerValues), 0, sizeof(XGCValues)); nxagentGCPriv(pGC) -> lastServerValues.background = 1; - nxagentGCPriv(pGC) -> lastServerValues.plane_mask = ~0; - nxagentGCPriv(pGC) -> lastServerValues.graphics_exposures = 1; - nxagentGCPriv(pGC) -> lastServerValues.dashes = 4; + nxagentGCPriv(pGC) -> nClipRects = 0; nxagentGCPriv(pGC) -> mid = FakeClientID(serverClient -> index); - nxagentGCPriv(pGC) -> pPixmap = NULL; AddResource(nxagentGCPriv(pGC) -> mid, RT_NX_GC, (void *) pGC); @@ -514,13 +508,11 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_NONE: { clipsMatch = (pGC -> clientClipType == None); - break; } case CT_REGION: { clipsMatch = nxagentCompareRegions(pGC -> clientClip, (RegionPtr) pValue); - break; } case CT_UNSORTED: @@ -529,17 +521,13 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_YXBANDED: { RegionPtr pReg = RegionFromRects(nRects, (xRectangle *)pValue, type); - clipsMatch = nxagentCompareRegions(pGC -> clientClip, pReg); - RegionDestroy(pReg); - break; } default: { clipsMatch = 0; - break; } } @@ -559,7 +547,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) { XSetClipMask(nxagentDisplay, nxagentGC(pGC), None); } - break; } case CT_REGION: @@ -584,7 +571,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pRects, nRects, Unsorted); SAFE_free(pRects); } - break; } case CT_PIXMAP: @@ -613,7 +599,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, Unsorted); } - break; } case CT_YSORTED: @@ -624,7 +609,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YSorted); } - break; } case CT_YXSORTED: @@ -635,7 +619,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YXSorted); } - break; } case CT_YXBANDED: @@ -646,7 +629,6 @@ void nxagentChangeClip(GCPtr pGC, int type, void * pValue, int nRects) pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YXBanded); } - break; } } @@ -764,11 +746,9 @@ void nxagentCopyClip(GCPtr pGCDst, GCPtr pGCSrc) nxagentChangeClip(pGCDst, CT_PIXMAP, pGCSrc->clientClip, 0); break; - case CT_NONE: nxagentDestroyClip(pGCDst); break; - } } @@ -1061,14 +1041,12 @@ void nxagentDisconnectGC(void * p0, XID x1, void * p2) fprintf(stderr, "nxagentDisconnectGC: WARNING! pGC is NULL.\n"); #endif } - return; } if (pGC -> stipple) { PixmapPtr pMap = pGC -> stipple; - nxagentDisconnectPixmap(nxagentRealPixmap(pMap), 0, pBool); } } @@ -1131,7 +1109,6 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_NONE: XSetClipMask(nxagentDisplay, nxagentGC(pGC), None); break; - case CT_REGION: if (nxagentGCPriv(pGC)->pPixmap == NULL) { @@ -1164,11 +1141,8 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) XSetClipOrigin(nxagentDisplay, nxagentGC(pGC), pGC -> clipOrg.x, pGC -> clipOrg.y); } - break; - case CT_PIXMAP: - XSetClipMask(nxagentDisplay, nxagentGC(pGC), nxagentPixmap((PixmapPtr)pValue)); @@ -1183,25 +1157,21 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) type = CT_REGION; break; - case CT_UNSORTED: XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, Unsorted); break; - case CT_YSORTED: XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YSorted); break; - case CT_YXSORTED: XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YXSorted); break; - case CT_YXBANDED: XSetClipRectangles(nxagentDisplay, nxagentGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, @@ -1277,7 +1247,6 @@ static int nxagentCompareRegions(RegionPtr r1, RegionPtr r2) else if (RegionRects(r1)[i].y2 != RegionRects(r2)[i].y2) return 0; } } - return 1; } @@ -1489,7 +1458,6 @@ void nxagentAllocateGraphicContexts(void) for (int i = 0; i < nxagentNumDepths; i++) { nxagentCreateGraphicContext(*depths); - depths++; } } -- cgit v1.2.3 From fae611c91be11511a673ce99513099b4e70ff3d9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:36:13 +0200 Subject: Client.c: save some lines --- nx-X11/programs/Xserver/hw/nxagent/Client.c | 71 ++++++++++++----------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index 6ea0c4fcf..6568859d1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -54,8 +54,7 @@ #include "Utils.h" /* - * Need to include this after the stub - * definition of GC in Agent.h. + * Need to include this after the stub definition of GC in Agent.h. */ #include "compext/Compext.h" @@ -70,22 +69,20 @@ #undef DEBUG /* - * Returns the last signal delivered - * to the process. + * Returns the last signal delivered to the process. */ extern int _X11TransSocketCheckSignal(void); /* - * Time in milliseconds of first iteration - * through the dispatcher. + * Time in milliseconds of first iteration through the dispatcher. */ unsigned long nxagentStartTime = -1; /* - * If defined, add a function checking if we - * need a null timeout after a client wakeup. + * If defined, add a function checking if we need a null timeout after + * a client wakeup. */ #undef CHECK_RESTARTED_CLIENTS @@ -103,8 +100,8 @@ void nxagentCheckRestartedClients(struct timeval **timeout); int nxagentClientPrivateIndex; /* - * The master nxagent holds in nxagentShadowCounter - * the number of shadow nxagents connected to itself. + * The master nxagent holds in nxagentShadowCounter the number of + * shadow nxagents connected to itself. */ int nxagentShadowCounter = 0; @@ -120,8 +117,8 @@ void nxagentInitClientPrivates(ClientPtr client) } /* - * Guess the running application based on the - * properties attached to its main window. + * Guess the running application based on the properties attached to + * its main window. */ void nxagentGuessClientHint(ClientPtr client, Atom property, char *data) @@ -199,8 +196,8 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property) #endif /* - * From this moment on we ignore the visibility - * checks to keep the windows updated. + * From this moment on we ignore the visibility checks to keep + * the windows updated. */ nxagentChangeOption(IgnoreVisibility, 1); @@ -210,7 +207,6 @@ void nxagentGuessShadowHint(ClientPtr client, Atom property) void nxagentCheckIfShadowAgent(ClientPtr client) { - if (nxagentClientPriv(client) -> clientHint == NXAGENT_SHADOW) { #ifdef TEST @@ -234,14 +230,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client) nxagentShadowCounter); #endif - if (nxagentShadowCounter == 0) { /* - * The last shadow nxagent has been detached - * from master nxagent. - * The master nxagent could do some action - * here. + * The last shadow nxagent has been detached from master + * nxagent. The master nxagent could do some action here. */ #ifdef TEST @@ -255,13 +248,11 @@ void nxagentCheckIfShadowAgent(ClientPtr client) void nxagentWakeupByReconnect(void) { - int i; - #ifdef TEST fprintf(stderr, "++++++nxagentWakeupByReconnect: Going to wakeup all clients.\n"); #endif - for (i = 1; i < currentMaxClients; i++) + for (int i = 1; i < currentMaxClients; i++) { if (clients[i] != NULL) { @@ -343,8 +334,7 @@ void nxagentWaitWakeupBySplit(ClientPtr client) #endif /* - * Be sure we intercept an I/O error - * as well as an interrupt. + * Be sure we intercept an I/O error as well as an interrupt. */ #ifdef USE_FINISH_SPLIT @@ -358,11 +348,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client) for (;;) { /* - * Can we handle all the possible events here - * or we need to select only the split events? - * Handling all the possible events would pre- - * empt the queue and make a better use of the - * link. + * Can we handle all the possible events here or we need to select + * only the split events? Handling all the possible events would + * preempt the queue and make a better use of the link. */ #ifdef WAIT_ALL_EVENTS @@ -407,9 +395,9 @@ void nxagentWaitWakeupBySplit(ClientPtr client) int nxagentSuspendBySplit(ClientPtr client) { /* -FIXME: Should record a serial number for the client, so that - the client is not restarted because of an end of split - of a previous client with the same index. +FIXME: Should record a serial number for the client, so that the + client is not restarted because of an end of split of a + previous client with the same index. */ if (client -> index < MAX_CONNECTIONS) { @@ -453,9 +441,9 @@ FIXME: Should record a serial number for the client, so that int nxagentWakeupBySplit(ClientPtr client) { /* -FIXME: Should record a serial number for the client, so that - the client is not restarted because of the end of the - split for a previous client with the same index. +FIXME: Should record a serial number for the client, so that the + client is not restarted because of the end of the split for a + previous client with the same index. */ if (client -> index < MAX_CONNECTIONS) { @@ -498,16 +486,13 @@ void nxagentCheckRestartedClients(struct timeval **timeout) { static struct timeval zero; - int i; - /* - * If any of the restarted clients had requests - * in input we'll need to enter the select with - * a null timeout, or we will block until any - * other client becomes available. + * If any of the restarted clients had requests in input we'll need + * to enter the select with a null timeout, or we will block until + * any other client becomes available. */ - for (i = 1; i < currentMaxClients; i++) + for (int i = 1; i < currentMaxClients; i++) { if (clients[i] != NULL && clients[i] -> osPrivate != NULL && nxagentNeedWakeup(clients[i]) == 0) -- cgit v1.2.3 From ace3d2d89a4a3783aa6033f3bd9d4e38b48e11c9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:40:49 +0200 Subject: Colormap.c: save some lines --- nx-X11/programs/Xserver/hw/nxagent/Colormap.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c index b04977887..9308390fe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Colormap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Colormap.c @@ -296,12 +296,10 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen) */ if (icws.numWindows) { - WindowPtr pWin; - Visual *visual; ColormapPtr pCmap; - pWin = nxagentWindowPtr(icws.windows[0]); - visual = nxagentVisualFromID(pScreen, wVisual(pWin)); + WindowPtr pWin = nxagentWindowPtr(icws.windows[0]); + Visual *visual = nxagentVisualFromID(pScreen, wVisual(pWin)); if (visual == nxagentDefaultVisual(pScreen)) pCmap = (ColormapPtr)LookupIDByType(wColormap(pWin), @@ -380,9 +378,7 @@ void nxagentDirectUninstallColormaps(ScreenPtr pScreen) int n = (*pScreen->ListInstalledColormaps)(pScreen, pCmapIDs); for (int i = 0; i < n; i++) { - ColormapPtr pCmap; - - pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); + ColormapPtr pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i], RT_COLORMAP); if (pCmap) XUninstallColormap(nxagentDisplay, nxagentColormap(pCmap)); } -- cgit v1.2.3 From 5067b1695fa38596526e72781bdd5391f4b316cf Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 22:56:08 +0200 Subject: Cursor.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index 55abefffd..34672fef5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -78,10 +78,8 @@ is" without express or implied warranty. #undef DEBUG /* - * Defined in Display.c. There are huge - * problems mixing the GC definition in - * Xlib with the server code. This must - * be reworked. + * Defined in Display.c. There are huge problems mixing the GC + * definition in Xlib with the server code. This must be reworked. */ extern XlibGC nxagentBitmapGC; @@ -124,11 +122,9 @@ void nxagentCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) { - /* - * Don't define the root cursor - * so that nxagent root window - * inherits the parent's cursor. + * Don't define the root cursor so that nxagent root window inherits + * the parent's cursor. */ Cursor cursor = (pCursor != rootCursor) ? nxagentCursor(pCursor, pScreen): None; @@ -191,11 +187,9 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) BitmapPad(nxagentDisplay), 0); /* - * If we used nxagentImageNormalize() here, - * we'd swap our own cursor data in place. - * Change byte_order and bitmap_bit_order - * in the image struct to let Xlib do the - * swap for us. + * If we used nxagentImageNormalize() here, we'd swap our own cursor + * data in place. Change byte_order and bitmap_bit_order in the + * image struct to let Xlib do the swap for us. */ image -> byte_order = IMAGE_BYTE_ORDER; @@ -310,8 +304,8 @@ Bool nxagentSetCursorPosition(ScreenPtr pScreen, int x, int y, else { /* - * Calling miSetCursorPosition with generateEvent == 0 - * causes a crash in miPoiterUpdate(). + * Calling miSetCursorPosition with generateEvent == 0 causes a + * crash in miPoiterUpdate(). */ return 1; -- cgit v1.2.3 From 838572f7b3cbd0005486dc076ba0df6ec8fab50a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 23:02:56 +0200 Subject: Dialog.c: save some lines --- nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 37 ++++------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index 0dcdda5a4..ccea93a92 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -198,7 +198,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_KILL_SESSION_TYPE; local = DIALOG_KILL_SESSION_LOCAL; pid = &nxagentKillDialogPid; - break; } case DIALOG_SUSPEND_SESSION: @@ -207,7 +206,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_SUSPEND_SESSION_TYPE; local = DIALOG_SUSPEND_SESSION_LOCAL; pid = &nxagentSuspendDialogPid; - break; } case DIALOG_ROOTLESS: @@ -216,7 +214,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ROOTLESS_TYPE; local = DIALOG_ROOTLESS_LOCAL; pid = &nxagentRootlessDialogPid; - break; } case DIALOG_PULLDOWN: @@ -226,7 +223,6 @@ void nxagentLaunchDialog(DialogType dialogType) local = DIALOG_PULLDOWN_LOCAL; pid = &nxagentPulldownDialogPid; window = nxagentPulldownWindow; - break; } case DIALOG_FONT_REPLACEMENT: @@ -235,7 +231,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_FONT_REPLACEMENT_TYPE; local = DIALOG_FONT_REPLACEMENT_LOCAL; pid = &nxagentFontsReplacementDialogPid; - break; } case DIALOG_FAILED_RECONNECTION: @@ -244,7 +239,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_FAILED_RECONNECTION_TYPE; local = DIALOG_FAILED_RECONNECTION_LOCAL; pid = &nxagentFailedReconnectionDialogPid; - break; } case DIALOG_ENABLE_DESKTOP_RESIZE_MODE: @@ -253,7 +247,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_TYPE; local = DIALOG_ENABLE_DESKTOP_RESIZE_MODE_LOCAL; pid = &nxagentEnableRandRModeDialogPid; - break; } case DIALOG_DISABLE_DESKTOP_RESIZE_MODE: @@ -262,7 +255,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_TYPE; local = DIALOG_DISABLE_DESKTOP_RESIZE_MODE_LOCAL; pid = &nxagentDisableRandRModeDialogPid; - break; } case DIALOG_ENABLE_DEFER_MODE: @@ -271,7 +263,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_DEFER_MODE_TYPE; local = DIALOG_ENABLE_DEFER_MODE_LOCAL; pid = &nxagentEnableDeferModePid; - break; } case DIALOG_DISABLE_DEFER_MODE: @@ -280,7 +271,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_DEFER_MODE_TYPE; local = DIALOG_DISABLE_DEFER_MODE_LOCAL; pid = &nxagentDisableDeferModePid; - break; } case DIALOG_ENABLE_AUTOGRAB_MODE: @@ -289,7 +279,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_ENABLE_AUTOGRAB_MODE_TYPE; local = DIALOG_ENABLE_AUTOGRAB_MODE_LOCAL; pid = &nxagentEnableAutograbModePid; - break; } case DIALOG_DISABLE_AUTOGRAB_MODE: @@ -298,7 +287,6 @@ void nxagentLaunchDialog(DialogType dialogType) type = DIALOG_DISABLE_AUTOGRAB_MODE_TYPE; local = DIALOG_DISABLE_AUTOGRAB_MODE_LOCAL; pid = &nxagentDisableAutograbModePid; - break; } default: @@ -325,8 +313,7 @@ void nxagentLaunchDialog(DialogType dialogType) } /* - * We don't want to receive SIGCHLD - * before we store the child pid. + * We don't want to receive SIGCHLD before we store the child pid. */ sigemptyset(&set); @@ -346,8 +333,7 @@ void nxagentLaunchDialog(DialogType dialogType) dialogDisplay[0] = '\0'; /* - * Restore the previous set of - * blocked signal. + * Restore the previous set of blocked signal. */ sigprocmask(SIG_SETMASK, &oldSet, NULL); @@ -385,8 +371,7 @@ void nxagentFailedReconnectionDialog(int alert, char *error) NXTransAlert(alert, NX_ALERT_REMOTE); /* - * Make it possible to interrupt the - * loop with a signal. + * Make it possible to interrupt the loop with a signal. */ while (NXDisplayError(nxagentDisplay) == 0 && @@ -477,73 +462,61 @@ void nxagentTerminateDialog(DialogType type) case DIALOG_KILL_SESSION: { pid = nxagentKillDialogPid; - break; } case DIALOG_SUSPEND_SESSION: { pid = nxagentSuspendDialogPid; - break; } case DIALOG_ROOTLESS: { pid = nxagentRootlessDialogPid; - break; } case DIALOG_PULLDOWN: { pid = nxagentPulldownDialogPid; - break; } case DIALOG_FONT_REPLACEMENT: { pid = nxagentFontsReplacementDialogPid; - break; } case DIALOG_FAILED_RECONNECTION: { pid = nxagentFailedReconnectionDialogPid; - break; } case DIALOG_ENABLE_DESKTOP_RESIZE_MODE: { pid = nxagentEnableRandRModeDialogPid; - break; } case DIALOG_DISABLE_DESKTOP_RESIZE_MODE: { pid = nxagentDisableRandRModeDialogPid; - break; } case DIALOG_ENABLE_DEFER_MODE: { pid = nxagentEnableDeferModePid; - break; } case DIALOG_DISABLE_DEFER_MODE: { pid = nxagentDisableDeferModePid; - break; } case DIALOG_ENABLE_AUTOGRAB_MODE: { pid = nxagentEnableAutograbModePid; - break; } case DIALOG_DISABLE_AUTOGRAB_MODE: { pid = nxagentDisableAutograbModePid; - break; } default: @@ -577,13 +550,11 @@ void nxagentTerminateDialog(DialogType type) void nxagentTerminateDialogs(void) { - DialogType type; - #ifdef DEBUG fprintf(stderr, "nxagentTerminateDialogs: Terminating all the running dialogs.\n"); #endif - for (type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++) + for (DialogType type = DIALOG_FIRST_TAG; type < DIALOG_LAST_TAG; type++) { nxagentTerminateDialog(type); } -- cgit v1.2.3 From b1d156888a3a75f1ec394702b1d4d8b10ef3e91f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 23:42:13 +0200 Subject: Display.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 267 ++++++++++++--------------- 1 file changed, 113 insertions(+), 154 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 27e5aee79..50f85b257 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -212,20 +212,18 @@ int nxagentServerOrder(void) } /* - * FIXME: This error handler is not printing anything - * in the session log. This is OK once the session is - * started, because the error is handled by the other - * layers, but not before that point, as the agent - * would die without giving any feedback to the user - * (or, worse, to the NX server). We should check how - * many requests have been handled for this display - * and print a message if the display dies before the - * session is up and running. + * FIXME: This error handler is not printing anything in the session + * log. This is OK once the session is started, because the error is + * handled by the other layers, but not before that point, as the + * agent would die without giving any feedback to the user (or, worse, + * to the NX server). We should check how many requests have been + * handled for this display and print a message if the display dies + * before the session is up and running. */ /* - * FIXME: This should be moved to Error.c, The other - * handlers should be probably moved to Handlers.c. + * FIXME: This should be moved to Error.c, The other handlers should + * be probably moved to Handlers.c. */ int nxagentIOErrorHandler(Display *display) @@ -246,11 +244,9 @@ int nxagentIOErrorHandler(Display *display) } /* - * Force a shutdown of any connection attempt - * while connecting to the remote display. - * This is needed to avoid a hang up in case - * of loopback connections to our own listen- - * ing sockets. + * Force a shutdown of any connection attempt while connecting to the + * remote display. This is needed to avoid a hang up in case of + * loopback connections to our own listening sockets. */ static void nxagentRejectConnection(int signal) @@ -266,16 +262,15 @@ static void nxagentRejectConnection(int signal) #endif /* - * A further timeout is unlikely to happen - * in the case of loopback connections. + * A further timeout is unlikely to happen in the case of loopback + * connections. */ alarm(5); } /* - * Ignore the signal if the NX transport is - * not running. + * Ignore the signal if the NX transport is not running. */ static void nxagentSigusrHandler(int signal) @@ -379,8 +374,8 @@ static void nxagentSigchldHandler(int signal) int options = WNOHANG | WUNTRACED; /* - * Try with the pid of the dialog process. - * Leave the other children unaffected. + * Try with the pid of the dialog process. Leave the other children + * unaffected. */ if (nxagentRootlessDialogPid) @@ -574,22 +569,19 @@ Display *nxagentInternalOpenDisplay(char *display) int result; /* - * Stop the smart schedule timer since - * it uses SIGALRM as we do. + * Stop the smart schedule timer since it uses SIGALRM as we do. */ nxagentStopTimer(); /* - * Install the handler rejecting a possible - * loopback connection. + * Install the handler rejecting a possible loopback connection. */ /* -FIXME: Should print a warning if the user tries to let - the agent impersonate the same display as the - display where the agent is supposed to connect. - We actually handle this by means of RejectWell- - KnownSockets() but without giving a friendly +FIXME: Should print a warning if the user tries to let the agent + impersonate the same display as the display where the agent is + supposed to connect. We actually handle this by means of + RejectWellKnownSockets() but without giving a friendly explanation for the error to the user. */ @@ -645,9 +637,8 @@ static void nxagentDisplayBlockHandler(Display *display, int reason) if (nxagentDisplay != NULL) { /* - * Don't allow the smart schedule to - * interrupt the agent while waiting - * for the remote display. + * Don't allow the smart schedule to interrupt the agent while + * waiting for the remote display. */ #ifdef DEBUG @@ -674,8 +665,7 @@ static void nxagentDisplayBlockHandler(Display *display, int reason) { /* - * Let the dispatch attend the next - * client. + * Let the dispatch attend the next client. */ #ifdef DEBUG @@ -799,18 +789,17 @@ static int nxagentDisplayErrorPredicate(Display *display, int error) void nxagentInstallDisplayHandlers(void) { /* - * If the display was already opened, be sure - * all structures are freed. + * If the display was already opened, be sure all structures are + * freed. */ nxagentResetDisplayHandlers(); /* - * We want the Xlib I/O error handler to return, - * instead of quitting the application. Using - * setjmp()/longjmp() leaves the door open to - * unexpected bugs when dealing with interaction - * with the other X server layers. + * We want the Xlib I/O error handler to return, instead of quitting + * the application. Using setjmp()/longjmp() leaves the door open to + * unexpected bugs when dealing with interaction with the other X + * server layers. */ NXHandleDisplayError(1); @@ -828,14 +817,12 @@ void nxagentInstallDisplayHandlers(void) XSetIOErrorHandler(nxagentIOErrorHandler); /* - * Let Xlib become aware of our interrupts. In theory - * we don't need to have the error handler installed - * during the normal operations and could simply let - * the dispatcher handle the interrupts. In practice - * it's better to have Xlib invalidating the display - * as soon as possible rather than incurring in the - * risk of entering a loop that doesn't care checking - * the display errors explicitly. + * Let Xlib become aware of our interrupts. In theory we don't need + * to have the error handler installed during the normal operations + * and could simply let the dispatcher handle the interrupts. In + * practice it's better to have Xlib invalidating the display as + * soon as possible rather than incurring in the risk of entering a + * loop that doesn't care checking the display errors explicitly. */ #ifdef TEST @@ -848,8 +835,8 @@ void nxagentInstallDisplayHandlers(void) void nxagentPostInstallDisplayHandlers(void) { /* - * This is executed after having opened the - * display, once we know the display address. + * This is executed after having opened the display, once we know + * the display address. */ if (nxagentDisplay != NULL) @@ -881,15 +868,13 @@ void nxagentResetDisplayHandlers(void) if (nxagentDisplay != NULL) { /* - * Free the internal nxcompext - * structures. + * Free the internal nxcompext structures. */ NXResetDisplay(nxagentDisplay); /* - * Remove the display descriptor - * from the listened sockets. + * Remove the display descriptor from the listened sockets. */ nxagentRemoveXConnection(); @@ -912,8 +897,7 @@ void nxagentResetDisplayHandlers(void) nxagentCongestion = 0; /* - * Reset the counter of synchronization - * requests pending. + * Reset the counter of synchronization requests pending. */ nxagentTokens.soft = 0; @@ -937,9 +921,8 @@ void nxagentInstallSignalHandlers(void) #endif /* - * Keep the default X server's handlers for - * SIGINT and SIGTERM and restore the other - * signals of interest to our defaults. + * Keep the default X server's handlers for SIGINT and SIGTERM and + * restore the other signals of interest to our defaults. */ struct sigaction newAction; @@ -947,9 +930,9 @@ void nxagentInstallSignalHandlers(void) int result; /* - * By default nxcomp installs its signal handlers. - * We need to ensure that SIGUSR1 and SIGUSR2 are - * ignored if the NX transport is not running. + * By default nxcomp installs its signal handlers. We need to + * ensure that SIGUSR1 and SIGUSR2 are ignored if the NX transport + * is not running. */ newAction.sa_handler = nxagentSigusrHandler; @@ -993,8 +976,7 @@ void nxagentInstallSignalHandlers(void) } /* - * Let the smart schedule set the SIGALRM - * handler again. + * Let the smart schedule set the SIGALRM handler again. */ nxagentInitTimer(); @@ -1043,13 +1025,12 @@ void nxagentPostInstallSignalHandlers(void) #endif /* - * Reconfigure our signal handlers to work well - * with the NX transport. + * Reconfigure our signal handlers to work well with the NX + * transport. * - * Let our handlers manage the SIGINT and SIGTERM. - * The following calls will tell the NX transport - * to restore the old handlers (those originally - * installed by us or the X server). + * Let our handlers manage the SIGINT and SIGTERM. The following + * calls will tell the NX transport to restore the old handlers + * (those originally installed by us or the X server). */ NXTransSignal(SIGINT, NX_SIGNAL_DISABLE); @@ -1062,16 +1043,14 @@ void nxagentPostInstallSignalHandlers(void) NXTransSignal(SIGHUP, NX_SIGNAL_DISABLE); /* - * Both the proxy and the agent need to catch - * their children, so we'll have to send the - * signal to transport. + * Both the proxy and the agent need to catch their children, so + * we'll have to send the signal to transport. */ NXTransSignal(SIGCHLD, NX_SIGNAL_DISABLE); /* - * Let the NX transport take care of SIGUSR1 - * and SIGUSR2. + * Let the NX transport take care of SIGUSR1 and SIGUSR2. */ } @@ -1084,8 +1063,7 @@ void nxagentResetSignalHandlers(void) memset(&newAction, 0, sizeof(newAction)); /* - * Reset the signal handlers - * to a well known state. + * Reset the signal handlers to a well known state. */ #ifdef TEST @@ -1111,8 +1089,7 @@ void nxagentResetSignalHandlers(void) } /* - * Let the smart schedule set the SIGALRM - * handler again. + * Let the smart schedule set the SIGALRM handler again. */ nxagentInitTimer(); @@ -1134,8 +1111,8 @@ void nxagentOpenDisplay(int argc, char *argv[]) #endif /* - * Initialize the reconnector only in the case - * of persistent sessions. + * Initialize the reconnector only in the case of persistent + * sessions. */ if (nxagentOption(Persistent)) @@ -1163,8 +1140,8 @@ void nxagentOpenDisplay(int argc, char *argv[]) if (nxagentDisplay == NULL) { /* -FIXME: The agent should never exit the program with a FatalError() - but rather use a specific function that may eventually call +FIXME: The agent should never exit the program with a FatalError() but + rather use a specific function that may eventually call FatalError() on its turn. */ FatalError("Unable to open display '%s'.\n", nxagentDisplayName); @@ -1264,18 +1241,17 @@ N/A #endif /* - * Initialize the agent's event mask that will be requested - * for the root and all the top level windows. If the nested - * window is a child of an existing window, we will need to - * receive StructureNotify events. If we are going to manage - * the changes in root window's visibility we'll also need - * VisibilityChange events. + * Initialize the agent's event mask that will be requested for the + * root and all the top level windows. If the nested window is a + * child of an existing window, we will need to receive + * StructureNotify events. If we are going to manage the changes in + * root window's visibility we'll also need VisibilityChange events. */ /* -FIXME: Use of nxagentParentWindow is strongly deprecated. - We need also to clarify which events are selected - in the different operating modes. +FIXME: Use of nxagentParentWindow is strongly deprecated. We need + also to clarify which events are selected in the different + operating modes. */ nxagentInitDefaultEventMask(); @@ -1290,9 +1266,8 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. (void) nxagentCheckForPixmapFormatsCompatibility(); /* - * Create a pixmap for each depth matching the - * local supported formats with format available - * on the remote display. + * Create a pixmap for each depth matching the local supported + * formats with format available on the remote display. */ nxagentSetDefaultDrawables(); @@ -1305,16 +1280,15 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. #endif /* - * This GC is referenced in Cursor.c. It can be - * probably removed. + * This GC is referenced in Cursor.c. It can be probably removed. */ nxagentBitmapGC = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[1], 0L, NULL); /* - * Note that this "confine window" is useless at the - * moment as we reimplement nxagentConstrainCursor() - * to skip the "constrain" stuff. + * Note that this "confine windoqw" is useless at the moment as we + * reimplement nxagentConstrainCursor() to skip the "constrain" + * stuff. */ #ifdef TEST @@ -1568,10 +1542,10 @@ void nxagentInitDepths(void) void nxagentInitPixmapFormats(void) { /* - * Formats are created with no care of which are supported - * on the real display. Creating only formats supported - * by the remote end makes troublesome handling migration - * of session from a display to another. + * Formats are created with no care of which are supported on the + * real display. Creating only formats supported by the remote end + * makes troublesome handling migration of session from a display to + * another. */ nxagentNumPixmapFormats = 0; @@ -1732,11 +1706,9 @@ void nxagentCloseDisplay(void) } /* - * If nxagentDoFullGeneration is true, all - * the X resources will be destroyed upon - * closing the display connection, so there - * is no real need to generate additional - * traffic + * If nxagentDoFullGeneration is true, all the X resources will be + * destroyed upon closing the display connection, so there is no + * real need to generate additional traffic */ SAFE_free(nxagentDefaultColormaps); @@ -1753,8 +1725,7 @@ FIXME: Is this needed? */ /* - * Free the image cache. This is useful - * for detecting memory leaks. + * Free the image cache. This is useful for detecting memory leaks. */ if (nxagentDisplay != NULL) @@ -1836,14 +1807,11 @@ void nxagentBackupDisplayInfo(void) } /* - * Since we need the display structure - * in order to behave correctly when no X - * connection is available, we must always - * have a good display record. - * It can be discarded only when a new X - * connection is available, so we store it - * in order to destroy whenever the recon- - * nection succed. + * Since we need the display structure in order to behave correctly + * when no X connection is available, we must always have a good + * display record. It can be discarded only when a new X connection + * is available, so we store it in order to destroy whenever the + * reconnection succeeds. */ nxagentDisplayBackup = nxagentDisplay; @@ -1925,9 +1893,8 @@ void nxagentDisconnectDisplay(void) case GOT_VISUAL_INFO: case OPENED: /* - * Actually we need the nxagentDisplay - * structure in order to let the agent - * go when no X connection is available. + * Actually we need the nxagentDisplay structure in order to let + * the agent go when no X connection is available. */ if (nxagentDisplay && @@ -2328,10 +2295,9 @@ static int nxagentInitAndCheckVisuals(int flexibility) if (nxagentCompareVisuals(nxagentVisuals[i], viList[n]) == 1) { /* -FIXME: Should the visual be ignored in this case? - We can flag the visuals with inverted masks, - and use this information to switch the masks - when contacting the remote X server. +FIXME: Should the visual be ignored in this case? We can flag the + visuals with inverted masks, and use this information to switch + the masks when contacting the remote X server. */ if (nxagentVisuals[i].red_mask == viList[n].blue_mask && nxagentVisuals[i].blue_mask == viList[n].red_mask) @@ -2502,9 +2468,8 @@ Bool nxagentReconnectDisplay(void *p0) DefaultScreenOfDisplay(nxagentDisplay)); /* - * After processing the arguments all the - * timeout values have been set. Now we - * have to change the screen-saver timeout. + * After processing the arguments all the timeout values have been + * set. Now we have to change the screen-saver timeout. */ nxagentSetScreenSaverTime(); @@ -2585,8 +2550,7 @@ Bool nxagentReconnectDisplay(void *p0) SAFE_XFree(nxagentRemotePixmapFormats); /* - * Check if all the required pixmap - * formats are supported. + * Check if all the required pixmap formats are supported. */ nxagentInitPixmapFormats(); @@ -2602,9 +2566,8 @@ Bool nxagentReconnectDisplay(void *p0) reconnectDisplayState = GOT_PIXMAP_FORMAT_LIST; /* - * Create a pixmap for each depth matching the - * local supported formats with format available - * on the remote display. + * Create a pixmap for each depth matching the local supported + * formats with format available on the remote display. */ nxagentSetDefaultDrawables(); @@ -2632,12 +2595,11 @@ Bool nxagentReconnectDisplay(void *p0) nxagentWhitePixel = WhitePixel(nxagentDisplay, DefaultScreen(nxagentDisplay)); /* - * Initialize the agent's event mask that will be requested - * for the root or all the top level windows. If the nested - * window is a child of an existing window we will need to - * receive StructureNotify events. If we are going to manage - * the changes in root window's visibility we'll also need - * VisibilityChange events. + * Initialize the agent's event mask that will be requested for the + * root or all the top level windows. If the nested window is a + * child of an existing window we will need to receive + * StructureNotify events. If we are going to manage the changes in + * root window's visibility we'll also need VisibilityChange events. */ nxagentInitDefaultEventMask(); @@ -2667,8 +2629,7 @@ Bool nxagentReconnectDisplay(void *p0) useXpmIcon = nxagentMakeIcon(nxagentDisplay, &nxagentIconPixmap, &nxagentIconShape); /* - * All went fine. We can continue - * handling our clients. + * All went fine. We can continue handling our clients. */ reconnectDisplayState = EVERYTHING_DONE; @@ -2701,10 +2662,9 @@ void nxagentRemoveXConnection(void) } /* - * Force an I/O error and wait until the NX trans- - * port is gone. It must be called before suspend- - * ing or terminating a session to ensure that the - * NX transport is terminated first. + * Force an I/O error and wait until the NX transport is gone. It must + * be called before suspending or terminating a session to ensure that + * the NX transport is terminated first. */ void nxagentWaitDisplay(void) @@ -2742,8 +2702,7 @@ void nxagentWaitDisplay(void) #endif /* - * Be sure the signal handlers are - * in a known state. + * Be sure the signal handlers are in a known state. */ nxagentResetSignalHandlers(); @@ -2760,9 +2719,9 @@ void nxagentWaitDisplay(void) void nxagentAbortDisplay(void) { /* - * Be sure the X server socket in .X11-unix is - * deleted otherwise other users may to become - * unable to run a session on the same display. + * Be sure the X server socket in .X11-unix is deleted otherwise + * other users may to become unable to run a session on the same + * display. */ #ifdef TEST -- cgit v1.2.3 From 24cb46d24f98f27d0020aae1b0651407947c4d45 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 22 Oct 2019 23:45:23 +0200 Subject: Error.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index dfc96d3f0..ed1580efa 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -397,9 +397,8 @@ char *nxagentGetRootPath(void) #endif /* - * We will determine the root NX directory - * based on the NX_HOME or HOME directory - * settings. + * We will determine the root NX directory based on the NX_HOME + * or HOME directory settings. */ char *homeEnv = nxagentGetHomePath(); @@ -490,10 +489,9 @@ char *nxagentGetSessionPath(void) if (*nxagentSessionDir == '\0') { /* - * If nxagentSessionId does not exist we - * assume that the sessionPath cannot be - * realized and do not use the clients - * log file. + * If nxagentSessionId does not exist we assume that the + * sessionPath cannot be realized and do not use the clients log + * file. */ if (*nxagentSessionId == '\0') -- cgit v1.2.3 From 9b1e29937c39c23a9db6bc1c3661cb2cf2e50671 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 23 Oct 2019 00:12:48 +0200 Subject: Image.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 349 ++++++++++++----------------- 1 file changed, 149 insertions(+), 200 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index 6c239012b..890706ba5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -59,9 +59,8 @@ #undef DUMP /* - * Don't pack the images having a width, a - * height or a data size smaller or equal - * to these thresholds. + * Don't pack the images having a width, a height or a data size + * smaller or equal to these thresholds. */ #define IMAGE_PACK_WIDTH 2 @@ -69,16 +68,14 @@ #define IMAGE_PACK_LENGTH 512 /* - * Compress the image with a lossless encoder - * if the percentage of discrete pixels in the - * image is below this threshold. + * Compress the image with a lossless encoder if the percentage of + * discrete pixels in the image is below this threshold. */ #define IMAGE_UNIQUE_RATIO 10 /* - * Preferred pack and split parameters we - * got from the NX transport. + * Preferred pack and split parameters we got from the NX transport. */ int nxagentPackLossless = -1; @@ -94,8 +91,8 @@ int nxagentAlphaEnabled = 0; int nxagentAlphaCompat = 0; /* - * Used to reformat image when connecting to - * displays having different byte order. + * Used to reformat image when connecting to displays having different + * byte order. */ extern void nxagentBitOrderInvert(unsigned char *, int); @@ -110,8 +107,7 @@ extern void nxagentFourByteSwap(register unsigned char *, register int); static VisualID nxagentUnpackVisualId[MAX_CONNECTIONS]; /* - * Store the last alpha data set for the - * client. + * Store the last alpha data set for the client. */ typedef struct _UnpackAlpha @@ -126,9 +122,8 @@ typedef UnpackAlphaRec *UnpackAlphaPtr; static UnpackAlphaPtr nxagentUnpackAlpha[MAX_CONNECTIONS]; /* - * Encode the imade alpha channel by using - * a specific encoding, separating it from - * the rest of the RGB data. + * Encode the imade alpha channel by using a specific encoding, + * separating it from the rest of the RGB data. */ static char *nxagentImageAlpha(XImage *ximage); @@ -141,10 +136,9 @@ static void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientP static char *nxagentImageCopy(XImage *source, XImage *destination); /* - * Return true if the image can be cached. - * Don't cache the images packed with the - * bitmap method as the encoding is little - * more expensive than a copy. + * Return true if the image can be cached. Don't cache the images + * packed with the bitmap method as the encoding is little more + * expensive than a copy. */ #define nxagentNeedCache(image, method) \ @@ -152,10 +146,8 @@ static char *nxagentImageCopy(XImage *source, XImage *destination); ((method) != PACK_BITMAP_16M_COLORS) /* - * With the bitmap encoding, if the image - * is 32 bits-per-pixel the 4th byte is not - * transmitted, so we don't need to clean - * the image. + * With the bitmap encoding, if the image is 32 bits-per-pixel the 4th + * byte is not transmitted, so we don't need to clean the image. */ #define nxagentNeedClean(image, method) \ @@ -188,11 +180,10 @@ ImageStatisticsRec nxagentImageStatistics; int nxagentImageReformat(char *base, int nbytes, int bpp, int order) { /* - * This is used whenever we need to swap the image data. - * If we got an image from an X server having a different - * endianness, we will need to reformat the image to match - * our own image-order so that ProcGetImage can return - * the expected format to the client. + * This is used whenever we need to swap the image data. If we got + * an image from an X server having a different endianness, we will + * need to reformat the image to match our own image-order so that + * ProcGetImage can return the expected format to the client. */ switch (bpp) @@ -298,10 +289,9 @@ int nxagentImagePad(int width, int format, int leftPad, int depth) } /* - * Only copy the data, not the structure. - * The data pointed by the destination is - * lost. Used to clone two images that - * point to the same data. + * Only copy the data, not the structure. The data pointed by the + * destination is lost. Used to clone two images that point to the + * same data. */ char *nxagentImageCopy(XImage *source, XImage *destination) @@ -344,8 +334,7 @@ char *nxagentImageAlpha(XImage *image) } /* - * The image is supposed to be in - * server order. + * The image is supposed to be in server order. */ int offset = (image -> byte_order == MSBFirst) ? 0 : 3; @@ -364,8 +353,7 @@ char *nxagentImageAlpha(XImage *image) } /* - * Write down the image cache statistics - * to the buffer. + * Write down the image cache statistics to the buffer. */ void nxagentImageStatisticsHandler(char **buffer, int type) @@ -381,9 +369,8 @@ FIXME: Agent cache statistics have to be implemented. } /* - * This should be called only for drawables - * having a depth of 32. In the other cases, - * it would only generate useless traffic. + * This should be called only for drawables having a depth of 32. In + * the other cases, it would only generate useless traffic. */ void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pClient) @@ -404,16 +391,15 @@ void nxagentSetUnpackAlpha(DrawablePtr pDrawable, XImage *pImage, ClientPtr pCli } /* - * If we are synchronizing the drawable, discard - * any unpack alpha stored for the client. The - * alpha data, in fact, may be still traveling - * and so we either wait until the end of the - * split or send a fresh copy. + * If we are synchronizing the drawable, discard any unpack alpha + * stored for the client. The alpha data, in fact, may be still + * traveling and so we either wait until the end of the split or + * send a fresh copy. */ /* -FIXME: Here the split trap is always set and so the caching of - the alpha channel is useless. I remember we set the trap - because of the cursor but why is it always set now? +FIXME: Here the split trap is always set and so the caching of the + alpha channel is useless. I remember we set the trap because of + the cursor but why is it always set now? */ #ifdef DEBUG fprintf(stderr, "nxagentSetUnpackAlpha: Checking alpha channel for client [%d] with trap [%d].\n", @@ -431,9 +417,8 @@ FIXME: Here the split trap is always set and so the caching of #endif /* - * Check if we are connected to a newer proxy - * version and so can send the alpha data in - * compressed form. + * Check if we are connected to a newer proxy version and so can + * send the alpha data in compressed form. */ if (nxagentAlphaCompat == 0) @@ -480,8 +465,7 @@ FIXME: Here the split trap is always set and so the caching of } /* - * The NX agent's implementation of the - * X server's image functions. + * The NX agent's implementation of the X server's image functions. */ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, @@ -502,9 +486,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, #endif /* - * If the display is down and there is not an - * nxagent attached, sleep for a while but - * still give a chance to the client to write + * If the display is down and there is not an nxagent attached, + * sleep for a while but still give a chance to the client to write * to the framebuffer. */ @@ -527,11 +510,11 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, } /* - * This is of little use because clients usually write - * to windows only after an expose event, and, in the - * rare case they use a direct put image to the window - * (for a media player it should be a necessity), they - * are likely to monitor the visibility of the window. + * This is of little use because clients usually write to windows + * only after an expose event, and, in the rare case they use a + * direct put image to the window (for a media player it should be a + * necessity), they are likely to monitor the visibility of the + * window. */ if (nxagentOption(IgnoreVisibility) == 0 && pDrawable -> type == DRAWABLE_WINDOW && @@ -548,9 +531,8 @@ void nxagentPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, } /* - * This is more interesting. Check if the operation - * will produce a visible result based on the clip - * list of the window and the GC. + * This is more interesting. Check if the operation will produce a + * visible result based on the clip list of the window and the GC. */ pRegion = nxagentCreateRegion(pDrawable, pGC, dstX, dstY, dstWidth, dstHeight); @@ -607,9 +589,8 @@ FIXME: Should use these. } /* - * We are going to realize the operation - * on the real display. Let's check if - * the link is down. + * We are going to realize the operation on the real display. Let's + * check if the link is down. */ if (NXDisplayError(nxagentDisplay) == 1) @@ -618,13 +599,11 @@ FIXME: Should use these. } /* - * Mark the region as corrupted and skip the operation - * if we went out of bandwidth. The drawable will be - * synchronized at later time. Don't do that if the - * image is likely to be a shape or a clip mask, if we - * are here because we are actually synchronizing the - * drawable or if the drawable's corrupted region is - * over-age. + * Mark the region as corrupted and skip the operation if we went + * out of bandwidth. The drawable will be synchronized at later + * time. Don't do that if the image is likely to be a shape or a + * clip mask, if we are here because we are actually synchronizing + * the drawable or if the drawable's corrupted region is over-age. */ if (NXAGENT_SHOULD_DEFER_PUTIMAGE(pDrawable)) @@ -676,8 +655,7 @@ FIXME: Should use these. #endif /* - * Check whether we need to enclose the - * image in a split sequence. + * Check whether we need to enclose the image in a split sequence. */ /* FIXME: Should we disable the split with link LAN? @@ -689,12 +667,11 @@ FIXME: Should we disable the split with link LAN? split = (nxagentOption(Streaming) == 1 && nxagentOption(LinkType) != LINK_TYPE_NONE /* -FIXME: Do we stream the images from GLX or Xv? If we do that, - we should also write on the frame buffer, including the - images put on windows, to be able to reconstruct the - region that is out of sync. Surely we should not try to - cache the GLX and Xv images in memory or save them in - the image cache on disk. +FIXME: Do we stream the images from GLX or Xv? If we do that, we + should also write on the frame buffer, including the images put + on windows, to be able to reconstruct the region that is out of + sync. Surely we should not try to cache the GLX and Xv images + in memory or save them in the image cache on disk. */ /* FIXME: Temporarily stream the GLX data. @@ -705,8 +682,7 @@ FIXME: Temporarily stream the GLX data. ); /* - * Never split images whose depth - * is less than 15. + * Never split images whose depth is less than 15. */ if (split == 1 && (nxagentSplitTrap == 1 || depth < 15)) @@ -750,9 +726,8 @@ FIXME: Temporarily stream the GLX data. #endif /* - * If the image was originated by a GLX - * or Xvideo request, temporarily disable - * the use of the cache. + * If the image was originated by a GLX or Xvideo request, + * temporarily disable the use of the cache. */ if (nxagentOption(LinkType) != LINK_TYPE_NONE && @@ -768,17 +743,15 @@ FIXME: Temporarily stream the GLX data. } /* - * Enclose the next messages in a split - * sequence. The proxy will tell us if - * the split took place. + * Enclose the next messages in a split sequence. The proxy will + * tell us if the split took place. */ if (split == 1) { /* - * If the drawable is already being split, - * expand the region. Currently drawables - * can't have more than a single split + * If the drawable is already being split, expand the + * region. Currently drawables can't have more than a single split * region. */ @@ -789,9 +762,8 @@ FIXME: Temporarily stream the GLX data. (void *) pDrawable); #endif /* -FIXME: Should probably intersect the region with - the region being split to also invalidate - the commits. +FIXME: Should probably intersect the region with the region being + split to also invalidate the commits. */ nxagentMarkCorruptedRegion(pDrawable, pRegion); @@ -800,9 +772,8 @@ FIXME: Should probably intersect the region with else { /* - * Assign a new resource to the drawable. - * Will also assign the GC to use for the - * operation. + * Assign a new resource to the drawable. Will also assign the + * GC to use for the operation. */ resource = nxagentCreateSplit(pDrawable, &pGC); @@ -824,12 +795,11 @@ FIXME: Should probably intersect the region with NXEndSplit(nxagentDisplay, resource); /* - * Now we need to check if all the messages went - * straight through the output stream or any of - * them required a split. If no split will take - * place, we will remove the association with the - * drawable and release the resource at the time - * we will handle the no-split event. + * Now we need to check if all the messages went straight through + * the output stream or any of them required a split. If no split + * will take place, we will remove the association with the + * drawable and release the resource at the time we will handle + * the no-split event. */ split = nxagentWaitSplitEvent(resource); @@ -843,10 +813,9 @@ FIXME: Should probably intersect the region with #endif /* - * Marking the corrupted region we will check - * if the region intersects the split region, - * therefore the split region must be added - * later. + * Marking the corrupted region we will check if the region + * intersects the split region, therefore the split region must + * be added later. */ nxagentMarkCorruptedRegion(pDrawable, pRegion); @@ -872,9 +841,8 @@ FIXME: Should probably intersect the region with if (nxagentDrawableStatus(pDrawable) == NotSynchronized) { /* - * We just covered the drawable with - * a solid image. We can consider the - * overlapping region as synchronized. + * We just covered the drawable with a solid image. We can + * consider the overlapping region as synchronized. */ #ifdef TEST @@ -919,8 +887,8 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int totalHeight; /* - * NXPutPackedImage is longer than PutPackedImage - * so that we subtract the bigger one to be sure. + * NXPutPackedImage is longer than PutPackedImage so that we + * subtract the bigger one to be sure. */ const int subSize = (MAX_REQUEST_SIZE << 2) - sizeof(xNXPutPackedImageReq); @@ -1085,13 +1053,13 @@ void nxagentPutSubImage(DrawablePtr pDrawable, GCPtr pGC, int depth, /* * XCreateImage is the place where the leftPad should be passed. - * The image data is received from our client unmodified. In - * theory what we would need to do is just creating an appropri- - * ate XImage structure based on the incoming data and let Xlib - * do the rest. Probably we don't have to pass leftPad again in - * the src_x of XPutImage otherwise the src_x would make Xlib - * to take into account the xoffset field twice. Unfortunately - * passing the leftPad doesn't work. + * The image data is received from our client unmodified. In theory + * what we would need to do is just creating an appropriate XImage + * structure based on the incoming data and let Xlib do the + * rest. Probably we don't have to pass leftPad again in the src_x + * of XPutImage otherwise the src_x would make Xlib to take into + * account the xoffset field twice. Unfortunately passing the + * leftPad doesn't work. * * plainImage = XCreateImage(nxagentDisplay, pVisual, * depth, format, leftPad, data, @@ -1145,10 +1113,9 @@ FIXME: Should use an unpack resource here. #endif /* - * We got the image data from the X client or - * from the frame-buffer with our own endianness. - * Byte swap the image data if the display has - * a different endianness than our own. + * We got the image data from the X client or from the frame-buffer + * with our own endianness. Byte swap the image data if the display + * has a different endianness than our own. */ if (nxagentImageNormalize(plainImage) != 0) @@ -1165,10 +1132,9 @@ FIXME: Should use an unpack resource here. #endif /* - * Check if the user requested to pack the - * image but don't pack it if we are not - * connected to a proxy or if the depth is - * less than 15 bpp. + * Check if the user requested to pack the image but don't pack it + * if we are not connected to a proxy or if the depth is less than + * 15 bpp. */ pack = (nxagentOption(LinkType) != LINK_TYPE_NONE && @@ -1179,9 +1145,8 @@ FIXME: Should use an unpack resource here. if (pack == 1 && lossless == 0) { /* - * Force the image to be sent as a plain - * bitmap if we don't have any lossless - * encoder available. + * Force the image to be sent as a plain bitmap if we don't have + * any lossless encoder available. */ if (w <= IMAGE_PACK_WIDTH || h <= IMAGE_PACK_HEIGHT || @@ -1220,8 +1185,8 @@ FIXME: Should use an unpack resource here. if (pack == 1) { /* - * Set the geometry and alpha channel - * to be used for the unpacked image. + * Set the geometry and alpha channel to be used for the unpacked + * image. */ if (nxagentUnpackVisualId[client -> index] != pVisual -> visualid) @@ -1237,9 +1202,8 @@ FIXME: Should use an unpack resource here. } /* - * Check if the image is supposed to carry - * the alpha data in the fourth byte and, - * if so, send the alpha channel using the + * Check if the image is supposed to carry the alpha data in the + * fourth byte and, if so, send the alpha channel using the * specific encoding. */ @@ -1249,46 +1213,43 @@ FIXME: Should use an unpack resource here. } /* - * If the image doesn't come from the XVideo or the - * GLX extension try to locate it in the cache. The - * case of the lossless trap is also special, as we - * want to eventually encode the image again using - * a lossless compression. + * If the image doesn't come from the XVideo or the GLX extension + * try to locate it in the cache. The case of the lossless trap is + * also special, as we want to eventually encode the image again + * using a lossless compression. */ /* -FIXME: Should try to locate the image anyway, if the lossless - trap is set, and if the image was encoded by a lossy - compressor, roll back the changes and encode the image - again using the preferred method. +FIXME: Should try to locate the image anyway, if the lossless trap is + set, and if the image was encoded by a lossy compressor, roll + back the changes and encode the image again using the preferred + method. */ if (nxagentNeedCache(plainImage, packMethod) && nxagentGlxTrap == 0 && nxagentXvTrap == 0 && nxagentLosslessTrap == 0 && NXImageCacheSize > 0) { /* - * Be sure that the padding bits are - * cleaned before calculating the MD5 - * checksum. + * Be sure that the padding bits are cleaned before calculating + * the MD5 checksum. */ /* FIXME: There should be a callback registered by the agent that - provides a statistics report, in text format, telling - for example how many images were searched in the cache, - how many were found, how many drawables are to be synch- - ronized, etc. This statistics report would be included - by the proxy in its stat output. + provides a statistics report, in text format, telling for + example how many images were searched in the cache, how many + were found, how many drawables are to be synchronized, + etc. This statistics report would be included by the proxy in + its stat output. */ clean = 1; NXCleanImage(plainImage); /* - * Will return a pointer to the image and checksum - * taken from the cache, if found. If the image is - * not found, the function returns a null image and - * a pointer to the calculated checksum. It is up - * to the application to free the memory. We will - * use the checksum to add the image in the cache. + * Will return a pointer to the image and checksum taken from + * the cache, if found. If the image is not found, the function + * returns a null image and a pointer to the calculated + * checksum. It is up to the application to free the memory. We + * will use the checksum to add the image in the cache. */ packedImage = NXCacheFindImage(plainImage, &packMethod, &packedChecksum); @@ -1325,9 +1286,8 @@ FIXME: There should be a callback registered by the agent that } /* - * If a specific encoder was not mandated, - * try to guess if a lossless encoder will - * compress better. + * If a specific encoder was not mandated, try to guess if a + * lossless encoder will compress better. */ if (lossless == 0 && nxagentOption(Adaptive) == 1) @@ -1355,8 +1315,7 @@ FIXME: There should be a callback registered by the agent that } /* - * Encode the image using the selected - * pack method. + * Encode the image using the selected pack method. */ if (packMethod == PACK_RLE_16M_COLORS || @@ -1364,13 +1323,11 @@ FIXME: There should be a callback registered by the agent that packMethod == PACK_BITMAP_16M_COLORS) { /* - * Cleanup the image if we didn't do that yet. - * We assume that the JPEG and PNG compression - * methods will actually ignore the padding - * bytes. In other words, bitmap images prod- - * ucing the same visual output should produce - * compressed images that are bitwise the same - * regardless the padding bits. + * Cleanup the image if we didn't do that yet. We assume that + * the JPEG and PNG compression methods will actually ignore the + * padding bytes. In other words, bitmap images producing the + * same visual output should produce compressed images that are + * bitwise the same regardless the padding bits. */ if (clean == 0) @@ -1386,12 +1343,10 @@ FIXME: There should be a callback registered by the agent that switch (packMethod) { /* - * If nothing is done by the bitmap encoder, - * it saves an allocation and a memory copy - * by setting the data field of the packed - * image to the original data. We need to - * check this at the time we will free the - * packed image. + * If nothing is done by the bitmap encoder, it saves an + * allocation and a memory copy by setting the data field of + * the packed image to the original data. We need to check + * this at the time we will free the packed image. */ case PACK_BITMAP_16M_COLORS: @@ -1433,8 +1388,8 @@ FIXME: There should be a callback registered by the agent that } /* - * If we didn't produce a valid packed - * image, send the image as a X bitmap. + * If we didn't produce a valid packed image, send the image as a X + * bitmap. */ if (packedImage != NULL) @@ -1453,10 +1408,8 @@ FIXME: There should be a callback registered by the agent that 0, 0, x, y, w, h); /* - * Add the image only if we have a valid - * checksum. This is the case only if we - * originally tried to find the image in - * cache. + * Add the image only if we have a valid checksum. This is the + * case only if we originally tried to find the image in cache. */ if (NXImageCacheSize > 0 && packedChecksum != NULL) @@ -1467,9 +1420,8 @@ FIXME: There should be a callback registered by the agent that #endif /* - * Check if both the plain and the packed - * image point to the same data. In this - * case we need a copy. + * Check if both the plain and the packed image point to the + * same data. In this case we need a copy. */ if (packedImage -> data == plainImage -> data && @@ -1490,19 +1442,17 @@ FIXME: There should be a callback registered by the agent that else { /* - * Clean the image to help the proxy to match - * the checksum in its cache. Do that only if - * the differential compression is enabled and - * if the image is not supposed to carry the - * alpha data in the fourth byte of the pixel. + * Clean the image to help the proxy to match the checksum in its + * cache. Do that only if the differential compression is enabled + * and if the image is not supposed to carry the alpha data in the + * fourth byte of the pixel. */ /* FIXME: If we failed to encode the image by any of the available - methods, for example if we couldn't allocate memory, we - may need to ripristinate the alpha channel, that in the - meanwhile was sent in the unpack alpha message. This can - be done here, if the clean flag is true and we are going - to send a plain image. + methods, for example if we couldn't allocate memory, we may + need to ripristinate the alpha channel, that in the meanwhile + was sent in the unpack alpha message. This can be done here, if + the clean flag is true and we are going to send a plain image. */ if (clean == 0) { @@ -1596,10 +1546,9 @@ void nxagentGetImage(DrawablePtr pDrawable, int x, int y, int w, int h, } /* - * We have to reset the visual cache before - * connecting to another display, so that a - * new unpack geometry can be communicated - * to the new proxy. + * We have to reset the visual cache before connecting to another + * display, so that a new unpack geometry can be communicated to the + * new proxy. */ void nxagentResetVisualCache(void) -- cgit v1.2.3 From 19ba07472fa7833d072b78c39200876517c5194f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 23 Oct 2019 00:18:27 +0200 Subject: Handlers.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Handlers.c | 187 +++++++++++--------------- 1 file changed, 76 insertions(+), 111 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c index 7311889b7..2c0ee731a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c @@ -57,47 +57,42 @@ #undef DUMP /* - * Log begin and end of the important - * handlers. + * Log begin and end of the important handlers. */ #undef BLOCKS /* - * If not defined, flush immediately - * upon entering the block handler. + * If not defined, flush immediately upon entering the block handler. */ #define FLUSH_AFTER_MULTIPLE_READS /* - * The soft limit should roughly match - * the size of the Xlib I/O buffer. + * The soft limit should roughly match the size of the Xlib I/O + * buffer. */ #define BYTES_BEFORE_SOFT_TOKEN 2048 #define BYTES_BEFORE_HARD_TOKEN 65536 /* - * Maximum number of synchronization - * requests before waiting for the + * Maximum number of synchronization requests before waiting for the * remote. */ #define TOKENS_PENDING_LIMIT 8 /* - * Limits are very unobtrusive. We don't - * want to interfere with the normal - * dispatching. + * Limits are very unobtrusive. We don't want to interfere with the + * normal dispatching. */ #define BYTES_BEFORE_YIELD 1048576 #define TIME_BEFORE_YIELD 500 /* - * Dynamically reduce the display buffer - * size after a congestion. + * Dynamically reduce the display buffer size after a congestion. */ #undef DYNAMIC_DISPLAY_BUFFER @@ -116,16 +111,14 @@ extern void nxagentDumpInputDevicesState(void); #endif /* - * Used in the handling of the X desktop - * manager protocol. + * Used in the handling of the X desktop manager protocol. */ int nxagentXdmcpUp = 0; int nxagentXdmcpAlertUp = 0; /* - * Also used in the block, wakeup and - * sync handlers. + * Also used in the block, wakeup and sync handlers. */ int nxagentBuffer; @@ -136,30 +129,28 @@ double nxagentBytesIn; double nxagentBytesOut; /* - * Total number of descriptors ready - * as reported by the wakeup handler. + * Total number of descriptors ready as reported by the wakeup + * handler. */ int nxagentReady; /* - * Timestamp of the last write to the - * remote display. + * Timestamp of the last write to the remote display. */ int nxagentFlush; /* - * Arbitrate the bandwidth among our - * clients. + * Arbitrate the bandwidth among our clients. */ struct _TokensRec nxagentTokens = { 0, 0, 0 }; struct _DispatchRec nxagentDispatch = { UNDEFINED, 0, 0, 0 }; /* - * Called just before blocking, waiting - * for our clients or the X server. + * Called just before blocking, waiting for our clients or the X + * server. */ extern int nxagentSkipImage; @@ -179,15 +170,13 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) static int now; /* - * Pending bytes to write to the - * network. + * Pending bytes to write to the network. */ static int flushable; /* - * Set if we need to synchronize - * any drawable. + * Set if we need to synchronize any drawable. */ static int synchronize; @@ -242,8 +231,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #endif /* - * Slow down the agent if the session is - * not connected to a valid display. + * Slow down the agent if the session is not connected to a valid + * display. */ if (NXDisplayError(nxagentDisplay) == 1 && nxagentShadowCounter == 0 && nxagentOption(SleepTime) > 0) @@ -263,8 +252,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #endif /* - * Update the shadow display. This is - * only for test purposes. + * Update the shadow display. This is only for test purposes. */ #ifdef DUMP @@ -276,17 +264,14 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #endif /* - * We need this here because some window - * configuration changes can be generated - * by the X server outside the control of - * the DIX. + * We need this here because some window configuration changes can + * be generated by the X server outside the control of the DIX. */ nxagentFlushConfigureWindow(); /* - * Check whether there is any drawable to - * synchronize. + * Check whether there is any drawable to synchronize. */ #ifdef TEST @@ -300,8 +285,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) nxagentCorruptedPixmaps > 0); /* - * The synchronization function requires a mask as - * parameter: + * The synchronization function requires a mask as parameter: * * EVENT_BREAK Breaks if an user input, like * a key press or a mouse move, @@ -324,9 +308,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) if (synchronize == 1) { /* - * We should not enter the synchronization - * loop if there is any user input pending, - * i.e. if we are in the middle of a scroll + * We should not enter the synchronization loop if there is any + * user input pending, i.e. if we are in the middle of a scroll * operation. */ @@ -361,9 +344,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #endif /* - * Check if we have more corrupted resources - * and whether the conditions are satisfied - * to continue with the synchronization. + * Check if we have more corrupted resources and whether the + * conditions are satisfied to continue with the synchronization. */ synchronize = (nxagentCongestion <= 4 && @@ -405,9 +387,9 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) } /* - * If the remote X server is blocking, reduce the - * amount of data sent in a single display update - * by reducing the size of the display buffer. + * If the remote X server is blocking, reduce the amount of data + * sent in a single display update by reducing the size of the + * display buffer. */ #ifdef DYNAMIC_DISPLAY_BUFFER @@ -445,8 +427,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #endif /* #ifdef DYNAMIC_DISPLAY_BUFFER */ /* - * Dispatch to the clients the events that - * may have become available. + * Dispatch to the clients the events that may have become + * available. */ if (nxagentPendingEvents(nxagentDisplay) > 0) @@ -459,9 +441,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) } /* - * Check if there is any data remaining, - * either in the display buffer or in - * the NX transport. + * Check if there is any data remaining, either in the display + * buffer or in the NX transport. */ flushable = NXDisplayFlushable(nxagentDisplay); @@ -471,9 +452,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #ifdef FLUSH_AFTER_MULTIPLE_READS /* - * Flush all the outstanding data if - * the wakeup handler didn't detect - * any activity. + * Flush all the outstanding data if the wakeup handler didn't + * detect any activity. */ if (nxagentReady == 0 || now - nxagentFlush >= @@ -487,8 +467,7 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) NXFlushDisplay(nxagentDisplay, NXFlushLink); /* - * New events may have become available - * after the flush. + * New events may have become available after the flush. */ if (nxagentPendingEvents(nxagentDisplay) > 0) @@ -516,9 +495,8 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) #else /* #ifdef FLUSH_AFTER_MULTIPLE_READS */ /* - * We are entering the select. Tell the NX - * transport to write any produced data to - * the remote end. + * We are entering the select. Tell the NX transport to write any + * produced data to the remote end. */ NXFlushDisplay(nxagentDisplay, NXFlushLink); @@ -556,12 +534,11 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) } /* - * WaitForSomething() sets a zero timeout if there - * are clients with input, but doesn't stop the - * timer. The select is then interrupted to update - * the schedule time even if, what the dispatcher - * cares, is only the number of ticks at the time - * the client is scheduled in. + * WaitForSomething() sets a zero timeout if there are clients with + * input, but doesn't stop the timer. The select is then interrupted + * to update the schedule time even if, what the dispatcher cares, + * is only the number of ticks at the time the client is scheduled + * in. */ #ifdef DEBUG @@ -641,8 +618,7 @@ void nxagentWakeupHandler(void * data, int count, void * mask) else if (nxagentQueuedEvents(nxagentDisplay) == 1) { /* - * We may have left some events in - * the queue. + * We may have left some events in the queue. */ #ifdef TEST @@ -674,9 +650,8 @@ void nxagentWakeupHandler(void * data, int count, void * mask) #endif /* - * If the XDM connection can't be established - * we'll need to create a dialog to notify the - * user and give him/her a chance to terminate + * If the XDM connection can't be established we'll need to create a + * dialog to notify the user and give him/her a chance to terminate * the session. */ @@ -813,14 +788,12 @@ void nxagentShadowBlockHandler(void * data, struct timeval **timeout, void * mas } /* - * We are entering the select. Tell the NX - * transport to write any produced data to - * the remote end. + * We are entering the select. Tell the NX transport to write any + * produced data to the remote end. */ /* -FIXME: Must queue multiple writes and handle - the events by resembling the ordinary - block handler. +FIXME: Must queue multiple writes and handle the events by resembling + the ordinary block handler. */ NXFlushDisplay(nxagentDisplay, NXFlushLink); @@ -929,8 +902,7 @@ void nxagentShadowWakeupHandler(void * data, int count, void * mask) else if (nxagentQueuedEvents(nxagentDisplay) == 1) { /* - * We may have left some events in - * the queue. + * We may have left some events in the queue. */ #ifdef TEST @@ -1022,13 +994,11 @@ Bool nxagentCollectInputFocusPredicate(Display *display, XEvent *X, XPointer ptr void nxagentDispatchHandler(ClientPtr client, int in, int out) { /* - * This function is called by the dispatcher (with 0 - * bytes out) after a new request has been processed. - * It is also called by the write handler (with 0 - * bytes in) after more data has been written to the - * display. It may be optionally called in the block - * and wakeup handlers. In this case both in and out - * must be 0. + * This function is called by the dispatcher (with 0 bytes out) + * after a new request has been processed. It is also called by the + * write handler (with 0 bytes in) after more data has been written + * to the display. It may be optionally called in the block and + * wakeup handlers. In this case both in and out must be 0. */ if (out > 0) @@ -1050,14 +1020,12 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) #endif /* - * Don't take care of the synchronization if - * the NX transport is running. The NX trans- - * port has its own token-based control flow. + * Don't take care of the synchronization if the NX transport is + * running. The NX transport has its own token-based control flow. * - * We can't produce more output here because - * we are in the middle of the flush. We will - * take care of the sync requests when called - * by the dispatcher. + * We can't produce more output here because we are in the middle + * of the flush. We will take care of the sync requests when + * called by the dispatcher. */ if (nxagentOption(LinkType) == LINK_TYPE_NONE) @@ -1079,8 +1047,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) { /* - * Pay attention to the next client if this - * client produced enough output. + * Pay attention to the next client if this client produced + * enough output. */ if (nxagentBytesOut - nxagentDispatch.out > BYTES_BEFORE_YIELD) @@ -1142,12 +1110,11 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) #endif /* - * When using the dumb scheduler, before reading from - * another client, the dispatcher tries to drain all - * the input from the client being processed. This - * means that, if isItTimeToYield is never set and the - * client never produces any output, we'll stick into - * the inner dispatch loop forever. + * When using the dumb scheduler, before reading from another + * client, the dispatcher tries to drain all the input from the + * client being processed. This means that, if isItTimeToYield is + * never set and the client never produces any output, we'll stick + * into the inner dispatch loop forever. */ if (!SmartScheduleSignalEnable) @@ -1228,10 +1195,9 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) else if (nxagentTokens.soft > BYTES_BEFORE_SOFT_TOKEN) { /* - * Alternatively, the amounts of bytes - * accounted for each sync request may - * be decreased according to the number - * of pending replies already awaited. + * Alternatively, the amounts of bytes accounted for each sync + * request may be decreased according to the number of pending + * replies already awaited. * * else if (nxagentTokens.soft > (BYTES_BEFORE_SOFT_TOKEN / (nxagentTokens.pending + 1))) */ @@ -1239,9 +1205,8 @@ void nxagentDispatchHandler(ClientPtr client, int in, int out) int resource; /* - * Wait eventually for the number of - * synchronization requests to return - * below the limit. + * Wait eventually for the number of synchronization requests to + * return below the limit. */ #ifdef TEST -- cgit v1.2.3 From 8b796ee54b2b750c81d987637e9fb2ef2f871c76 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 23 Oct 2019 00:19:09 +0200 Subject: Binder.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Binder.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Binder.c b/nx-X11/programs/Xserver/hw/nxagent/Binder.c index 247fb9d77..518c016c4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Binder.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Binder.c @@ -49,8 +49,7 @@ int nxagentCheckBinder(int argc, char *argv[], int i) char *display = argv[i]; /* - * Check if a display specification follows - * the -B switch. + * Check if a display specification follows the -B switch. */ char *found = rindex(display, ':'); @@ -73,8 +72,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i) /* * The NX options must be specified in the DISPLAY - * environment. Check if the display specified on - * the command line matches the NX virtual display. + * environment. Check if the display specified on the command line + * matches the NX virtual display. */ display = getenv("DISPLAY"); @@ -103,8 +102,8 @@ int nxagentCheckBinder(int argc, char *argv[], int i) #endif /* - * Save the proxy options. They will be later - * used to create the transport. + * Save the proxy options. They will be later used to create the + * transport. */ nxagentChangeOption(Rootless, False); @@ -112,10 +111,9 @@ int nxagentCheckBinder(int argc, char *argv[], int i) nxagentChangeOption(Binder, True); /* - * FIXME: This now points to the buffer that was - * returned by getenv(). It is to be decided how - * to handle the values of type string in the - * Options repository. + * FIXME: This now points to the buffer that was returned by + * getenv(). It is to be decided how to handle the values of type + * string in the Options repository. */ nxagentChangeOption(BinderOptions, display); -- cgit v1.2.3 From 1bd78de58aff68b6ad7758efdad2a73f731f0072 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 28 Oct 2019 22:31:10 +0100 Subject: NXmitrap.c: mark NX changes --- nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c index 1988ca102..08666a3f8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmitrap.c @@ -80,6 +80,7 @@ miTrapezoids (CARD8 op, xDst = traps[0].left.p1.x >> 16; yDst = traps[0].left.p1.y >> 16; +#ifdef NXAGENT_SERVER if (nxagentTrapezoidExtents != NullBox) { memcpy(&bounds, nxagentTrapezoidExtents, sizeof(BoxRec)); @@ -92,7 +93,9 @@ miTrapezoids (CARD8 op, memcpy(nxagentTrapezoidExtents, &bounds, sizeof(BoxRec)); } - +#else + miTrapezoidBounds (ntrap, traps, &bounds); +#endif if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) return; pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, -- cgit v1.2.3 From f48e2da3e86b2d7600de3d5d4ef6f81ba2c17bed Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 26 May 2019 11:58:01 +0200 Subject: miwindow.c: mark NX changes --- nx-X11/programs/Xserver/mi/miwindow.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c index c696caf26..4e67987d6 100644 --- a/nx-X11/programs/Xserver/mi/miwindow.c +++ b/nx-X11/programs/Xserver/mi/miwindow.c @@ -1037,6 +1037,7 @@ miSetShape(pWin) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); +#ifdef NXAGENT_SERVER /* * Applies to NXAGENT_SERVER builds: * @@ -1056,6 +1057,9 @@ miSetShape(pWin) */ if (WasViewable && pOldClip) +#else + if (WasViewable) +#endif RegionDestroy(pOldClip); if (bsExposed) { -- cgit v1.2.3 From 36f679fb38765a2e3982b089d1f7cb080cbbe78c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 22:49:08 +0200 Subject: Events.c: reformat comments save some lines --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 257 ++++++++++++---------------- 1 file changed, 109 insertions(+), 148 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index cbdf17a22..af6f17cc3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -105,9 +105,8 @@ #include "compext/Compext.h" /* - * Set here the required log level. Please note - * that if you want to enable DEBUG here, then - * you need to enable DEBUG even in Rootless.c + * Set here the required log level. Please note that if you want to + * enable DEBUG here, then you need to enable DEBUG even in Rootless.c */ #define PANIC @@ -163,8 +162,7 @@ PropertyRequestRec nxagentPropertyRequests[NXNumberOfResources]; void nxagentHandleCollectPropertyEvent(XEvent*); /* - * Finalize the asynchronous handling - * of the X_GrabPointer requests. + * Finalize the asynchronous handling of the X_GrabPointer requests. */ void nxagentHandleCollectGrabPointerEvent(int resource); @@ -172,8 +170,8 @@ void nxagentHandleCollectGrabPointerEvent(int resource); Bool nxagentCollectGrabPointerPredicate(Display *display, XEvent *X, XPointer ptr); /* - * Used in Handlers.c to synchronize - * the agent with the remote X server. + * Used in Handlers.c to synchronize the agent with the remote X + * server. */ void nxagentHandleCollectInputFocusEvent(int resource); @@ -193,12 +191,12 @@ static Cursor viewportCursor; #define nextinc(x) ((x) < MAX_INC ? (x) += INC_STEP : (x)) /* - * Keyboard and pointer are handled as they were real devices by - * Xnest and we inherit this behaviour. The following mask will - * contain the event mask selected for the root window of the - * agent. All the keyboard and pointer events will be translated - * by the agent and sent to the internal clients according to - * events selected by the inferior windows. + * Keyboard and pointer are handled as they were real devices by Xnest + * and we inherit this behaviour. The following mask will contain the + * event mask selected for the root window of the agent. All the + * keyboard and pointer events will be translated by the agent and + * sent to the internal clients according to events selected by the + * inferior windows. */ static Mask defaultEventMask; @@ -206,9 +204,8 @@ static Mask defaultEventMask; static int lastEventSerial = 0; /* - * Used to mask the appropriate bits in - * the state reported by XkbStateNotify - * and XkbGetIndicatorState. + * Used to mask the appropriate bits in the state reported by + * XkbStateNotify and XkbGetIndicatorState. */ #define CAPSFLAG_IN_REPLY 1 @@ -221,8 +218,8 @@ CARD32 nxagentLastKeyPressTime = 0; Time nxagentLastServerTime = 0; /* - * Used for storing windows that need to - * receive expose events from the agent. + * Used for storing windows that need to receive expose events from + * the agent. */ #define nxagentExposeQueueHead nxagentExposeQueue.exposures[nxagentExposeQueue.start] @@ -246,16 +243,14 @@ int GetWindowProperty(WindowPtr pWin, Atom property, long longOffset, unsigned char **propData); /* - * Associate a resource to a drawable and - * store the region affected by the split - * operation. + * Associate a resource to a drawable and store the region affected by + * the split operation. */ SplitResourceRec nxagentSplitResources[NXNumberOfResources]; /* - * Associate a resource to an unpack - * operation. + * Associate a resource to an unpack operation. */ UnpackResourceRec nxagentUnpackResources[NXNumberOfResources]; @@ -269,8 +264,7 @@ Bool nxagentLastWindowDestroyed = False; Time nxagentLastWindowDestroyedTime = 0; /* - * Set this flag when an user input event - * is received. + * Set this flag when an user input event is received. */ int nxagentInputEvent = 0; @@ -728,9 +722,8 @@ static void nxagentToggleAutoGrab(void) static Bool nxagentExposurePredicate(Display *display, XEvent *event, XPointer window) { /* - * Handle both Expose and ProcessedExpose events. - * The latters are those not filtered by function - * nxagentWindowExposures(). + * Handle both Expose and ProcessedExpose events. The latters are + * those not filtered by function nxagentWindowExposures(). */ if (window) @@ -876,13 +869,11 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) } /* - * We must read here, even if apparently there is - * nothing to read. The ioctl() based readable - * function, in fact, is often unable to detect a - * failure of the socket, in particular if the - * agent was connected to the proxy and the proxy - * is gone. Thus we must trust the wakeup handler - * that called us after the select(). + * We must read here, even if apparently there is nothing to + * read. The ioctl() based readable function, in fact, is often + * unable to detect a failure of the socket, in particular if the + * agent was connected to the proxy and the proxy is gone. Thus we + * must trust the wakeup handler that called us after the select(). */ #ifdef TEST @@ -895,11 +886,10 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) #endif /* - * We want to process all the events already in - * the queue, plus any additional event that may - * be read from the network. If no event can be - * read, we want to continue handling our clients - * without flushing the output buffer. + * We want to process all the events already in the queue, plus any + * additional event that may be read from the network. If no event + * can be read, we want to continue handling our clients without + * flushing the output buffer. */ while (nxagentCheckEvents(nxagentDisplay, &X, predicate != NULL ? predicate : @@ -1126,13 +1116,11 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) } /* - * Elide multiple KeyPress/KeyRelease events of - * the same key and generate a single pair. This - * is intended to reduce the impact of the laten- - * cy on the key auto-repeat, handled by the re- - * mote X server. We may optionally do that only - * if the timestamps in the events show an exces- - * sive delay. + * Elide multiple KeyPress/KeyRelease events of the same key + * and generate a single pair. This is intended to reduce the + * impact of the latency on the key auto-repeat, handled by + * the remote X server. We may optionally do that only if the + * timestamps in the events show an exces- sive delay. */ keysym = XKeycodeToKeysym(nxagentDisplay, X.xkey.keycode, 0); @@ -1157,18 +1145,17 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) int sendKey = 0; /* -FIXME: If we don't flush the queue here, it could happen - that the inputInfo structure will not be up to date - when we perform the following check on down keys. +FIXME: If we don't flush the queue here, it could happen that the + inputInfo structure will not be up to date when we perform the + following check on down keys. */ ProcessInputEvents(); /* -FIXME: Don't enqueue the KeyRelease event if the key was - not already pressed. This workaround avoids a fake - KeyPress being enqueued by the XKEYBOARD extension. - Another solution would be to let the events - enqueued and to remove the KeyPress afterwards. +FIXME: Don't enqueue the KeyRelease event if the key was not already + pressed. This workaround avoids a fake 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, nxagentConvertKeycode(X.xkey.keycode))) @@ -1206,9 +1193,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. */ + /* 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); @@ -1564,9 +1551,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was #endif /* - * Here we change the focus state in the agent. - * It looks like this is needed only for root- - * less mode at the present moment. + * Here we change the focus state in the agent. It looks like + * this is needed only for rootless mode at present. */ if (nxagentOption(Rootless) && @@ -1743,9 +1729,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was pWin -> drawable.y != X.xcrossing.y_root - X.xcrossing.y - pWin -> borderWidth)) { /* - * This code is useful for finding the window - * position. It should be re-implemented by - * following the ICCCM 4.1.5 recommendations. + * This code is useful for finding the window position. It + * should be re-implemented by following the ICCCM 4.1.5 + * recommendations. */ XID values[4]; @@ -2141,8 +2127,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was /* * without window manager there will be no ConfigureNotify - * event that would trigger xinerama updates. So we do that once - * the nxagent window gets mapped. + * event that would trigger xinerama updates. So we do that + * once the nxagent window gets mapped. */ if (!nxagentWMIsRunning && X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum]) @@ -2171,8 +2157,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was default: { /* - * Let's check if this is a XKB - * state modification event. + * Let's check if this is a XKB state modification event. */ if (nxagentHandleXkbKeyboardStateEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0) @@ -2280,8 +2265,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was #endif /* - * Let the underlying X server code - * process the input events. + * Let the underlying X server code process the input events. */ #ifdef BLOCKS @@ -2296,9 +2280,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was #endif /* - * Write the events to our clients. We may - * flush only in the case of critical output - * but this doesn't seem beneficial. + * Write the events to our clients. We may flush only in the case of + * critical output but this doesn't seem beneficial. * * if (CriticalOutputPending == 1) * { @@ -2330,8 +2313,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was } /* - * Functions providing the ad-hoc handling - * of the remote X events. + * Functions providing the ad-hoc handling of the remote X events. */ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) @@ -2558,9 +2540,9 @@ FIXME: This can be maybe optimized by consuming the int nxagentHandleGraphicsExposeEvent(XEvent *X) { /* - * Send an expose event to client, instead of graphics - * expose. If target drawable is a backing pixmap, send - * expose event for the saved window, else do nothing. + * Send an expose event to client, instead of graphics expose. If + * target drawable is a backing pixmap, send expose event for the + * saved window, else do nothing. */ RegionPtr exposeRegion; @@ -2609,8 +2591,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) } /* - * Rectangle affected by GraphicsExpose - * event. + * Rectangle affected by GraphicsExpose event. */ rect.x1 = X -> xgraphicsexpose.x; @@ -2628,19 +2609,17 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) #endif /* - * The exposeRegion coordinates are relative - * to the pixmap to which GraphicsExpose - * event refers. But the BS coordinates of - * the savedRegion are relative to the - * window. + * The exposeRegion coordinates are relative to the pixmap to + * which GraphicsExpose event refers. But the BS coordinates of + * the savedRegion are relative to the window. */ RegionTranslate(exposeRegion, pStoringPixmapRec -> backingStoreX, pStoringPixmapRec -> backingStoreY); /* - * We remove from SavedRegion the part - * affected by the GraphicsExpose event. + * We remove from SavedRegion the part affected by the + * GraphicsExpose event. */ RegionSubtract(&(pBSwindow -> SavedRegion), &(pBSwindow -> SavedRegion), @@ -2648,9 +2627,8 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) } /* - * Store the exposeRegion in order to send - * the expose event later. The coordinates - * must be relative to the screen. + * Store the exposeRegion in order to send the expose event + * later. The coordinates must be relative to the screen. */ RegionTranslate(exposeRegion, pWin -> drawable.x, pWin -> drawable.y); @@ -2673,8 +2651,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) #endif /* - * If window is 0, message_type is 0 and format is - * 32 then we assume event is coming from proxy. + * If window is 0, message_type is 0 and format is 32 then we assume + * event is coming from proxy. */ if (X -> xclient.window == 0 && @@ -3007,10 +2985,8 @@ int nxagentHandleProxyEvent(XEvent *X) case NXStartSplitNotify: { /* - * We should never receive such events - * in the event loop, as they should - * be caught at the time the split is - * initiated. + * We should never receive such events in the event loop, as + * they should be caught at the time the split is initiated. */ #ifdef PANIC @@ -3035,10 +3011,9 @@ int nxagentHandleProxyEvent(XEvent *X) case NXCommitSplitNotify: { /* - * We need to commit an image. Image can be the - * result of a PutSubImage() generated by Xlib, - * so there can be more than a single image to - * commit, even if only one PutImage was perfor- + * We need to commit an image. Image can be the result of a + * PutSubImage() generated by Xlib, so there can be more than a + * single image to commit, even if only one PutImage was perfor- * med by the agent. */ @@ -3059,8 +3034,8 @@ int nxagentHandleProxyEvent(XEvent *X) case NXEndSplitNotify: { /* - * All images for the split were transferred and - * we need to restart the client. + * All images for the split were transferred and we need to + * restart the client. */ int client = (int) X -> xclient.data.l[1]; @@ -3148,9 +3123,8 @@ int nxagentHandleProxyEvent(XEvent *X) } /* - * In this function it is assumed that we never - * get a configure with both stacking order and - * geometry changed, this way we can ignore + * In this function it is assumed that we never get a configure with + * both stacking order and geometry changed, this way we can ignore * stacking changes if the geometry has changed. */ @@ -3317,9 +3291,8 @@ int nxagentHandleConfigureNotify(XEvent* X) nxagentCheckWindowConfiguration((XConfigureEvent*)X); /* - * This workaround should help with - * Java 1.6.0 that seems to ignore - * non-synthetic events. + * This workaround should help with Java 1.6.0 that seems to + * ignore non-synthetic events. */ if (nxagentOption(ClientOs) == ClientOsWinnt) @@ -3367,15 +3340,14 @@ int nxagentHandleConfigureNotify(XEvent* X) else { /* - * Save the position of the agent default window. Don't - * save the values if the agent is in fullscreen mode. + * Save the position of the agent default window. Don't save the + * values if the agent is in fullscreen mode. * - * If we use these values to restore the position of a - * window after that we have dynamically changed the - * fullscreen attribute, depending on the behaviour of - * window manager, we could be not able to place the - * window exactly in the requested position, so let the - * window manager do the job for us. + * If we use these values to restore the position of a window + * after that we have dynamically changed the fullscreen + * attribute, depending on the behaviour of window manager, we + * could be not able to place the window exactly in the requested + * position, so let the window manager do the job for us. */ ScreenPtr pScreen = nxagentScreen(X -> xconfigure.window); @@ -3584,9 +3556,8 @@ int nxagentHandleReparentNotify(XEvent* X) if (nxagentWindowTopLevel(pWin)) { /* - * If the window manager reparents our top level - * window, we need to know the new top level - * ancestor. + * If the window manager reparents our top level window, we need + * to know the new top level ancestor. */ w = None; @@ -3919,10 +3890,9 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) #endif /* - * The smart scheduler could be stopped while - * waiting for the reply. In this case we need - * to yield explicitly to avoid to be stuck in - * the dispatch loop forever. + * The smart scheduler could be stopped while waiting for the + * reply. In this case we need to yield explicitly to avoid to be + * stuck in the dispatch loop forever. */ isItTimeToYield = 1; @@ -4355,9 +4325,8 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) #endif /* - * The miWindowExposures() clears out the - * region parameters, so the subtract ope- - * ration must be done before calling it. + * The miWindowExposures() clears out the region parameters, so + * the subtract ope- ration must be done before calling it. */ RegionSubtract(remoteExposeRgn, remoteExposeRgn, exposeRgn); @@ -4391,13 +4360,10 @@ int nxagentUserInput(void *p) int result = 0; /* - * This function is used as callback in - * the polling handler of agent in shadow - * mode. When inside the polling loop the - * handlers are never called, so we have - * to dispatch enqueued events to eventu- - * ally change the nxagentInputEvent sta- - * tus. + * This function is used as callback in the polling handler of agent + * in shadow mode. When inside the polling loop the handlers are + * never called, so we have to dispatch enqueued events to + * eventually change the nxagentInputEvent status. */ if (nxagentOption(Shadow) == 1 && @@ -4414,11 +4380,9 @@ int nxagentUserInput(void *p) } /* - * The agent working in shadow mode synch- - * ronizes the remote X server even if a - * button/key is not released (i.e. when - * scrolling a long browser's page), in - * order to update the screen smoothly. + * The agent working in shadow mode synchronizes the remote X server + * even if a button/key is not released (i.e. when scrolling a long + * browser's page), in order to update the screen smoothly. */ if (nxagentOption(Shadow) == 1) @@ -4429,9 +4393,8 @@ int nxagentUserInput(void *p) if (result == 0) { /* - * If there is at least one button/key down, - * we are receiving an input. This is not a - * condition to break a synchronization loop + * If there is at least one button/key down, we are receiving an + * input. This is not a condition to break a synchronization loop * if there is enough bandwidth. */ @@ -4471,13 +4434,11 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) } /* - * Returns true if there is any event waiting to - * be dispatched. This function is critical for - * the performance because it is called very, - * very often. It must also handle the case when - * the display is down. The display descriptor, - * in fact, may have been reused by some other - * client. + * Returns true if there is any event waiting to be dispatched. This + * function is critical for the performance because it is called very, + * very often. It must also handle the case when the display is + * down. The display descriptor, in fact, may have been reused by some + * other client. */ int nxagentPendingEvents(Display *dpy) -- cgit v1.2.3 From ad89c7055cd79a1b6bfc9424f55362a7cd3d4409 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 22:51:42 +0200 Subject: Events.c: reformat switch blocks save some lines --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 81 ++++++----------------------- 1 file changed, 17 insertions(+), 64 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index af6f17cc3..cdbe3c1c6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -300,26 +300,10 @@ char * nxagentGetNotifyMode(int mode) { switch (mode) { - case NotifyNormal: - { - return "NotifyNormal"; - break; - } - case NotifyGrab: - { - return "NotifyGrab"; - break; - } - case NotifyUngrab: - { - return "NotifyUngrab"; - break; - } - case NotifyWhileGrabbed: - { - return "NotifyWhileGrabbed"; - break; - } + case NotifyNormal: return "NotifyNormal"; + case NotifyGrab: return "NotifyGrab"; + case NotifyUngrab: return "NotifyUngrab"; + case NotifyWhileGrabbed: return "NotifyWhileGrabbed"; } return "Unknown"; } @@ -1013,67 +997,56 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case doMinimize: { minimize = TRUE; - break; } case doSwitchFullscreen: { switchFullscreen = TRUE; - break; } case doSwitchAllScreens: { switchAllScreens = TRUE; - break; } case doViewportMoveUp: { nxagentMoveViewport(pScreen, 0, -nxagentOption(Height)); - break; } case doViewportMoveDown: { nxagentMoveViewport(pScreen, 0, nxagentOption(Height)); - break; } case doViewportMoveLeft: { nxagentMoveViewport(pScreen, -nxagentOption(Width), 0); - break; } case doViewportMoveRight: { nxagentMoveViewport(pScreen, nxagentOption(Width), 0); - break; } case doViewportUp: { nxagentMoveViewport(pScreen, 0, -nextinc(viewportInc)); - break; } case doViewportDown: { nxagentMoveViewport(pScreen, 0, +nextinc(viewportInc)); - break; } case doViewportLeft: { nxagentMoveViewport(pScreen, -nextinc(viewportInc), 0); - break; } case doViewportRight: { nxagentMoveViewport(pScreen, +nextinc(viewportInc), 0); - break; } case doSwitchResizeMode: @@ -1098,19 +1071,16 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) { nxagentSwitchDeferMode(); } - break; } case doAutoGrab: { nxagentToggleAutoGrab(); - break; } default: { FatalError("nxagentDispatchEvent: handleKeyPress returned unknown value\n"); - break; } } @@ -2942,18 +2912,10 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) switch (xfixesEvent -> xfixesselection.subtype) { - case SelectionSetOwner: - fprintf(stderr, "SelectionSetOwner.\n"); - break; - case SelectionWindowDestroy: - fprintf(stderr, "SelectionWindowDestroy.\n"); - break; - case SelectionClientClose: - fprintf(stderr, "SelectionClientClose.\n"); - break; - default: - fprintf(stderr, ".\n"); - break; + case SelectionSetOwner: fprintf(stderr, "SelectionSetOwner.\n"); break; + case SelectionWindowDestroy: fprintf(stderr, "SelectionWindowDestroy.\n"); break; + case SelectionClientClose: fprintf(stderr, "SelectionClientClose.\n"); break; + default: fprintf(stderr, ".\n"); break; } #endif @@ -4586,24 +4548,15 @@ static const char *nxagentGrabStateToString(int state) { switch (state) { - case 0: - return "NOT_GRABBED"; - case 1: - return "THAWED"; - case 2: - return "THAWED_BOTH"; - case 3: - return "FREEZE_NEXT_EVENT"; - case 4: - return "FREEZE_BOTH_NEXT_EVENT"; - case 5: - return "FROZEN_NO_EVENT"; - case 6: - return "FROZEN_WITH_EVENT"; - case 7: - return "THAW_OTHERS"; - default: - return "unknown state"; + case 0: return "NOT_GRABBED"; + case 1: return "THAWED"; + case 2: return "THAWED_BOTH"; + case 3: return "FREEZE_NEXT_EVENT"; + case 4: return "FREEZE_BOTH_NEXT_EVENT"; + case 5: return "FROZEN_NO_EVENT"; + case 6: return "FROZEN_WITH_EVENT"; + case 7: return "THAW_OTHERS"; + default: return "unknown state"; } } -- cgit v1.2.3 From 9358eaedc8b323d97dc45c944a29b92d5b327a23 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 22:56:12 +0200 Subject: Events.c: Scope improvements/code simplification --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 230 ++++++++++------------------ 1 file changed, 83 insertions(+), 147 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index cdbe3c1c6..11ea28f0f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -495,7 +495,6 @@ void nxagentRemoteWindowsTree(Window window, int level) void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) { - int result; unsigned long ulReturnItems; unsigned long ulReturnBytesLeft; Atom atomReturnType; @@ -505,11 +504,11 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) fprintf(stderr, "Window ID=[0x%x] %s Remote ID=[0x%x] ", pWin -> drawable.id, pWin->parent ? "" : "(the root window)", nxagentWindow(pWin)); - result = GetWindowProperty(pWin, MakeAtom("WM_NAME", 7, False) , 0, - sizeof(CARD32), False, AnyPropertyType, - &atomReturnType, &iReturnFormat, - &ulReturnItems, &ulReturnBytesLeft, - &pszReturnData); + int result = GetWindowProperty(pWin, MakeAtom("WM_NAME", 7, False) , 0, + sizeof(CARD32), False, AnyPropertyType, + &atomReturnType, &iReturnFormat, + &ulReturnItems, &ulReturnBytesLeft, + &pszReturnData); fprintf(stderr, "Name: "); @@ -942,8 +941,6 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) { enum HandleEventResult result; - KeySym keysym; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeyPress event.\n"); #endif @@ -1093,7 +1090,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) * timestamps in the events show an exces- sive delay. */ - keysym = XKeycodeToKeysym(nxagentDisplay, X.xkey.keycode, 0); + KeySym keysym = XKeycodeToKeysym(nxagentDisplay, X.xkey.keycode, 0); if (nxagentMonitoredDuplicate(keysym) == 1) { @@ -1664,14 +1661,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already { WindowPtr pWin; - WindowPtr pTLWin = NULL; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new EnterNotify event.\n"); #endif if (nxagentOption(Rootless)) { + WindowPtr pTLWin = NULL; + pWin = nxagentWindowPtr(X.xcrossing.window); if (pWin != NULL) @@ -1704,16 +1701,13 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already * recommendations. */ - XID values[4]; - register XID *value = values; - Mask mask = 0; - ClientPtr pClient = wClient(pWin); - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: pWin -> drawable.x [%d] pWin -> drawable.y [%d].\n", pWin -> drawable.x, pWin -> drawable.y); #endif + XID values[4]; + register XID *value = values; *value++ = (XID) (X.xcrossing.x_root - X.xcrossing.x - pWin -> borderWidth); *value++ = (XID) (X.xcrossing.y_root - X.xcrossing.y - pWin -> borderWidth); @@ -1722,11 +1716,11 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already * nxagentWindowPriv(pWin)->y = (X.xcrossing.y_root - X.xcrossing.y); */ - mask = CWX | CWY; + Mask mask = CWX | CWY; nxagentScreenTrap = 1; - ConfigureWindow(pWin, mask, (XID *) values, pClient); + ConfigureWindow(pWin, mask, (XID *) values, wClient(pWin)); nxagentScreenTrap = 0; } @@ -1930,16 +1924,6 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } case CirculateNotify: { - /* - * WindowPtr pWin; - * WindowPtr pSib; - * ClientPtr pClient; - - * XID values[2]; - * register XID *value = values; - * Mask mask = 0; - */ - #ifdef WARNING fprintf(stderr, "nxagentDispatchEvents: Going to handle new CirculateNotify event.\n"); #endif @@ -1947,7 +1931,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already /* * FIXME: Do we need this? * - * pWin = nxagentWindowPtr(X.xcirculate.window); + * WindowPtr pWin = nxagentWindowPtr(X.xcirculate.window); * * if (!pWin) * { @@ -2062,11 +2046,9 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already ((pWin = nxagentWindowPtr(X.xmap.window)) != NULL && nxagentWindowTopLevel(pWin) == 1)) { - ClientPtr pClient = wClient(pWin); - nxagentScreenTrap = 1; - MapWindow(pWin, pClient); + MapWindow(pWin, wClient(pWin)); nxagentScreenTrap = 0; } @@ -2119,7 +2101,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already if (mappingEvent -> request == MappingPointer) { - nxagentInitPointerMap(); + nxagentInitPointerMap(); } break; @@ -2384,15 +2366,6 @@ int nxagentHandlePropertyNotify(XEvent *X) int nxagentHandleExposeEvent(XEvent *X) { - WindowPtr pWin = NULL; - Window window = None; - - RegionRec sum; - RegionRec add; - BoxRec box; - int index = 0; - int overlap = 0; - StaticResizedWindowStruct *resizedWinPtr = NULL; #ifdef DEBUG @@ -2402,12 +2375,16 @@ int nxagentHandleExposeEvent(XEvent *X) X -> xexpose.window); #endif - window = X -> xexpose.window; + Window window = X -> xexpose.window; - pWin = nxagentWindowPtr(window); + WindowPtr pWin = nxagentWindowPtr(window); if (pWin != NULL) { + RegionRec sum; + RegionRec add; + BoxRec box; + RegionInit(&sum, (BoxRec *) NULL, 1); /* FIXME: This can be maybe optimized by consuming the @@ -2453,6 +2430,7 @@ FIXME: This can be maybe optimized by consuming the while (nxagentCheckEvents(nxagentDisplay, X, nxagentExposurePredicate, (XPointer) &window) == 1); + int overlap = 0; RegionValidate(&sum, &overlap); RegionIntersect(&sum, &sum, @@ -2468,7 +2446,7 @@ FIXME: This can be maybe optimized by consuming the * save received exposes for later processing. */ - index = nxagentLookupByWindow(pWin); + int index = nxagentLookupByWindow(pWin); if (index == -1) { @@ -2515,14 +2493,11 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) * saved window, else do nothing. */ - RegionPtr exposeRegion; - BoxRec rect; - WindowPtr pWin; StoringPixmapPtr pStoringPixmapRec = NULL; miBSWindowPtr pBSwindow = NULL; int drawableType; - pWin = nxagentWindowPtr(X -> xgraphicsexpose.drawable); + WindowPtr pWin = nxagentWindowPtr(X -> xgraphicsexpose.drawable); if (pWin != NULL) { @@ -2569,7 +2544,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) rect.x2 = rect.x1 + X -> xgraphicsexpose.width; rect.y2 = rect.y1 + X -> xgraphicsexpose.height; - exposeRegion = RegionCreate(&rect, 0); + RegionPtr exposeRegion = RegionCreate(&rect, 0); if (drawableType == DRAWABLE_PIXMAP) { @@ -2705,11 +2680,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) if (X -> xclient.message_type == nxagentAtoms[1]) /* WM_PROTOCOLS */ { - Atom deleteWMatom, wmAtom; - - wmAtom = (Atom) X -> xclient.data.l[0]; - - deleteWMatom = nxagentAtoms[2]; /* WM_DELETE_WINDOW */ + Atom wmAtom = (Atom) X -> xclient.data.l[0]; + Atom deleteWMatom = nxagentAtoms[2]; /* WM_DELETE_WINDOW */ if (wmAtom == deleteWMatom) { @@ -2853,8 +2825,6 @@ int nxagentHandleXkbKeyboardStateEvent(XEvent *X) int nxagentHandleXFixesSelectionNotify(XEvent *X) { - Atom local; - XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X; if (nxagentXFixesInfo.Initialized == 0) @@ -2877,14 +2847,14 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Handling event.\n"); #endif - local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection); + Atom local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection); if (SelectionCallback) { int i = nxagentFindCurrentSelectionIndex(local); if (i < NumCurrentSelections) { - SelectionInfoRec info; + SelectionInfoRec info; if (CurrentSelections[i].client != 0) { @@ -3173,12 +3143,9 @@ int nxagentHandleConfigureNotify(XEvent* X) { if (nxagentOption(Rootless) == True) { - ClientPtr pClient; - WindowPtr pWinWindow; - WindowPtr pWin; int sendEventAnyway = 0; - pWinWindow = nxagentWindowPtr(X -> xconfigure.window); + WindowPtr pWinWindow = nxagentWindowPtr(X -> xconfigure.window); #ifdef TEST { @@ -3196,7 +3163,8 @@ int nxagentHandleConfigureNotify(XEvent* X) X -> xconfigure.height, X -> xconfigure.send_event); #endif - if ((pWin = nxagentRootlessTopLevelWindow(X -> xconfigure.window)) != NULL) + WindowPtr pWin = nxagentRootlessTopLevelWindow(X -> xconfigure.window); + if (pWin != NULL) { /* * Checking for new geometry or stacking order changes. @@ -3210,11 +3178,9 @@ int nxagentHandleConfigureNotify(XEvent* X) if (nxagentWindowTopLevel(pWinWindow) && !X -> xconfigure.override_redirect) { XID values[5]; - Mask mask = 0; - register XID *value = values; - pClient = wClient(pWinWindow); + Mask mask = CWHeight | CWWidth | CWBorderWidth; /* FIXME: override_redirect is always FALSE here */ if (X -> xconfigure.send_event || !nxagentWMIsRunning || @@ -3242,11 +3208,9 @@ int nxagentHandleConfigureNotify(XEvent* X) * nxagentWindowPriv(pWinWindow)->height = X -> xconfigure.height; */ - mask |= CWHeight | CWWidth | CWBorderWidth; - nxagentScreenTrap = 1; - ConfigureWindow(pWinWindow, mask, (XID *) values, pClient); + ConfigureWindow(pWinWindow, mask, (XID *) values, wClient(pWinWindow)); nxagentScreenTrap = 0; @@ -3271,8 +3235,7 @@ int nxagentHandleConfigureNotify(XEvent* X) xEvent x; memset(&x, 0, sizeof(xEvent)); - x.u.u.type = X -> xconfigure.type; - x.u.u.type |= 0x80; + x.u.u.type = X -> xconfigure.type | 0x80; x.u.configureNotify.event = pWinWindow -> drawable.id; x.u.configureNotify.window = pWinWindow -> drawable.id; @@ -3293,7 +3256,7 @@ int nxagentHandleConfigureNotify(XEvent* X) x.u.configureNotify.borderWidth = X -> xconfigure.border_width; x.u.configureNotify.override = X -> xconfigure.override_redirect; - TryClientEvents(pClient, &x, 1, 1, 1, 0); + TryClientEvents(wClient(pWinWindow), &x, 1, 1, 1, 0); } return 1; @@ -3494,12 +3457,6 @@ int nxagentHandleReparentNotify(XEvent* X) if (nxagentOption(Rootless)) { - XlibWindow w; - XlibWindow root_return = 0; - XlibWindow parent_return = 0; - XlibWindow *children_return = NULL; - unsigned int nchildren_return = 0; - Status result; WindowPtr pWin = nxagentWindowPtr(X -> xreparent.window); #ifdef TEST @@ -3522,8 +3479,13 @@ int nxagentHandleReparentNotify(XEvent* X) * to know the new top level ancestor. */ - w = None; - parent_return = X -> xreparent.parent; + XlibWindow w = None; + XlibWindow root_return = 0; + XlibWindow *children_return = NULL; + unsigned int nchildren_return = 0; + Status result; + + XlibWindow parent_return = X -> xreparent.parent; while (parent_return != RootWindow(nxagentDisplay, 0)) { @@ -3587,19 +3549,11 @@ int nxagentHandleReparentNotify(XEvent* X) else if (nxagentWMIsRunning && nxagentOption(Fullscreen) == 0 && nxagentOption(WMBorderWidth) == -1) { - XlibWindow w; - XlibWindow rootReturn = 0; - XlibWindow parentReturn = 0; - XlibWindow junk; - XlibWindow *childrenReturn = NULL; - unsigned int nchildrenReturn = 0; - XWindowAttributes attributes; - int x, y; - /* * Calculate the absolute upper-left X e Y */ + XWindowAttributes attributes; if ((XGetWindowAttributes(nxagentDisplay, X -> xreparent.window, &attributes) == 0)) { @@ -3611,9 +3565,10 @@ int nxagentHandleReparentNotify(XEvent* X) return 1; } - x = attributes.x; - y = attributes.y; + int x = attributes.x; + int y = attributes.y; + XlibWindow junk; XTranslateCoordinates(nxagentDisplay, X -> xreparent.window, attributes.root, -attributes.border_width, -attributes.border_width, &x, &y, &junk); @@ -3622,11 +3577,14 @@ int nxagentHandleReparentNotify(XEvent* X) * Calculate the parent X and parent Y. */ - w = X -> xreparent.parent; + XlibWindow w = X -> xreparent.parent; if (w != DefaultRootWindow(nxagentDisplay)) { - int xParent, yParent; + XlibWindow rootReturn = 0; + XlibWindow parentReturn = 0; + XlibWindow *childrenReturn = NULL; + unsigned int nchildrenReturn = 0; do { @@ -3658,16 +3616,13 @@ int nxagentHandleReparentNotify(XEvent* X) return 1; } - xParent = attributes.x; - yParent = attributes.y; - /* * Difference between Absolute X and Parent X gives thickness of side frame. * Difference between Absolute Y and Parent Y gives thickness of title bar. */ - nxagentChangeOption(WMBorderWidth, (x - xParent)); - nxagentChangeOption(WMTitleHeight, (y - yParent)); + nxagentChangeOption(WMBorderWidth, (x - attributes.x)); + nxagentChangeOption(WMTitleHeight, (y - attributes.y)); } } @@ -3723,9 +3678,7 @@ void nxagentDisablePointerEvents(void) void nxagentSendFakeKey(int key) { xEvent fake; - Time now; - - now = GetTimeInMillis(); + Time now = GetTimeInMillis(); memset(&fake, 0, sizeof(xEvent)); fake.u.u.type = KeyPress; @@ -3745,8 +3698,6 @@ int nxagentInitXkbKeyboardState(void) { XEvent X; - unsigned int modifiers; - XkbEvent *xkbev = (XkbEvent *) &X; if (nxagentXkbInfo.EventBase == -1) @@ -3760,6 +3711,7 @@ int nxagentInitXkbKeyboardState(void) memset(&X, 0, sizeof(XEvent)); + unsigned int modifiers; XkbGetIndicatorState(nxagentDisplay, XkbUseCoreKbd, &modifiers); xkbev -> state.locked_mods = 0x0; @@ -3806,17 +3758,13 @@ int nxagentWaitForResource(GetResourceFuncPtr pGetResource, PredicateFuncPtr pPr void nxagentGrabPointerAndKeyboard(XEvent *X) { - unsigned long now; - - int resource; - - int result; - #ifdef TEST fprintf(stderr, "nxagentGrabPointerAndKeyboard: Grabbing pointer and keyboard with event at [%p].\n", (void *) X); #endif + unsigned long now; + if (X != NULL) { now = X -> xcrossing.time; @@ -3830,12 +3778,10 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the keyboard in context [B1].\n"); #endif - if (nxagentFullscreenWindow) - result = XGrabKeyboard(nxagentDisplay, nxagentFullscreenWindow, - True, GrabModeAsync, GrabModeAsync, now); - else - result = XGrabKeyboard(nxagentDisplay, RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)), - True, GrabModeAsync, GrabModeAsync, now); + int result = XGrabKeyboard(nxagentDisplay, + nxagentFullscreenWindow ? nxagentFullscreenWindow + : RootWindow(nxagentDisplay, DefaultScreen(nxagentDisplay)), + True, GrabModeAsync, GrabModeAsync, now); if (result != GrabSuccess) { @@ -3863,8 +3809,8 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the pointer in context [B2].\n"); #endif - resource = nxagentWaitForResource(NXGetCollectGrabPointerResource, - nxagentCollectGrabPointerPredicate); + int resource = nxagentWaitForResource(NXGetCollectGrabPointerResource, + nxagentCollectGrabPointerPredicate); if (nxagentFullscreenWindow) NXCollectGrabPointer(nxagentDisplay, resource, @@ -3971,14 +3917,6 @@ void nxagentHandleCollectGrabPointerEvent(int resource) void nxagentHandleCollectPropertyEvent(XEvent *X) { - Window window; - Atom property; - Atom atomReturnType; - int resultFormat; - unsigned long ulReturnItems; - unsigned long ulReturnBytesLeft; - unsigned char *pszReturnData = NULL; - int result; int resource = X -> xclient.data.l[1]; if (X -> xclient.data.l[2] == False) @@ -3997,18 +3935,24 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) } else { - result = NXGetCollectedProperty(nxagentDisplay, - resource, - &atomReturnType, - &resultFormat, - &ulReturnItems, - &ulReturnBytesLeft, - &pszReturnData); + Atom atomReturnType; + int resultFormat; + unsigned long ulReturnItems; + unsigned long ulReturnBytesLeft; + unsigned char *pszReturnData = NULL; + + int result = NXGetCollectedProperty(nxagentDisplay, + resource, + &atomReturnType, + &resultFormat, + &ulReturnItems, + &ulReturnBytesLeft, + &pszReturnData); if (result == True) { - window = nxagentPropertyRequests[resource].window; - property = nxagentPropertyRequests[resource].property; + Window window = nxagentPropertyRequests[resource].window; + Atom property = nxagentPropertyRequests[resource].property; nxagentImportProperty(window, property, atomReturnType, resultFormat, ulReturnItems, ulReturnBytesLeft, pszReturnData); @@ -4029,8 +3973,6 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) void nxagentSynchronizeExpose(void) { - WindowPtr pWin; - if (nxagentExposeQueue.length <= 0) { #ifdef TEST @@ -4041,7 +3983,7 @@ void nxagentSynchronizeExpose(void) return; } - pWin = nxagentExposeQueueHead.pWindow; + WindowPtr pWin = nxagentExposeQueueHead.pWindow; if (pWin) { @@ -4084,16 +4026,13 @@ void nxagentSynchronizeExpose(void) { RegionDestroy(nxagentExposeQueueHead.localRegion); } - nxagentExposeQueueHead.localRegion = NullRegion; if (nxagentExposeQueueHead.remoteRegion != NullRegion) { RegionDestroy(nxagentExposeQueueHead.remoteRegion); } - nxagentExposeQueueHead.remoteRegion = NullRegion; - nxagentExposeQueueHead.remoteRegionIsCompleted = False; nxagentExposeQueue.start = (nxagentExposeQueue.start + 1) % EXPOSED_SIZE; @@ -4238,13 +4177,12 @@ void nxagentForwardRemoteExpose(void) void nxagentAddRectToRemoteExposeRegion(BoxPtr rect) { - RegionRec exposeRegion; - if (nxagentRemoteExposeRegion == NULL) { return; } + RegionRec exposeRegion; RegionInit(&exposeRegion, rect, 1); RegionUnion(nxagentRemoteExposeRegion, @@ -4562,14 +4500,12 @@ static const char *nxagentGrabStateToString(int state) void nxagentDumpInputDevicesState(void) { - DeviceIntPtr dev; - GrabPtr grab; WindowPtr pWin = NULL; fprintf(stderr, "\n*** Dump input devices state: BEGIN ***" "\nKeys down:"); - dev = inputInfo.keyboard; + DeviceIntPtr dev = inputInfo.keyboard; for (int i = 0; i < DOWN_LENGTH; i++) { @@ -4597,7 +4533,7 @@ void nxagentDumpInputDevicesState(void) dev -> fromPassiveGrab ? "Yes" : "No", dev -> activatingKey); - grab = dev -> grab; + GrabPtr grab = dev -> grab; if (grab) { -- cgit v1.2.3 From d501d48c30dca60febbac408dc3118139c687220 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 22:57:13 +0200 Subject: Events.c: use designated initializers --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 37 ++++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 11ea28f0f..70a3f957e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -1610,9 +1610,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already if (nxagentOption(ViewOnly) == 0 && nxagentOption(Shadow)) { - XEvent xM; - - memset(&xM, 0, sizeof(XEvent)); + XEvent xM = {0}; xM.type = KeyRelease; xM.xkey.display = nxagentDisplay; xM.xkey.type = KeyRelease; @@ -2539,10 +2537,12 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) * Rectangle affected by GraphicsExpose event. */ - rect.x1 = X -> xgraphicsexpose.x; - rect.y1 = X -> xgraphicsexpose.y; - rect.x2 = rect.x1 + X -> xgraphicsexpose.width; - rect.y2 = rect.y1 + X -> xgraphicsexpose.height; + BoxRec rect = { + .x1 = X -> xgraphicsexpose.x, + .y1 = X -> xgraphicsexpose.y, + .x2 = rect.x1 + X -> xgraphicsexpose.width, + .y2 = rect.y1 + X -> xgraphicsexpose.height, + }; RegionPtr exposeRegion = RegionCreate(&rect, 0); @@ -2635,12 +2635,9 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) if (message_type == MakeAtom("WM_PROTOCOLS", strlen("WM_PROTOCOLS"), False)) { - xEvent x; - - memset(&x, 0, sizeof(xEvent)); + xEvent x = {0}; x.u.u.type = ClientMessage; x.u.u.detail = X -> xclient.format; - x.u.clientMessage.window = pWin -> drawable.id; x.u.clientMessage.u.l.type = message_type; x.u.clientMessage.u.l.longs0 = nxagentRemoteToLocalAtom(X -> xclient.data.l[0]); @@ -2854,8 +2851,6 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) int i = nxagentFindCurrentSelectionIndex(local); if (i < NumCurrentSelections) { - SelectionInfoRec info; - if (CurrentSelections[i].client != 0) { #ifdef TEST @@ -2889,8 +2884,10 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) } #endif - info.selection = &CurrentSelections[i]; - info.kind = xfixesEvent->xfixesselection.subtype; + SelectionInfoRec info = { + .selection = &CurrentSelections[i], + .kind = xfixesEvent->xfixesselection.subtype + }; /* * The trap indicates that we are triggered by a clipboard event @@ -3232,9 +3229,8 @@ int nxagentHandleConfigureNotify(XEvent* X) if (sendEventAnyway || X -> xconfigure.send_event) { - xEvent x; + xEvent x = {0}; - memset(&x, 0, sizeof(xEvent)); x.u.u.type = X -> xconfigure.type | 0x80; x.u.configureNotify.event = pWinWindow -> drawable.id; @@ -3677,10 +3673,9 @@ void nxagentDisablePointerEvents(void) void nxagentSendFakeKey(int key) { - xEvent fake; Time now = GetTimeInMillis(); - memset(&fake, 0, sizeof(xEvent)); + xEvent fake = {0}; fake.u.u.type = KeyPress; fake.u.u.detail = key; fake.u.keyButtonPointer.time = now; @@ -3696,7 +3691,7 @@ void nxagentSendFakeKey(int key) int nxagentInitXkbKeyboardState(void) { - XEvent X; + XEvent X = {0}; XkbEvent *xkbev = (XkbEvent *) &X; @@ -3709,8 +3704,6 @@ int nxagentInitXkbKeyboardState(void) fprintf(stderr, "%s: Initializing XKB state.\n", __func__); #endif - memset(&X, 0, sizeof(XEvent)); - unsigned int modifiers; XkbGetIndicatorState(nxagentDisplay, XkbUseCoreKbd, &modifiers); -- cgit v1.2.3 From 8dbfc1e4505e1dc1a43bf8e70e13e4d3c7935c48 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 30 Oct 2019 21:58:47 +0100 Subject: Event.c: use __func__ in fprintf --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 314 +++++++++++++--------------- 1 file changed, 144 insertions(+), 170 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 70a3f957e..7c53cbf3f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -288,7 +288,7 @@ void ProcessInputEvents(void) #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "ProcessInputEvents: Processing input.\n"); + fprintf(stderr, "%s: Processing input.\n", __func__); } #endif @@ -452,7 +452,7 @@ void nxagentRemoteWindowsTree(Window window, int level) if (!XQueryTree(nxagentDisplay, window, &rootWin, &parentWin, &childList, &numChildren)) { - fprintf(stderr, "nxagentRemoteWindowsTree - XQueryTree failed.\n"); + fprintf(stderr, "%s - XQueryTree failed.\n", __func__); return; } @@ -566,7 +566,7 @@ void nxagentInternalWindowsTree(WindowPtr pWin, int indent) void nxagentSwitchResizeMode(ScreenPtr pScreen) { #ifdef DEBUG - fprintf(stderr, "nxagentSwitchResizeMode called.\n"); + fprintf(stderr, "%s: Called.\n", __func__); #endif int desktopResize = nxagentOption(DesktopResize); @@ -842,8 +842,8 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) #endif #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new events with " - "predicate [%p].\n", *(void **)&predicate); + fprintf(stderr, "%s: Going to handle new events with predicate [%p].\n", __func__, + *(void **)&predicate); #endif if (nxagentRemoteExposeRegion == NULL) @@ -863,7 +863,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) if (nxagentPendingEvents(nxagentDisplay) == 0) { - fprintf(stderr, "nxagentDispatchEvents: PANIC! No event needs to be dispatched.\n"); + fprintf(stderr, "%s: PANIC! No event needs to be dispatched.\n", __func__); } #endif @@ -879,7 +879,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) nxagentAnyEventPredicate, NULL) == 1) { #ifdef DEBUG - fprintf(stderr, "nxagentDispatchEvents: Going to handle new event type [%d].\n", + fprintf(stderr, "%s: Going to handle new event type [%d].\n", __func__, X.type); #endif @@ -894,7 +894,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case SelectionClear: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionClear event.\n"); + fprintf(stderr, "%s: Going to handle new SelectionClear event.\n", __func__); #endif nxagentClearSelection(&X); @@ -904,7 +904,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case SelectionRequest: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionRequest event.\n"); + fprintf(stderr, "%s: Going to handle new SelectionRequest event.\n", __func__); #endif nxagentRequestSelection(&X); @@ -914,7 +914,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case SelectionNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new SelectionNotify event.\n"); + fprintf(stderr, "%s: Going to handle new SelectionNotify event.\n", __func__); #endif nxagentHandleSelectionNotifyFromXServer(&X); @@ -927,8 +927,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) case PropertyNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: PropertyNotify on " - "prop %d[%s] window %lx state %d\n", + fprintf(stderr, "%s: PropertyNotify on prop %d[%s] window %lx state %d\n", __func__, (int)X.xproperty.atom, validateString(XGetAtomName(nxagentDisplay, X.xproperty.atom)), X.xproperty.window, X.xproperty.state); #endif @@ -942,7 +941,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) enum HandleEventResult result; #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeyPress event.\n"); + fprintf(stderr, "%s: Going to handle new KeyPress event.\n", __func__); #endif nxagentInputEvent = 1; @@ -1131,7 +1130,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeyRelease event.\n"); + fprintf(stderr, "%s: Going to handle new KeyRelease event.\n", __func__); #endif nxagentInputEvent = 1; @@ -1211,7 +1210,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Going to handle new ButtonPress event.\n"); + fprintf(stderr, "%s: Going to handle new ButtonPress event.\n", __func__); } #endif @@ -1276,7 +1275,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Adding ButtonPress event.\n"); + fprintf(stderr, "%s: Adding ButtonPress event.\n", __func__); } #endif @@ -1310,7 +1309,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Going to handle new ButtonRelease event.\n"); + fprintf(stderr, "%s: Going to handle new ButtonRelease event.\n", __func__); } #endif @@ -1350,7 +1349,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Adding ButtonRelease event.\n"); + fprintf(stderr, "%s: Adding ButtonRelease event.\n", __func__); } #endif @@ -1384,17 +1383,17 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already ScreenPtr pScreen = nxagentScreen(X.xmotion.window); #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new MotionNotify event.\n"); + fprintf(stderr, "%s: Going to handle new MotionNotify event.\n", __func__); #endif #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Handling motion notify window [%ld] root [%ld] child [%ld].\n", - X.xmotion.window, X.xmotion.root, X.xmotion.subwindow); + fprintf(stderr, "%s: Handling motion notify window [%ld] root [%ld] child [%ld].\n", + __func__, X.xmotion.window, X.xmotion.root, X.xmotion.subwindow); - fprintf(stderr, "nxagentDispatchEvents: Pointer at [%d][%d] relative root [%d][%d].\n", - X.xmotion.x, X.xmotion.y, X.xmotion.x_root, X.xmotion.y_root); + fprintf(stderr, "%s: Pointer at [%d][%d] relative root [%d][%d].\n", __func__, + X.xmotion.x, X.xmotion.y, X.xmotion.x_root, X.xmotion.y_root); } #endif @@ -1445,7 +1444,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef NX_DEBUG_INPUT if (nxagentDebugInput == 1) { - fprintf(stderr, "nxagentDispatchEvents: Adding motion event [%d, %d] to the queue.\n", + fprintf(stderr, "%s: Adding motion event [%d, %d] to the queue.\n", __func__, x.u.keyButtonPointer.rootX, x.u.keyButtonPointer.rootY); } #endif @@ -1513,7 +1512,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #else #ifdef TEST - fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__); + fprintf(stderr, "%s: Going to handle new FocusIn event\n", __func__); #endif #endif @@ -1650,7 +1649,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case KeymapNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new KeymapNotify event.\n"); + fprintf(stderr, "%s: Going to handle new KeymapNotify event.\n", __func__); #endif break; @@ -1660,7 +1659,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already WindowPtr pWin; #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new EnterNotify event.\n"); + fprintf(stderr, "%s: Going to handle new EnterNotify event.\n", __func__); #endif if (nxagentOption(Rootless)) @@ -1682,7 +1681,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: nxagentLastEnteredTopLevelWindow [%p].\n", + fprintf(stderr, "%s: nxagentLastEnteredTopLevelWindow [%p].\n", __func__, (void *)nxagentLastEnteredTopLevelWindow); #endif } @@ -1700,7 +1699,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already */ #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: pWin -> drawable.x [%d] pWin -> drawable.y [%d].\n", + fprintf(stderr, "%s: pWin -> drawable.x [%d] pWin -> drawable.y [%d].\n", __func__, pWin -> drawable.x, pWin -> drawable.y); #endif @@ -1768,7 +1767,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case LeaveNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new LeaveNotify event.\n"); + fprintf(stderr, "%s: Going to handle new LeaveNotify event.\n", __func__); #endif if (nxagentOption(Rootless) && X.xcrossing.mode == NotifyNormal && @@ -1804,7 +1803,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case DestroyNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new DestroyNotify event.\n"); + fprintf(stderr, "%s: Going to handle new DestroyNotify event.\n", __func__); #endif if (nxagentParentWindow != (Window) 0 && @@ -1820,7 +1819,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already enum HandleEventResult result; #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new ClientMessage event.\n"); + fprintf(stderr, "%s: Going to handle new ClientMessage event.\n", __func__); #endif nxagentHandleClientMessageEvent(&X, &result); @@ -1835,7 +1834,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case VisibilityNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new VisibilityNotify event.\n"); + fprintf(stderr, "%s: Going to handle new VisibilityNotify event.\n", __func__); #endif if (X.xvisibility.window != nxagentDefaultWindows[0]) @@ -1862,7 +1861,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Suppressing visibility notify on window [%lx].\n", + fprintf(stderr, "%s: Suppressing visibility notify on window [%lx].\n", __func__, X.xvisibility.window); #endif @@ -1870,7 +1869,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already } #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Visibility notify state is [%d] with previous [%d].\n", + fprintf(stderr, "%s: Visibility notify state is [%d] with previous [%d].\n", __func__, X.xvisibility.state, nxagentVisibility); #endif @@ -1881,10 +1880,10 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case Expose: { #ifdef DEBUG - fprintf(stderr, "nxagentDispatchEvents: Going to handle new Expose event.\n"); + fprintf(stderr, "%s: Going to handle new Expose event.\n", __func__); - fprintf(stderr, "nxagentDispatchEvents: WARNING! Received Expose event " - "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n", + fprintf(stderr, "%s: WARNING! Received Expose event for drawable [%lx]" + " geometry [%d, %d, %d, %d] count [%d].\n", __func__, X.xexpose.window, X.xexpose.x, X.xexpose.y, X.xexpose.width, X.xexpose.height, X.xexpose.count); #endif @@ -1896,10 +1895,10 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case GraphicsExpose: { #ifdef DEBUG - fprintf(stderr, "nxagentDispatchEvents: Going to handle new GraphicsExpose event.\n"); + fprintf(stderr, "%s: Going to handle new GraphicsExpose event.\n", __func__); - fprintf(stderr, "nxagentDispatchEvents: WARNING! Received GraphicsExpose event " - "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n", + fprintf(stderr, "%s: WARNING! Received GraphicsExpose event " + "for drawable [%lx] geometry [%d, %d, %d, %d] count [%d].\n", __func__, X.xgraphicsexpose.drawable, X.xgraphicsexpose.x, X.xgraphicsexpose.y, X.xgraphicsexpose.width, X.xgraphicsexpose.height, X.xgraphicsexpose.count); @@ -1912,10 +1911,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case NoExpose: { #ifdef DEBUG - fprintf(stderr, "nxagentDispatchEvents: Going to handle new NoExpose event.\n"); - - fprintf(stderr, "nxagentDispatchEvents: WARNING! Received NoExpose event for " - "drawable [%lx].\n", X.xnoexpose.drawable); + fprintf(stderr, "%s: Going to handle new NoExpose event.\n", __func__); + fprintf(stderr, "%s: WARNING! Received NoExpose event for drawable [%lx].\n", __func__, X.xnoexpose.drawable); #endif break; @@ -1923,7 +1920,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case CirculateNotify: { #ifdef WARNING - fprintf(stderr, "nxagentDispatchEvents: Going to handle new CirculateNotify event.\n"); + fprintf(stderr, "%s: Going to handle new CirculateNotify event.\n", __func__); #endif /* @@ -1952,7 +1949,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case ConfigureNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new ConfigureNotify event.\n"); + fprintf(stderr, "%s: Going to handle new ConfigureNotify event.\n", __func__); #endif if (nxagentConfiguredSynchroWindow == X.xconfigure.window) @@ -1962,14 +1959,13 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already #ifdef WARNING if (nxagentVerbose == 1) { - fprintf(stderr, "nxagentDispatchEvents: Requested ConfigureNotify changes didn't take place.\n"); + fprintf(stderr, "%s: Requested ConfigureNotify changes didn't take place.\n", __func__); } #endif } #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Received ConfigureNotify and going to call " - "nxagentSynchronizeExpose.\n"); + fprintf(stderr, "%s: Received ConfigureNotify and going to call nxagentSynchronizeExpose.\n", __func__); #endif nxagentSynchronizeExpose(); @@ -1984,7 +1980,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case GravityNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new GravityNotify event.\n"); + fprintf(stderr, "%s: Going to handle new GravityNotify event.\n", __func__); #endif break; @@ -1992,7 +1988,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case ReparentNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new ReparentNotify event.\n"); + fprintf(stderr, "%s: Going to handle new ReparentNotify event.\n", __func__); #endif nxagentHandleReparentNotify(&X); @@ -2002,7 +1998,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case UnmapNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new UnmapNotify event.\n"); + fprintf(stderr, "%s: Going to handle new UnmapNotify event.\n", __func__); #endif if (nxagentOption(Rootless) == 1) @@ -2033,7 +2029,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case MapNotify: { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Going to handle new MapNotify event.\n"); + fprintf(stderr, "%s: Going to handle new MapNotify event.\n", __func__); #endif if (nxagentOption(Rootless) == 1) @@ -2094,7 +2090,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already XMappingEvent *mappingEvent = (XMappingEvent *) &X; #ifdef DEBUG - fprintf(stderr, "nxagentDispatchEvents: WARNING! Going to handle new MappingNotify event.\n"); + fprintf(stderr, "%s: WARNING! Going to handle new MappingNotify event.\n", __func__); #endif if (mappingEvent -> request == MappingPointer) @@ -2113,8 +2109,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already if (nxagentHandleXkbKeyboardStateEvent(&X) == 0 && nxagentHandleXFixesSelectionNotify(&X) == 0) { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: WARNING! Unhandled event code [%d].\n", - X.type); + fprintf(stderr, "%s: WARNING! Unhandled event code [%d].\n", __func__, X.type); #endif } @@ -2225,7 +2220,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already ProcessInputEvents(); #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Output pending flag is [%d] critical [%d].\n", + fprintf(stderr, "%s: Output pending flag is [%d] critical [%d].\n", __func__, NewOutputPending, CriticalOutputPending); #endif @@ -2242,19 +2237,17 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already if (NewOutputPending == 1) { #ifdef TEST - fprintf(stderr, "nxagentDispatchEvents: Flushed the processed events to clients.\n"); + fprintf(stderr, "%s: Flushed the processed events to clients.\n", __func__); #endif FlushAllOutput(); } #ifdef TEST - if (nxagentPendingEvents(nxagentDisplay) > 0) { - fprintf(stderr, "nxagentDispatchEvents: WARNING! More events need to be dispatched.\n"); + fprintf(stderr, "%s: WARNING! More events need to be dispatched.\n", __func__); } - #endif #ifdef BLOCKS @@ -2327,7 +2320,7 @@ int nxagentHandlePropertyNotify(XEvent *X) if (nxagentOption(Rootless) && !nxagentNotifyMatchChangeProperty((XPropertyEvent *) X)) { #ifdef TEST - fprintf(stderr, "nxagentHandlePropertyNotify: Property %ld on window %lx.\n", + fprintf(stderr, "%s: Property %ld on window %lx.\n", __func__, X -> xproperty.atom, X -> xproperty.window); #endif @@ -2338,7 +2331,7 @@ int nxagentHandlePropertyNotify(XEvent *X) if (resource == -1) { #ifdef WARNING - fprintf(stderr, "nxagentHandlePropertyNotify: WARNING! Asynchronous get property queue is full.\n"); + fprintf(stderr, "%s: WARNING! Asynchronous get property queue is full.\n", __func__); #endif return 0; @@ -2354,7 +2347,7 @@ int nxagentHandlePropertyNotify(XEvent *X) #ifdef TEST else { - fprintf(stderr, "nxagentHandlePropertyNotify: Failed to look up remote window property.\n"); + fprintf(stderr, "%s: Failed to look up remote window property.\n", __func__); } #endif } @@ -2367,10 +2360,8 @@ int nxagentHandleExposeEvent(XEvent *X) StaticResizedWindowStruct *resizedWinPtr = NULL; #ifdef DEBUG - fprintf(stderr, "nxagentHandleExposeEvent: Checking remote expose events.\n"); - - fprintf(stderr, "nxagentHandleExposeEvent: Looking for window id [%ld].\n", - X -> xexpose.window); + fprintf(stderr, "%s: Checking remote expose events.\n", __func__); + fprintf(stderr, "%s: Looking for window id [%ld].\n", __func__, X -> xexpose.window); #endif Window window = X -> xexpose.window; @@ -2391,8 +2382,7 @@ FIXME: This can be maybe optimized by consuming the do { #ifdef DEBUG - fprintf(stderr, "nxagentHandleExposeEvent: Adding event for window id [%ld].\n", - X -> xexpose.window); + fprintf(stderr, "%s: Adding event for window id [%ld].\n", __func__, X -> xexpose.window); #endif box.x1 = pWin -> drawable.x + wBorderWidth(pWin) + X -> xexpose.x; @@ -2435,8 +2425,7 @@ FIXME: This can be maybe optimized by consuming the &pWin->drawable.pScreen->root->winSize); #ifdef DEBUG - fprintf(stderr, "nxagentHandleExposeEvent: Sending events for window id [%ld].\n", - X -> xexpose.window); + fprintf(stderr, "%s: Sending events for window id [%ld].\n", __func__, X -> xexpose.window); #endif /* @@ -2463,7 +2452,7 @@ FIXME: This can be maybe optimized by consuming the nxagentExposeQueue.exposures[index].remoteRegion, &sum); #ifdef TEST - fprintf(stderr, "nxagentHandleExposeEvent: Added region for window [%u] to position [%d].\n", + fprintf(stderr, "%s: Added region for window [%u] to position [%d].\n", __func__, nxagentWindow(pWin), index); #endif @@ -2513,7 +2502,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) if (pStoringPixmapRec == NULL) { #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Storing pixmap not found.\n"); + fprintf(stderr, "%s: WARNING! Storing pixmap not found.\n", __func__); #endif return 1; @@ -2524,7 +2513,7 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) if (pBSwindow == NULL) { #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Back storage not found.\n"); + fprintf(stderr, "%s: WARNING! Back storage not found.\n", __func__); #endif return 1; @@ -2549,8 +2538,8 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) if (drawableType == DRAWABLE_PIXMAP) { #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: Handling GraphicsExpose event on pixmap with id" - " [%lu].\n", X -> xgraphicsexpose.drawable); + fprintf(stderr, "%s: Handling GraphicsExpose event on pixmap with id [%lu].\n", + __func__, X -> xgraphicsexpose.drawable); #endif /* @@ -2590,9 +2579,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) *result = doNothing; #ifdef TEST - fprintf(stderr, "nxagentHandleClientMessageEvent: ClientMessage event window [%ld] with " - "type [%ld] format [%d].\n", X -> xclient.window, X -> xclient.message_type, - X -> xclient.format); + fprintf(stderr, "%s: ClientMessage event window [%ld] with type [%ld] format [%d].\n", + __func__, X -> xclient.window, X -> xclient.message_type, X -> xclient.format); #endif /* @@ -2616,7 +2604,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) if (!ValidAtom(message_type)) { #ifdef WARNING - fprintf(stderr, "nxagentHandleClientMessageEvent: WARNING Invalid type in client message.\n"); + fprintf(stderr, "%s: WARNING Invalid type in client message.\n", __func__); #endif return 0; @@ -2646,8 +2634,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) if (!ValidAtom(x.u.clientMessage.u.l.longs0)) { #ifdef WARNING - fprintf(stderr, "nxagentHandleClientMessageEvent: WARNING Invalid value in client message " - "of type WM_PROTOCOLS.\n"); + fprintf(stderr, "%s: WARNING Invalid value in client message of type WM_PROTOCOLS.\n", __func__); #endif return 0; @@ -2655,8 +2642,8 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) #ifdef TEST else { - fprintf(stderr, "nxagentHandleClientMessageEvent: Sent client message of type WM_PROTOCOLS " - "and value [%s].\n", validateString(NameForAtom(x.u.clientMessage.u.l.longs0))); + fprintf(stderr, "%s: Sent client message of type WM_PROTOCOLS and value [%s].\n", __func__, + validateString(NameForAtom(x.u.clientMessage.u.l.longs0))); } #endif @@ -2665,7 +2652,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) else { #ifdef WARNING - fprintf(stderr, "nxagentHandleClientMessageEvent: Ignored message type %ld [%s].\n", + fprintf(stderr, "%s: Ignored message type %ld [%s].\n", __func__, (long int) message_type, validateString(NameForAtom(message_type))); #endif @@ -2689,7 +2676,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) else { #ifdef TEST - fprintf(stderr, "Events: WM_DELETE_WINDOW arrived Atom = %u.\n", wmAtom); + fprintf(stderr, "%s: WM_DELETE_WINDOW arrived Atom = %u.\n", __func__, wmAtom); #endif if (X -> xclient.window == nxagentIconWindow) @@ -2827,7 +2814,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (nxagentXFixesInfo.Initialized == 0) { #ifdef DEBUG - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: XFixes not initialized - doing nothing.\n"); + fprintf(stderr, "%s: XFixes not initialized - doing nothing.\n", __func__); #endif return 0; } @@ -2835,13 +2822,13 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (xfixesEvent -> type != (nxagentXFixesInfo.EventBase + XFixesSelectionNotify)) { #ifdef DEBUG - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: event type is [%d] - doing nothing.\n", xfixesEvent->type); + fprintf(stderr, "%s: event type is [%d] - doing nothing.\n", __func__, xfixesEvent->type); #endif return 0; } #ifdef TEST - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Handling event.\n"); + fprintf(stderr, "%s: Handling event.\n", __func__); #endif Atom local = nxagentRemoteToLocalAtom(xfixesEvent -> xfixesselection.selection); @@ -2854,14 +2841,14 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (CurrentSelections[i].client != 0) { #ifdef TEST - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Do nothing.\n"); + fprintf(stderr, "%s: Do nothing.\n", __func__); #endif return 1; } #ifdef TEST - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Calling callbacks for %d [%s] selection.\n", + fprintf(stderr, "%s: Calling callbacks for %d [%s] selection.\n", __func__, CurrentSelections[i].selection, NameForAtom(CurrentSelections[i].selection)); #endif @@ -2873,7 +2860,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) fprintf(stderr, "%s: Event selection owner [0x%x]\n", __func__, xfixesEvent->xfixesselection.owner); fprintf(stderr, "%s: Event selection [%s]\n", __func__, NameForAtom(nxagentRemoteToLocalAtom(xfixesEvent->xfixesselection.selection))); - fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Subtype "); + fprintf(stderr, "%s: Subtype ", __func__); switch (xfixesEvent -> xfixesselection.subtype) { @@ -2924,13 +2911,11 @@ int nxagentHandleProxyEvent(XEvent *X) if (X -> xclient.data.l[0] == NXNoSplitNotify) { - fprintf(stderr, "nxagentHandleProxyEvent: PANIC! NXNoSplitNotify received " - "with client [%d].\n", client); + fprintf(stderr, "%s: PANIC! NXNoSplitNotify received with client [%d].\n", __func__, client); } else { - fprintf(stderr, "nxagentHandleProxyEvent: PANIC! NXStartSplitNotify received " - "with client [%d].\n", client); + fprintf(stderr, "%s: PANIC! NXStartSplitNotify received with client [%d].\n", __func__, client); } #endif @@ -2951,8 +2936,8 @@ int nxagentHandleProxyEvent(XEvent *X) int position = (int) X -> xclient.data.l[3]; #ifdef TEST - fprintf(stderr, "nxagentHandleProxyEvent: NXCommitSplitNotify received with " - "client [%d] request [%d] and position [%d].\n", + fprintf(stderr, "%s: NXCommitSplitNotify received with client [%d]" + " request [%d] and position [%d].\n", __func__, client, request, position); #endif @@ -2970,8 +2955,7 @@ int nxagentHandleProxyEvent(XEvent *X) int client = (int) X -> xclient.data.l[1]; #ifdef TEST - fprintf(stderr, "nxagentHandleProxyEvent: NXEndSplitNotify received with " - "client [%d].\n", client); + fprintf(stderr, "%s: NXEndSplitNotify received with client [%d].\n", __func__, client); #endif nxagentHandleEndSplitEvent(client); @@ -2985,7 +2969,7 @@ int nxagentHandleProxyEvent(XEvent *X) */ #ifdef TEST - fprintf(stderr, "nxagentHandleProxyEvent: NXEmptySplitNotify received.\n"); + fprintf(stderr, "%s: NXEmptySplitNotify received.\n", __func__); #endif nxagentHandleEmptySplitEvent(); @@ -2997,8 +2981,7 @@ int nxagentHandleProxyEvent(XEvent *X) #ifdef TEST int resource = (int) X -> xclient.data.l[1]; - fprintf(stderr, "nxagentHandleProxyEvent: NXCollectPropertyNotify received with resource [%d].\n", - resource); + fprintf(stderr, "%s: NXCollectPropertyNotify received with resource [%d].\n", __func__, resource); #endif nxagentHandleCollectPropertyEvent(X); @@ -3010,8 +2993,7 @@ int nxagentHandleProxyEvent(XEvent *X) int resource = (int) X -> xclient.data.l[1]; #ifdef TEST - fprintf(stderr, "nxagentHandleProxyEvent: NXCollectGrabPointerNotify received with resource [%d].\n", - resource); + fprintf(stderr, "%s: NXCollectGrabPointerNotify received with resource [%d].\n", __func__, resource); #endif nxagentHandleCollectGrabPointerEvent(resource); @@ -3027,8 +3009,7 @@ int nxagentHandleProxyEvent(XEvent *X) */ #ifdef TEST - fprintf(stderr, "nxagentHandleProxyEvent: NXCollectInputFocusNotify received with resource [%d].\n", - resource); + fprintf(stderr, "%s: NXCollectInputFocusNotify received with resource [%d].\n", __func__, resource); #endif nxagentHandleCollectInputFocusEvent(resource); @@ -3042,7 +3023,7 @@ int nxagentHandleProxyEvent(XEvent *X) */ #ifdef WARNING - fprintf(stderr, "nxagentHandleProxyEvent: WARNING! Not a recognized ClientMessage proxy event [%d].\n", + fprintf(stderr, "%s: WARNING! Not a recognized ClientMessage proxy event [%d].\n", __func__, (int) X -> xclient.data.l[0]); #endif @@ -3093,7 +3074,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) if (geometryChanged) { #ifdef TEST - fprintf(stderr, "nxagentCheckWindowConfiguration: Configure frame. No restack.\n"); + fprintf(stderr, "%s: Configure frame. No restack.\n", __func__); #endif return 1; @@ -3101,13 +3082,12 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) #ifdef TEST { - fprintf(stderr, "nxagentCheckWindowConfiguration: Before restacking top level window [%p]\n", + fprintf(stderr, "%s: Before restacking top level window [%p]\n", __func__, (void *) nxagentWindowPtr(X -> window)); for (WindowPtr pSib = screenInfo.screens[0]->root -> firstChild; pSib; pSib = pSib -> nextSib) { - fprintf(stderr, "nxagentCheckWindowConfiguration: Top level window: [%p].\n", - (void *) pSib); + fprintf(stderr, "%s: Top level window: [%p].\n", __func__, (void *) pSib); } } #endif @@ -3122,15 +3102,14 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X) else { #ifdef WARNING - fprintf(stderr, "nxagentCheckWindowConfiguration: WARNING! Failed QueryTree request.\n"); + fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__); #endif } SAFE_XFree(children_return); #if 0 - fprintf(stderr, "nxagentCheckWindowConfiguration: Trees match: %s\n", - nxagentRootlessTreesMatch() ? "Yes" : "No"); + fprintf(stderr, "%s: Trees match: %s\n", __func__, nxagentRootlessTreesMatch() ? "Yes" : "No"); #endif return 1; @@ -3148,14 +3127,14 @@ int nxagentHandleConfigureNotify(XEvent* X) { WindowPtr pWinEvent = nxagentWindowPtr(X -> xconfigure.event); - fprintf(stderr, "nxagentHandleConfigureNotify: Generating window is [%p][%ld] target [%p][%ld].\n", + fprintf(stderr, "%s: Generating window is [%p][%ld] target [%p][%ld].\n", __func__, (void *) pWinEvent, X -> xconfigure.event, (void *) pWinWindow, X -> xconfigure.window); } #endif #ifdef TEST - fprintf(stderr, "nxagentHandleConfigureNotify: New configuration for window [%p][%ld] is [%d][%d][%d][%d] " - "send_event [%i].\n", (void *) pWinWindow, X -> xconfigure.window, + fprintf(stderr, "%s: New configuration for window [%p][%ld] is [%d][%d][%d][%d] send_event [%i].\n", + __func__, (void *) pWinWindow, X -> xconfigure.window, X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height, X -> xconfigure.send_event); #endif @@ -3221,7 +3200,7 @@ int nxagentHandleConfigureNotify(XEvent* X) if (nxagentOption(ClientOs) == ClientOsWinnt) { #ifdef TEST - fprintf(stderr, "nxagentHandleConfigureNotify: Apply workaround for NXWin.\n"); + fprintf(stderr, "%s: Apply workaround for NXWin.\n", __func__); #endif sendEventAnyway = 1; @@ -3410,7 +3389,7 @@ int nxagentHandleConfigureNotify(XEvent* X) if (doRandR) { #ifdef TEST - fprintf(stderr,"nxagentHandleConfigureNotify: Width %d Height %d.\n", + fprintf(stderr,"%s: Width %d Height %d.\n", __func__, nxagentOption(Width), nxagentOption(Height)); #endif @@ -3426,7 +3405,8 @@ int nxagentHandleConfigureNotify(XEvent* X) if ( (X -> xconfigure.window == DefaultRootWindow(nxagentDisplay)) || nxagentFullscreenWindow ) { #ifdef TEST - fprintf(stderr, "nxagentHandleConfigureNotify: remote root window has changed: %d,%d %dx%d\n", X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height); + fprintf(stderr, "%s: remote root window has changed: %d,%d %dx%d\n", __func__, + X -> xconfigure.x, X -> xconfigure.y, X -> xconfigure.width, X -> xconfigure.height); #endif nxagentChangeOption(RootX, X -> xconfigure.x); @@ -3448,7 +3428,7 @@ int nxagentHandleConfigureNotify(XEvent* X) int nxagentHandleReparentNotify(XEvent* X) { #ifdef TEST - fprintf(stderr, "nxagentHandleReparentNotify: Going to handle a new reparent event.\n"); + fprintf(stderr, "%s: Going to handle a new reparent event.\n", __func__); #endif if (nxagentOption(Rootless)) @@ -3461,7 +3441,7 @@ int nxagentHandleReparentNotify(XEvent* X) WindowPtr pParent = nxagentWindowPtr(X -> xreparent.parent); WindowPtr pEvent = nxagentWindowPtr(X -> xreparent.event); - fprintf(stderr, "nxagentHandleReparentNotify: event %p[%lx] window %p[%lx] parent %p[%lx] at (%d, %d)\n", + fprintf(stderr, "%s: event %p[%lx] window %p[%lx] parent %p[%lx] at (%d, %d)\n", __func__, (void*)pEvent, X -> xreparent.event, (void*)pWin, X -> xreparent.window, (void*)pParent, X -> xreparent.parent, X -> xreparent.x, X -> xreparent.y); } @@ -3494,7 +3474,7 @@ int nxagentHandleReparentNotify(XEvent* X) if (!result) { #ifdef WARNING - fprintf(stderr, "nxagentHandleReparentNotify: WARNING! Failed QueryTree request.\n"); + fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__); #endif break; @@ -3508,9 +3488,8 @@ int nxagentHandleReparentNotify(XEvent* X) nxagentRootlessAddTopLevelWindow(pWin, w); #ifdef TEST - fprintf(stderr, "nxagentHandleReparentNotify: new top level window [%ld].\n", w); - fprintf(stderr, "nxagentHandleReparentNotify: reparented window [%ld].\n", - X -> xreparent.window); + fprintf(stderr, "%s: new top level window [%ld].\n", __func__, w); + fprintf(stderr, "%s: reparented window [%ld].\n", __func__, X -> xreparent.window); #endif result = XQueryTree(nxagentDisplay, DefaultRootWindow(nxagentDisplay), @@ -3523,7 +3502,7 @@ int nxagentHandleReparentNotify(XEvent* X) else { #ifdef WARNING - fprintf(stderr, "nxagentHandleReparentNotify: WARNING! Failed QueryTree request.\n"); + fprintf(stderr, "%s: WARNING! Failed QueryTree request.\n", __func__); #endif } @@ -3532,8 +3511,8 @@ int nxagentHandleReparentNotify(XEvent* X) else { #ifdef TEST - fprintf(stderr, "nxagentHandleReparentNotify: Window at [%p] has been reparented to [%ld]" - " top level parent [%ld].\n", (void *) pWin, X -> xreparent.parent, w); + fprintf(stderr, "%s: Window at [%p] has been reparented to [%ld] top level parent [%ld].\n", + __func__, (void *) pWin, X -> xreparent.parent, w); #endif nxagentRootlessDelTopLevelWindow(pWin); @@ -3554,8 +3533,7 @@ int nxagentHandleReparentNotify(XEvent* X) &attributes) == 0)) { #ifdef WARNING - fprintf(stderr, "nxagentHandleReparentNotify: WARNING! " - "XGetWindowAttributes failed.\n"); + fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed.\n", __func__); #endif return 1; @@ -3605,8 +3583,7 @@ int nxagentHandleReparentNotify(XEvent* X) if (XGetWindowAttributes(nxagentDisplay, w, &attributes) == 0) { #ifdef WARNING - fprintf(stderr, "nxagentHandleReparentNotify: WARNING! " - "XGetWindowAttributes failed for parent window.\n"); + fprintf(stderr, "%s: WARNING! XGetWindowAttributes failed for parent window.\n", __func__); #endif return 1; @@ -3752,7 +3729,7 @@ int nxagentWaitForResource(GetResourceFuncPtr pGetResource, PredicateFuncPtr pPr void nxagentGrabPointerAndKeyboard(XEvent *X) { #ifdef TEST - fprintf(stderr, "nxagentGrabPointerAndKeyboard: Grabbing pointer and keyboard with event at [%p].\n", + fprintf(stderr, "%s: Grabbing pointer and keyboard with event at [%p].\n", __func__, (void *) X); #endif @@ -3768,7 +3745,7 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) } #ifdef TEST - fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the keyboard in context [B1].\n"); + fprintf(stderr, "%s: Going to grab the keyboard in context [B1].\n", __func__); #endif int result = XGrabKeyboard(nxagentDisplay, @@ -3799,7 +3776,7 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) isItTimeToYield = 1; #ifdef TEST - fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to grab the pointer in context [B2].\n"); + fprintf(stderr, "%s: Going to grab the pointer in context [B2].\n", __func__); #endif int resource = nxagentWaitForResource(NXGetCollectGrabPointerResource, @@ -3820,7 +3797,7 @@ void nxagentGrabPointerAndKeyboard(XEvent *X) if (X != NULL) { #ifdef TEST - fprintf(stderr, "nxagentGrabPointerAndKeyboard: Going to force focus in context [B4].\n"); + fprintf(stderr, "%s: Going to force focus in context [B4].\n", __func__); #endif XSetInputFocus(nxagentDisplay, nxagentFullscreenWindow, @@ -3833,7 +3810,7 @@ void nxagentUngrabPointerAndKeyboard(XEvent *X) unsigned long now; #ifdef TEST - fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Ungrabbing pointer and keyboard with event at [%p].\n", + fprintf(stderr, "%s: Ungrabbing pointer and keyboard with event at [%p].\n", __func__, (void *) X); #endif @@ -3847,13 +3824,13 @@ void nxagentUngrabPointerAndKeyboard(XEvent *X) } #ifdef TEST - fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Going to ungrab the keyboard in context [B5].\n"); + fprintf(stderr, "%s: Going to ungrab the keyboard in context [B5].\n", __func__); #endif XUngrabKeyboard(nxagentDisplay, now); #ifdef TEST - fprintf(stderr, "nxagentUngrabPointerAndKeyboard: Going to ungrab the pointer in context [B6].\n"); + fprintf(stderr, "%s: Going to ungrab the pointer in context [B6].\n", __func__); #endif XUngrabPointer(nxagentDisplay, now); @@ -3902,8 +3879,7 @@ void nxagentHandleCollectGrabPointerEvent(int resource) if (NXGetCollectedGrabPointer(nxagentDisplay, resource, &status) == 0) { #ifdef PANIC - fprintf(stderr, "nxagentHandleCollectGrabPointerEvent: PANIC! Failed to get GrabPointer " - "reply for resource [%d].\n", resource); + fprintf(stderr, "%s: PANIC! Failed to get GrabPointer reply for resource [%d].\n", __func__, resource); #endif } } @@ -3915,7 +3891,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) if (X -> xclient.data.l[2] == False) { #ifdef DEBUG - fprintf (stderr, "nxagentHandleCollectPropertyEvent: Failed to get reply data for client [%d].\n", + fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__, resource); #endif @@ -3953,7 +3929,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) else { #ifdef DEBUG - fprintf (stderr, "nxagentHandleCollectPropertyEvent: Failed to get reply data for client [%d].\n", + fprintf (stderr, "%s: Failed to get reply data for client [%d].\n", __func__, resource); #endif } @@ -3969,7 +3945,7 @@ void nxagentSynchronizeExpose(void) if (nxagentExposeQueue.length <= 0) { #ifdef TEST - fprintf(stderr, "nxagentSynchronizeExpose: PANIC! Called with nxagentExposeQueue.length [%d].\n", + fprintf(stderr, "%s: PANIC! Called with nxagentExposeQueue.length [%d].\n", __func__, nxagentExposeQueue.length); #endif @@ -4003,8 +3979,8 @@ void nxagentSynchronizeExpose(void) ((pWin -> eventMask|wOtherEventMasks(pWin)) & ExposureMask)) { #ifdef TEST - fprintf(stderr, "nxagentSynchronizeExpose: Going to call miWindowExposures" - " for window [%d] - rects [%d].\n", nxagentWindow(pWin), + fprintf(stderr, "%s: Going to call miWindowExposures for window [%d] - rects [%d].\n", + __func__, nxagentWindow(pWin), RegionNumRects(nxagentExposeQueueHead.remoteRegion)); #endif @@ -4061,13 +4037,11 @@ void nxagentRemoveDuplicatedKeys(XEvent *X) { #ifdef TEST - fprintf(stderr, "nxagentRemoveDuplicatedKeys: Trying to read more events " - "from the X server.\n"); + fprintf(stderr, "%s: Trying to read more events from the X server.\n", __func__); if (nxagentReadEvents(nxagentDisplay) > 0) { - fprintf(stderr, "nxagentRemoveDuplicatedKeys: Successfully read more events " - "from the X server.\n"); + fprintf(stderr, "%s: Successfully read more events from the X server.\n", __func__); } #else @@ -4144,7 +4118,7 @@ void nxagentInitRemoteExposeRegion(void) if (nxagentRemoteExposeRegion == NULL) { #ifdef PANIC - fprintf(stderr, "nxagentInitRemoteExposeRegion: PANIC! Failed to create expose region.\n"); + fprintf(stderr, "%s: PANIC! Failed to create expose region.\n", __func__); #endif } } @@ -4155,7 +4129,7 @@ void nxagentForwardRemoteExpose(void) if (RegionNotEmpty(nxagentRemoteExposeRegion)) { #ifdef DEBUG - fprintf(stderr, "nxagentForwardRemoteExpose: Going to forward events.\n"); + fprintf(stderr, "%s: Going to forward events.\n", __func__); #endif TraverseTree(screenInfo.screens[0]->root, nxagentClipAndSendExpose, (void *)nxagentRemoteExposeRegion); @@ -4189,7 +4163,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) RegionPtr remoteExposeRgn = (RegionRec *) ptr; #ifdef DEBUG - fprintf(stderr, "nxagentClipAndSendExpose: Called.\n"); + fprintf(stderr, "%s: Called.\n", __func__); #endif if (pWin -> drawable.class != InputOnly) @@ -4199,12 +4173,12 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) #ifdef DEBUG BoxRec box = *RegionExtents(remoteExposeRgn); - fprintf(stderr, "nxagentClipAndSendExpose: Root expose extents: [%d] [%d] [%d] [%d].\n", + fprintf(stderr, "%s: Root expose extents: [%d] [%d] [%d] [%d].\n", __func__, box.x1, box.y1, box.x2, box.y2); box = *RegionExtents(&pWin -> clipList); - fprintf(stderr, "nxagentClipAndSendExpose: Clip list extents for window at [%p]: [%d] [%d] [%d] [%d].\n", + fprintf(stderr, "%s: Clip list extents for window at [%p]: [%d] [%d] [%d] [%d].\n", __func__, (void *)pWin, box.x1, box.y1, box.x2, box.y2); #endif @@ -4213,7 +4187,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) if (RegionNotEmpty(exposeRgn)) { #ifdef DEBUG - fprintf(stderr, "nxagentClipAndSendExpose: Forwarding expose to window at [%p] pWin.\n", + fprintf(stderr, "%s: Forwarding expose to window at [%p] pWin.\n", __func__, (void *)pWin); #endif @@ -4233,7 +4207,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) if (RegionNotEmpty(remoteExposeRgn)) { #ifdef DEBUG - fprintf(stderr, "nxagentClipAndSendExpose: Region not empty. Walk children.\n"); + fprintf(stderr, "%s: Region not empty. Walk children.\n", __func__); #endif return WT_WALKCHILDREN; @@ -4241,7 +4215,7 @@ int nxagentClipAndSendExpose(WindowPtr pWin, void * ptr) else { #ifdef DEBUG - fprintf(stderr, "nxagentClipAndSendExpose: Region empty. Stop walking.\n"); + fprintf(stderr, "%s: Region empty. Stop walking.\n", __func__); #endif return WT_STOPWALKING; @@ -4296,7 +4270,7 @@ int nxagentUserInput(void *p) nxagentKeyDown > 0)) { #ifdef TEST - fprintf(stderr, "nxagentUserInput: Buttons [%d] Keys [%d].\n", + fprintf(stderr, "%s: Buttons [%d] Keys [%d].\n", __func__, inputInfo.pointer -> button -> buttonsDown, nxagentKeyDown); #endif @@ -4312,7 +4286,7 @@ int nxagentHandleRRScreenChangeNotify(XEvent *X) XRRScreenChangeNotifyEvent *Xr = (XRRScreenChangeNotifyEvent *) X; #ifdef DEBUG - fprintf(stderr, "nxagentHandleRRScreenChangeNotify called.\n"); + fprintf(stderr, "%s: Called.\n", __func__); #endif nxagentResizeScreen(screenInfo.screens[DefaultScreen(nxagentDisplay)], Xr -> width, Xr -> height, @@ -4339,7 +4313,7 @@ int nxagentPendingEvents(Display *dpy) if (_XGetIOError(dpy) != 0) { #ifdef DEBUG - fprintf(stderr, "nxagentPendingEvents: Returning error with display down.\n"); + fprintf(stderr, "%s: Returning error with display down.\n", __func__); #endif return -1; @@ -4347,7 +4321,7 @@ int nxagentPendingEvents(Display *dpy) else if (XQLength(dpy) > 0) { #ifdef DEBUG - fprintf(stderr, "nxagentPendingEvents: Returning true with [%d] events queued.\n", + fprintf(stderr, "%s: Returning true with [%d] events queued.\n", __func__, XQLength(dpy)); #endif @@ -4362,7 +4336,7 @@ int nxagentPendingEvents(Display *dpy) if (readable > 0) { #ifdef DEBUG - fprintf(stderr, "nxagentPendingEvents: Returning true with [%d] bytes readable.\n", + fprintf(stderr, "%s: Returning true with [%d] bytes readable.\n", __func__, readable); #endif @@ -4370,7 +4344,7 @@ int nxagentPendingEvents(Display *dpy) } #ifdef DEBUG - fprintf(stderr, "nxagentPendingEvents: Returning false with [%d] bytes readable.\n", + fprintf(stderr, "%s: Returning false with [%d] bytes readable.\n", __func__, readable); #endif @@ -4378,7 +4352,7 @@ int nxagentPendingEvents(Display *dpy) } #ifdef TEST - fprintf(stderr, "nxagentPendingEvents: WARNING! Error detected on the X display.\n"); + fprintf(stderr, "%s: WARNING! Error detected on the X display.\n", __func__); #endif NXForceDisplayError(dpy); @@ -4394,7 +4368,7 @@ int nxagentPendingEvents(Display *dpy) int nxagentWaitEvents(Display *dpy, useconds_t msec) { #ifdef DEBUG - fprintf(stderr, "nxagentWaitEvents called.\n"); + fprintf(stderr, "%s: Called.\n", __func__); #endif NXFlushDisplay(dpy, NXFlushLink); -- cgit v1.2.3 From e74eb76525630c5c6455880c2149b7db2355216d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 30 Oct 2019 23:00:00 +0100 Subject: Events.c: fix format specifiers --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 7c53cbf3f..b9d3a9238 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -1503,12 +1503,12 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already WindowPtr pWin; #ifdef DEBUG - fprintf(stderr, "%s: Going to handle new FocusIn event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); + fprintf(stderr, "%s: Going to handle new FocusIn event [0x%lx] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); { XlibWindow w; int revert_to; XGetInputFocus(nxagentDisplay, &w, &revert_to); - fprintf(stderr, "%s: (FocusIn): Event win [0x%x] Focus owner [0x%x] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]); + fprintf(stderr, "%s: (FocusIn): Event win [0x%lx] Focus owner [0x%lx] nxagentDefaultWindows[0] [0x%x]\n", __func__, X.xfocus.window, w, nxagentDefaultWindows[0]); } #else #ifdef TEST @@ -1561,7 +1561,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was not already case FocusOut: { #ifdef DEBUG - fprintf(stderr, "%s: Going to handle new FocusOut event [0x%x] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); + fprintf(stderr, "%s: Going to handle new FocusOut event [0x%lx] mode: [%s]\n", __func__, X.xfocus.window, nxagentGetNotifyMode(X.xfocus.mode)); #else #ifdef TEST fprintf(stderr, "%s: Going to handle new FocusOut event.\n", __func__); @@ -2856,8 +2856,8 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) fprintf(stderr, "%s: CurrentSelections[i].lastTimeChanged [%d]\n", __func__, CurrentSelections[i].lastTimeChanged.milliseconds); fprintf(stderr, "%s: Event timestamp [%ld]\n", __func__, xfixesEvent->xfixesselection.timestamp); fprintf(stderr, "%s: Event selection timestamp [%ld]\n", __func__, xfixesEvent->xfixesselection.selection_timestamp); - fprintf(stderr, "%s: Event selection window [0x%x]\n", __func__, xfixesEvent->xfixesselection.window); - fprintf(stderr, "%s: Event selection owner [0x%x]\n", __func__, xfixesEvent->xfixesselection.owner); + fprintf(stderr, "%s: Event selection window [0x%lx]\n", __func__, xfixesEvent->xfixesselection.window); + fprintf(stderr, "%s: Event selection owner [0x%lx]\n", __func__, xfixesEvent->xfixesselection.owner); fprintf(stderr, "%s: Event selection [%s]\n", __func__, NameForAtom(nxagentRemoteToLocalAtom(xfixesEvent->xfixesselection.selection))); fprintf(stderr, "%s: Subtype ", __func__); -- cgit v1.2.3 From f469ac534f917b9c9cc32e8a66c253dc39418f9f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:28:18 +0200 Subject: Image.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index 890706ba5..dcd7c49c0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -100,8 +100,8 @@ extern void nxagentTwoByteSwap(unsigned char *, register int); extern void nxagentFourByteSwap(register unsigned char *, register int); /* - * Store the last visual used to unpack - * the images for the given client. + * Store the last visual used to unpack the images for the given + * client. */ static VisualID nxagentUnpackVisualId[MAX_CONNECTIONS]; @@ -114,7 +114,6 @@ typedef struct _UnpackAlpha { char *data; int size; - } UnpackAlphaRec; typedef UnpackAlphaRec *UnpackAlphaPtr; @@ -688,14 +687,12 @@ FIXME: Temporarily stream the GLX data. if (split == 1 && (nxagentSplitTrap == 1 || depth < 15)) { #ifdef TEST - if (nxagentSplitTrap == 1 || nxagentReconnectTrap == 1) { fprintf(stderr, "nxagentPutImage: Not splitting with reconnection [%d] trap [%d] " "depth [%d].\n", nxagentSplitTrap, nxagentReconnectTrap, depth); } - #endif split = 0; @@ -722,7 +719,6 @@ FIXME: Temporarily stream the GLX data. "link [%d] GLX [%d] Xv [%d].\n", length, nxagentOption(LinkType), nxagentGlxTrap, nxagentXvTrap); } - #endif /* @@ -831,9 +827,8 @@ FIXME: Should probably intersect the region with the region being } /* - * The split value could be changed by a - * no-split event in the block above, so - * here we have to check the value again. + * The split value could be changed by a no-split event in the block + * above, so here we have to check the value again. */ if (split == 0) @@ -910,8 +905,7 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, } /* - * Get the visual according to the - * drawable and depth. + * Get the visual according to the drawable and depth. */ pVisual = nxagentImageVisual(pDrawable, depth); -- cgit v1.2.3 From 5d3029a6ccfb2226bdf0ffa5dedb6880ef832e5e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:29:04 +0200 Subject: Image.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 36 +++++++++++------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index dcd7c49c0..a655e1428 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -875,12 +875,6 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *data) { - int length; - - int bytesPerLine; - int numSubImages; - int totalHeight; - /* * NXPutPackedImage is longer than PutPackedImage so that we * subtract the bigger one to be sure. @@ -923,21 +917,21 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, * Get bytes per line according to format. */ - bytesPerLine = nxagentImagePad(w, format, leftPad, depth); + int bytesPerLine = nxagentImagePad(w, format, leftPad, depth); if (nxagentOption(Shadow) == 1 && format == ZPixmap && (nxagentOption(XRatio) != DONT_SCALE || nxagentOption(YRatio) != DONT_SCALE) && pDrawable == (DrawablePtr) nxagentShadowPixmapPtr) { - int scaledx; - int scaledy; - image = XCreateImage(nxagentDisplay, pVisual, depth, ZPixmap, 0, data, w, h, BitmapPad(nxagentDisplay), bytesPerLine); if (image != NULL) { + int scaledx; + int scaledy; + image -> byte_order = IMAGE_BYTE_ORDER; image -> bitmap_bit_order = BITMAP_BIT_ORDER; @@ -972,13 +966,13 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, goto nxagentRealizeImageEnd; } - totalHeight = h; + int totalHeight = h; - length = bytesPerLine * h; + int length = bytesPerLine * h; h = (subSize < length ? subSize : length) / bytesPerLine; - numSubImages = totalHeight / h + 1; + int numSubImages = totalHeight / h + 1; while (numSubImages > 0) { @@ -1635,10 +1629,9 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, #else - char *srcPixel = &image -> data[(j * image -> bytes_per_line) + - ((i * image -> bits_per_pixel) >> 3)]; - - char *dstPixel = (char *) &val; + char * srcPixel = &image -> data[(j * image -> bytes_per_line) + + ((i * image -> bits_per_pixel) >> 3)]; + char * dstPixel = (char *) &val; val = 0; @@ -1691,15 +1684,12 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio, char *nxagentAllocateImageData(int width, int height, int depth, int *length, int *format) { - int leftPad = 0; - *format = (depth == 1) ? XYPixmap : ZPixmap; - *length = nxagentImageLength(width, height, *format, leftPad, depth); + *length = nxagentImageLength(width, height, *format, 0, depth); - char *data = NULL; - - if ((data = malloc(*length)) == NULL) + char *data = malloc(*length); + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentAllocateImageData: WARNING! Failed to allocate [%d] bytes of memory.\n", *length); -- cgit v1.2.3 From 129c8621fd3f6f1ef2190f0a17c7eb6fef53a603 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:29:52 +0200 Subject: Image.c: remove some blank lines --- nx-X11/programs/Xserver/hw/nxagent/Image.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Image.c b/nx-X11/programs/Xserver/hw/nxagent/Image.c index a655e1428..34d5cf9f9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Image.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Image.c @@ -171,7 +171,6 @@ typedef struct _ImageStatisticsRec double totalMatches; double totalEncoded; double totalAdded; - } ImageStatisticsRec; ImageStatisticsRec nxagentImageStatistics; @@ -256,7 +255,6 @@ int nxagentImageLength(int width, int height, int format, int leftPad, int depth else if (format == XYPixmap) { line = BitmapBytePad(width + leftPad); - line *= depth; } else if (format == ZPixmap) @@ -706,7 +704,6 @@ FIXME: Temporarily stream the GLX data. #endif #ifdef TEST - if (split == 1) { fprintf(stderr, "nxagentPutImage: Splitting the image with size [%d] " @@ -888,7 +885,6 @@ void nxagentRealizeImage(DrawablePtr pDrawable, GCPtr pGC, int depth, XImage *image = NULL; - if (NXDisplayError(nxagentDisplay) == 1) { #ifdef TEST -- cgit v1.2.3 From e72e2375ffcb7625d2c322d4d58965d06a630c8e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:40:03 +0200 Subject: Cursor.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 55 +++++++++++++---------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index 34672fef5..5346efd90 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -93,11 +93,8 @@ extern CursorPtr GetSpriteCursor(void); void nxagentConstrainCursor(ScreenPtr pScreen, BoxPtr pBox) { #ifdef TEST - - int width, height; - - width = nxagentOption(RootWidth); - height = nxagentOption(RootHeight); + int width = nxagentOption(RootWidth); + int height = nxagentOption(RootHeight); if (pBox->x1 <= 0 && pBox->y1 <= 0 && pBox->x2 >= width && pBox->y2 >= height) @@ -150,18 +147,14 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) fprintf(stderr, "nxagentRealizeCursor: Called for cursor at [%p].\n", (void *) pCursor); #endif - unsigned long valuemask = GCFunction | - GCPlaneMask | - GCForeground | - GCBackground | - GCClipMask; + unsigned long valuemask = GCFunction | GCPlaneMask | GCForeground | GCBackground | GCClipMask; XGCValues values = { - .function = GXcopy, - .plane_mask = AllPlanes, - .foreground = 1L, - .background = 0L, - .clip_mask = None + .function = GXcopy, + .plane_mask = AllPlanes, + .foreground = 1L, + .background = 0L, + .clip_mask = None, }; XChangeGC(nxagentDisplay, nxagentBitmapGC, valuemask, &values); @@ -221,15 +214,15 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) SAFE_XFree(image); XColor fg_color = { - .red = pCursor->foreRed, - .green = pCursor->foreGreen, - .blue = pCursor->foreBlue + .red = pCursor->foreRed, + .green = pCursor->foreGreen, + .blue = pCursor->foreBlue, }; XColor bg_color = { - .red = pCursor->backRed, - .green = pCursor->backGreen, - .blue = pCursor->backBlue + .red = pCursor->backRed, + .green = pCursor->backGreen, + .blue = pCursor->backBlue, }; pCursor->devPriv[pScreen->myNum] = (void *) malloc(sizeof(nxagentPrivCursor)); @@ -275,15 +268,15 @@ void nxagentRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed) { XColor fg_color = { - .red = pCursor->foreRed, - .green = pCursor->foreGreen, - .blue = pCursor->foreBlue + .red = pCursor->foreRed, + .green = pCursor->foreGreen, + .blue = pCursor->foreBlue, }; XColor bg_color = { - .red = pCursor->backRed, - .green = pCursor->backGreen, - .blue = pCursor->backBlue + .red = pCursor->backRed, + .green = pCursor->backGreen, + .blue = pCursor->backBlue, }; XRecolorCursor(nxagentDisplay, @@ -404,7 +397,7 @@ Bool nxagentReconnectAllCursor(void *p0) fprintf(stderr, "nxagentReconnectAllCursor\n"); #endif - for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { @@ -514,7 +507,7 @@ Bool nxagentDisconnectAllCursor(void) fprintf(stderr, "nxagentDisconnectAllCursor: Going to iterate through cursor resources.\n"); #endif - for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { @@ -558,9 +551,9 @@ void nxagentListCursor(void *p0, void *p1, void *p2) void nxagentListCursors(void) { - Bool r; + Bool r = True; - for (int i = 0, r = 1; i < MAXCLIENTS; r = 1, i++) + for (int i = 0; i < MAXCLIENTS; r = 1, i++) { if (clients[i]) { -- cgit v1.2.3 From 631092bb006f646c3b0d51c7b50deeb2a2ea927e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:40:45 +0200 Subject: Cursor.c: remove some blank lines --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index 5346efd90..2b4728736 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -107,7 +107,6 @@ void nxagentConstrainCursor(ScreenPtr pScreen, BoxPtr pBox) fprintf(stderr, "nxagentConstrainCursor: WARNING! Called with box [%d,%d,%d,%d].\n", pBox->x1, pBox->y1, pBox->x2, pBox->y2); } - #endif } @@ -300,7 +299,6 @@ Bool nxagentSetCursorPosition(ScreenPtr pScreen, int x, int y, * Calling miSetCursorPosition with generateEvent == 0 causes a * crash in miPoiterUpdate(). */ - return 1; } } @@ -404,13 +402,11 @@ Bool nxagentReconnectAllCursor(void *p0) FindClientResourcesByType(clients[i], RT_CURSOR, nxagentReconnectCursor, &r); #ifdef WARNING - if (r == False) { fprintf(stderr, "nxagentReconnectAllCursor: WARNING! Failed to recreate " "cursor for client [%d].\n", i); } - #endif } } @@ -514,13 +510,11 @@ Bool nxagentDisconnectAllCursor(void) FindClientResourcesByType(clients[i], RT_CURSOR, nxagentDisconnectCursor, &r); #ifdef WARNING - if (r == False) { fprintf(stderr, "nxagentDisconnectAllCursor: WARNING! Failed to disconnect " "cursor for client [%d].\n", i); } - #endif } } @@ -560,13 +554,11 @@ void nxagentListCursors(void) FindClientResourcesByType(clients[i], RT_CURSOR, nxagentListCursor, &r); #ifdef WARNING - if (r == False) { fprintf(stderr, "nxagentListCursors: WARNING! Failed to list " "cursor for client [%d].\n", i); } - #endif } } -- cgit v1.2.3 From 5275d2d03f636092c310a9249062125ec9201c64 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 30 Oct 2019 23:53:03 +0100 Subject: Cursor.c: use __func__ in fprintf calls --- nx-X11/programs/Xserver/hw/nxagent/Cursor.c | 67 +++++++++++++---------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index 2b4728736..0c667a00c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -99,12 +99,12 @@ void nxagentConstrainCursor(ScreenPtr pScreen, BoxPtr pBox) if (pBox->x1 <= 0 && pBox->y1 <= 0 && pBox->x2 >= width && pBox->y2 >= height) { - fprintf(stderr, "nxagentConstrainCursor: Called with box [%d,%d,%d,%d]. " - "Skipping the operation.\n", pBox->x1, pBox->y1, pBox->x2, pBox->y2); + fprintf(stderr, "%s: Called with box [%d,%d,%d,%d]. Skipping the operation.\n", + __func__, pBox->x1, pBox->y1, pBox->x2, pBox->y2); } else { - fprintf(stderr, "nxagentConstrainCursor: WARNING! Called with box [%d,%d,%d,%d].\n", + fprintf(stderr, "%s: WARNING! Called with box [%d,%d,%d,%d].\n", __func__, pBox->x1, pBox->y1, pBox->x2, pBox->y2); } #endif @@ -132,7 +132,7 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) cursor); #ifdef TEST - fprintf(stderr, "nxagentDisplayCursor: Called for cursor at [%p] with private [%p].\n", + fprintf(stderr, "%s: Called for cursor at [%p] with private [%p].\n", __func__, (void *) pCursor, pCursor->devPriv[pScreen->myNum]); #endif } @@ -143,7 +143,7 @@ Bool nxagentDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { #ifdef TEST - fprintf(stderr, "nxagentRealizeCursor: Called for cursor at [%p].\n", (void *) pCursor); + fprintf(stderr, "%s: Called for cursor at [%p].\n", __func__, (void *) pCursor); #endif unsigned long valuemask = GCFunction | GCPlaneMask | GCForeground | GCBackground | GCClipMask; @@ -233,7 +233,7 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) nxagentCursorUsesRender(pCursor, pScreen) = 0; #ifdef TEST - fprintf(stderr, "nxagentRealizeCursor: Set cursor private at [%p] cursor is [%ld].\n", + fprintf(stderr, "%s: Set cursor private at [%p] cursor is [%ld].\n", __func__, (void *) nxagentCursorPriv(pCursor, pScreen), nxagentCursorPriv(pCursor, pScreen) -> cursor); #endif @@ -308,12 +308,8 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) Bool* pBool = (Bool*)p2; CursorPtr pCursor = (CursorPtr) p0; - #ifdef TEST - fprintf(stderr, "nxagentReconnectCursor: pCursor at [%p]\n", pCursor); - #endif - - #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG - fprintf(stderr, "nxagentReconnectCursor: pCursor at [%p]\n", pCursor); + #if defined( TEST) || defined(NXAGENT_RECONNECT_CURSOR_DEBUG) + fprintf(stderr, "%s: pCursor at [%p]\n", __func__, pCursor); #endif if (!*pBool || !pCursor) @@ -326,7 +322,7 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) if (nxagentIsAnimCursor(pCursor)) { #ifdef TEST - fprintf(stderr, "nxagentReconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor); + fprintf(stderr, "%s: nxagentIsAnimCursor pCursor at [%p]\n", __func__, pCursor); #endif AnimCurPtr ac = nxagentGetAnimCursor(pCursor); @@ -336,12 +332,11 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) nxagentReconnectCursor (ac->elts[j].pCursor, x1, p2); #ifdef TEST - fprintf(stderr, "nxagentReconnectCursor: Iteration [%d] pCursor at [%p]\n", j, ac->elts[j].pCursor); + fprintf(stderr, "%s: Iteration [%d] pCursor at [%p]\n", __func__, j, ac->elts[j].pCursor); #endif } } } - else { if (nxagentCursorUsesRender(pCursor, nxagentDefaultScreen)) @@ -358,14 +353,14 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) free(nxagentCursorPriv(pCursor, nxagentDefaultScreen)); if (!nxagentRealizeCursor(nxagentDefaultScreen, pCursor)) { - fprintf(stderr, "nxagentReconnectCursor: nxagentRealizeCursor failed\n"); + fprintf(stderr, "%s: nxagentRealizeCursor failed\n", __func__); *pBool = False; } } } #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG - fprintf(stderr, "nxagentReconnectCursor: %p - ID %lx\n", pCursor, nxagentCursor(pCursor, nxagentDefaultScreen)); + fprintf(stderr, "%s: %p - ID %lx\n", __func__, pCursor, nxagentCursor(pCursor, nxagentDefaultScreen)); #endif } @@ -392,7 +387,7 @@ Bool nxagentReconnectAllCursor(void *p0) GrabPtr grab = inputInfo.pointer -> grab; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_CURSOR_DEBUG) - fprintf(stderr, "nxagentReconnectAllCursor\n"); + fprintf(stderr, "%s\n", __func__); #endif for (int i = 0; i < MAXCLIENTS; r = 1, i++) @@ -404,8 +399,8 @@ Bool nxagentReconnectAllCursor(void *p0) #ifdef WARNING if (r == False) { - fprintf(stderr, "nxagentReconnectAllCursor: WARNING! Failed to recreate " - "cursor for client [%d].\n", i); + fprintf(stderr, "%s: WARNING! Failed to recreate " + "cursor for client [%d].\n", __func__, i); } #endif } @@ -434,7 +429,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) if (nxagentIsAnimCursor(pCursor)) { #ifdef TEST - fprintf(stderr, "nxagentDisconnectCursor: nxagentIsAnimCursor pCursor at [%p]\n", pCursor); + fprintf(stderr, "%s: nxagentIsAnimCursor pCursor at [%p]\n", __func__, pCursor); #endif AnimCurPtr ac = nxagentGetAnimCursor(pCursor); @@ -444,7 +439,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) nxagentDisconnectCursor (ac->elts[j].pCursor, x1, p2); #ifdef TEST - fprintf(stderr, "nxagentDisconnectCursor: Iteration [%d] pCursor at [%p]\n", j, ac->elts[j].pCursor); + fprintf(stderr, "%s: Iteration [%d] pCursor at [%p]\n", __func__, j, ac->elts[j].pCursor); #endif } } @@ -452,29 +447,28 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) } #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG - fprintf(stderr, "nxagentDisconnectCursor: %p - ID %lx\n", - pCursor, - nxagentCursor(pCursor, nxagentDefaultScreen)); + fprintf(stderr, "%s: %p - ID %lx\n", __func__, pCursor, + nxagentCursor(pCursor, nxagentDefaultScreen)); #endif #ifdef TEST - fprintf(stderr, "nxagentDisconnectCursor: Called with bool [%d].\n", *pBool); + fprintf(stderr, "%s: Called with bool [%d].\n", __func__, *pBool); - fprintf(stderr, "nxagentDisconnectCursor: Pointer to cursor is [%p] with counter [%d].\n", + fprintf(stderr, "%s: Pointer to cursor is [%p] with counter [%d].\n", __func__, (void *) pCursor, pCursor -> refcnt); - fprintf(stderr, "nxagentDisconnectCursor: Dummy screen is at [%p].\n", + fprintf(stderr, "%s: Dummy screen is at [%p].\n", __func__, (void *) nxagentDefaultScreen); - fprintf(stderr, "nxagentDisconnectCursor: Cursor private is at [%p].\n", + fprintf(stderr, "%s: Cursor private is at [%p].\n", __func__, (void *) nxagentCursorPriv(pCursor, nxagentDefaultScreen)); #endif #ifdef TEST - fprintf(stderr, "nxagentDisconnectCursor: Dummy screen number is [%d].\n", + fprintf(stderr, "%s: Dummy screen number is [%d].\n", __func__, nxagentDefaultScreen -> myNum); - fprintf(stderr, "nxagentDisconnectCursor: Cursor is [%ld].\n", + fprintf(stderr, "%s: Cursor is [%ld].\n", __func__, nxagentCursor(pCursor, nxagentDefaultScreen)); #endif @@ -486,7 +480,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) int ret = 1; #if defined(NXAGENT_RECONNECT_CURSOR_DEBUG) || defined(NXAGENT_RECONNECT_PICTURE_DEBUG) - fprintf(stderr, "nxagentDisconnectCursor: disconnecting attached picture %p\n", pPicture); + fprintf(stderr, "%s: disconnecting attached picture %p\n", __func__, pPicture); #endif nxagentDisconnectPicture(pPicture, 0, &ret); @@ -500,7 +494,7 @@ Bool nxagentDisconnectAllCursor(void) GrabPtr grab = inputInfo.pointer -> grab; #ifdef TEST - fprintf(stderr, "nxagentDisconnectAllCursor: Going to iterate through cursor resources.\n"); + fprintf(stderr, "%s: Going to iterate through cursor resources.\n", __func__); #endif for (int i = 0; i < MAXCLIENTS; r = 1, i++) @@ -512,8 +506,8 @@ Bool nxagentDisconnectAllCursor(void) #ifdef WARNING if (r == False) { - fprintf(stderr, "nxagentDisconnectAllCursor: WARNING! Failed to disconnect " - "cursor for client [%d].\n", i); + fprintf(stderr, "%s: WARNING! Failed to disconnect " + "cursor for client [%d].\n", __func__, i); } #endif } @@ -556,8 +550,7 @@ void nxagentListCursors(void) #ifdef WARNING if (r == False) { - fprintf(stderr, "nxagentListCursors: WARNING! Failed to list " - "cursor for client [%d].\n", i); + fprintf(stderr, "%s: WARNING! Failed to list cursor for client [%d].\n", __func__, i); } #endif } -- cgit v1.2.3 From ab7113b79d6495fd248bd84ee3716ca09e6ad032 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:48:04 +0200 Subject: BitmapUtils.c: remove tailing whitespace --- nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c index b889d2a62..567c1c302 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c +++ b/nx-X11/programs/Xserver/hw/nxagent/BitmapUtils.c @@ -115,4 +115,3 @@ nxagentFourByteSwap(unsigned char *buf, int nbytes) buf[2] = c; } } - -- cgit v1.2.3 From 560b7c6c210e905384af8a1503d13d10c79ddafc Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:53:31 +0200 Subject: Client.c: remove tailing whitespace --- nx-X11/programs/Xserver/hw/nxagent/Client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index 6568859d1..e04a03dc1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -527,5 +527,4 @@ void nxagentCheckRestartedClients(struct timeval **timeout) } } } - #endif -- cgit v1.2.3 From dbe3cc1f73d717aea9dc37262523c079e368e27a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:54:46 +0200 Subject: Composite.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Composite.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.c b/nx-X11/programs/Xserver/hw/nxagent/Composite.c index e48671879..40e4af8a0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Composite.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.c @@ -44,8 +44,7 @@ #undef DEBUG /* - * Set if the composite extension is supported - * by the remote display. + * Set if the composite extension is supported by the remote display. */ int nxagentCompositeEnable = UNDEFINED; @@ -53,8 +52,7 @@ int nxagentCompositeEnable = UNDEFINED; void nxagentCompositeExtensionInit(void) { /* - * Set the flag only if the initialization - * completes. + * Set the flag only if the initialization completes. */ nxagentCompositeEnable = 0; @@ -70,8 +68,8 @@ void nxagentCompositeExtensionInit(void) if (XCompositeQueryExtension(nxagentDisplay, &eventBase, &errorBase) == 1) { /* - * At the moment we don't need to care - * the version of the extension. + * At the moment we don't need to care the version of the + * extension. */ #ifdef TEST @@ -143,13 +141,12 @@ void nxagentRedirectDefaultWindows(void) #endif /* - * When trying to redirect only the top level window, - * and not the subwindows, we incur in a strange be- - * haviour. The top level is unmapped, mapped, unmap- - * ped and then reparented. This at first makes the - * agent think that the window manager is gone, then - * the agent window disappears. To make thinks even - * more weird, this happens only at reconnection. + * When trying to redirect only the top level window, and not the + * subwindows, we incur in a strange be- haviour. The top level is + * unmapped, mapped, unmap- ped and then reparented. This at first + * makes the agent think that the window manager is gone, then the + * agent window disappears. To make thinks even more weird, this + * happens only at reconnection. */ XCompositeRedirectSubwindows(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], -- cgit v1.2.3 From 8836547418f29a01e10c38316a4dc6751266dd30 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:54:57 +0200 Subject: Composite.c: scope improvement --- nx-X11/programs/Xserver/hw/nxagent/Composite.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Composite.c b/nx-X11/programs/Xserver/hw/nxagent/Composite.c index 40e4af8a0..af29f8ebc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Composite.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Composite.c @@ -115,8 +115,6 @@ void nxagentCompositeExtensionInit(void) void nxagentRedirectDefaultWindows(void) { - int i; - if (nxagentOption(Rootless) == 1 || nxagentCompositeEnable == 0) { @@ -129,7 +127,7 @@ void nxagentRedirectDefaultWindows(void) return; } - for (i = 0; i < screenInfo.numScreens; i++) + for (int i = 0; i < screenInfo.numScreens; i++) { WindowPtr pWin = screenInfo.screens[i]->root; -- cgit v1.2.3 From fab0e477eee2d54d5b550a3d5f3de25638b52318 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:58:44 +0200 Subject: Dialog.c: shorten switch blocks --- nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index ccea93a92..def3c86c5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -294,7 +294,6 @@ void nxagentLaunchDialog(DialogType dialogType) #ifdef WARNING fprintf(stderr, "nxagentLaunchDialog: Unknown Dialog type [%d].\n", dialogType); #endif - return; } } @@ -524,7 +523,6 @@ void nxagentTerminateDialog(DialogType type) #ifdef WARNING fprintf(stderr, "nxagentTerminateDialog: Unknown dialog type [%d].\n", type); #endif - return; } } -- cgit v1.2.3 From 7e8f638a966e3c17db4ad1be2f1e6e0021886423 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Sep 2019 23:59:26 +0200 Subject: Dialog.c: use designated initializer --- nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index def3c86c5..c20a6a475 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -376,10 +376,10 @@ void nxagentFailedReconnectionDialog(int alert, char *error) while (NXDisplayError(nxagentDisplay) == 0 && NXTransRunning(NX_FD_ANY) == 1) { - struct timeval timeout; - - timeout.tv_sec = 30; - timeout.tv_usec = 0; + struct timeval timeout = { + .tv_sec = 30, + .tv_usec = 0, + }; NXTransContinue(&timeout); } -- cgit v1.2.3 From 88e3a37ad7abfa6e7172d7f84cae05c36b7c3d26 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 00:28:14 +0200 Subject: Display.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 79 +++++++++++++--------------- 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 50f85b257..2fb8d4960 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -152,8 +152,8 @@ Drawable nxagentDefaultDrawables[MAXDEPTH + 1]; Pixmap nxagentScreenSaverPixmap; /* - * Also used in Cursor.c. There are huge problems - * using GC definition. This is to be reworked. + * Also used in Cursor.c. There are huge problems using GC + * definition. This is to be reworked. */ XlibGC nxagentBitmapGC; @@ -1188,9 +1188,8 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio DefaultScreenOfDisplay(nxagentDisplay)); /* - * Processing the arguments all the timeouts - * have been set. Now we have to change the - * screen-saver timeout. + * Processing the arguments all the timeouts have been set. Now we + * have to change the screen-saver timeout. */ nxagentSetScreenSaverTime(); @@ -1286,7 +1285,7 @@ FIXME: Use of nxagentParentWindow is strongly deprecated. We need nxagentBitmapGC = XCreateGC(nxagentDisplay, nxagentDefaultDrawables[1], 0L, NULL); /* - * Note that this "confine windoqw" is useless at the moment as we + * Note that this "confine window" is useless at the moment as we * reimplement nxagentConstrainCursor() to skip the "constrain" * stuff. */ @@ -1918,14 +1917,13 @@ static int nxagentCheckForDefaultDepthCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the old and new default depth values - * must match exactly. - * - Safe or Risky means that the default depth values might differ, - * but the new default depth value must be at least as - * high as the former default depth value. This is - * recommended, because it allows clients with a - * higher default depth value to still connect, but - * not lose functionality. + * - Strict means that the old and new default depth values must + * match exactly. + * - Safe or Risky means that the default depth values might + * differ, but the new default depth value must be at least as + * high as the former default depth value. This is recommended, + * because it allows clients with a higher default depth value + * to still connect, but not lose functionality. * - Bypass means that all of these checks are essentially * deactivated. This is probably a very bad idea. */ @@ -1982,18 +1980,16 @@ static int nxagentCheckForDepthsCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the number of old and new depths must - * match exactly and every old depth value must be - * available in the new depth array. - * - Safe means that the number of depths might diverge, - * but all former depth must also be included in the - * new depth array. This is recommended, because - * it allows clients with more depths to still - * connect, but not lose functionality. + * - Strict means that the number of old and new depths must match + * exactly and every old depth value must be available in the + * new depth array. + * - Safe means that the number of depths might diverge, but all + * former depth must also be included in the new depth + * array. This is recommended, because it allows clients with + * more depths to still connect, but not lose functionality. * - Risky means that the new depths array is allowed to be - * smaller than the old depths array, but at least - * one depth value must be included in both. - * This is potentially unsafe. + * smaller than the old depths array, but at least one depth + * value must be included in both. This is potentially unsafe. * - Bypass or higher means that all of these checks are * essentially deactivated. This is a very bad idea. */ @@ -2140,20 +2136,18 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) /* * Depending on the (reconnect) tolerance checks value, this * function checks stricter or looser: - * - Strict means that the number of internal and external - * pixmap formats must match exactly and every - * internal pixmap format must be available in the - * external pixmap format array. - * - Safe means that the number of pixmap formats might - * diverge, but all internal pixmap formats must - * also be included in the external pixmap formats - * array. This is recommended, because it allows - * clients with more pixmap formats to still connect, + * - Strict means that the number of internal and external pixmap + * formats must match exactly and every internal pixmap format + * must be available in the external pixmap format array. + * - Safe means that the number of pixmap formats might diverge, + * but all internal pixmap formats must also be included in the + * external pixmap formats array. This is recommended, because + * it allows clients with more pixmap formats to still connect, * but not lose functionality. - * - Risky means that the internal pixmap formats array is - * allowed to be smaller than the external pixmap - * formats array, but at least one pixmap format must - * be included in both. This is potentially unsafe. + * - Risky means that the internal pixmap formats array is allowed + * to be smaller than the external pixmap formats array, but at + * least one pixmap format must be included in both. This is + * potentially unsafe. * - Bypass or higher means that all of these checks are * essentially deactivated. This is a very bad idea. */ @@ -2709,11 +2703,10 @@ void nxagentWaitDisplay(void) } /* - * This has not to do with the remote display but - * with the X server that the agent is impersonating. - * We have it here to be consistent with the other - * cleanup procedures which have mainly to do with - * the Xlib display connection. + * This has not to do with the remote display but with the X server + * that the agent is impersonating. We have it here to be consistent + * with the other cleanup procedures which have mainly to do with the + * Xlib display connection. */ void nxagentAbortDisplay(void) -- cgit v1.2.3 From 462ad036e5d0414150f36f074be4ecb7f0ae7339 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 00:29:14 +0200 Subject: Display.c: code simplification, scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 45 +++++++++++----------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 2fb8d4960..51d75fefb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -561,8 +561,6 @@ static void nxagentSigchldHandler(int signal) Display *nxagentInternalOpenDisplay(char *display) { - Display *newDisplay; - struct sigaction oldAction; struct sigaction newAction; @@ -606,7 +604,7 @@ FIXME: Should print a warning if the user tries to let the agent display); #endif - newDisplay = XOpenDisplay(display); + Display *newDisplay = XOpenDisplay(display); alarm(0); @@ -1413,15 +1411,11 @@ N/A void nxagentSetDefaultVisual(void) { - XVisualInfo vi; - - int i; - if (nxagentUserDefaultClass || nxagentUserDefaultDepth) { nxagentDefaultVisualIndex = UNDEFINED; - for (i = 0; i < nxagentNumVisuals; i++) + for (int i = 0; i < nxagentNumVisuals; i++) { if ((!nxagentUserDefaultClass || nxagentVisuals[i].class == nxagentDefaultClass) @@ -1430,7 +1424,6 @@ void nxagentSetDefaultVisual(void) nxagentVisuals[i].depth == nxagentDefaultDepth)) { nxagentDefaultVisualIndex = i; - break; } } @@ -1442,11 +1435,13 @@ void nxagentSetDefaultVisual(void) } else { + XVisualInfo vi = {0}; + vi.visualid = XVisualIDFromVisual(DefaultVisual(nxagentDisplay, DefaultScreen(nxagentDisplay))); nxagentDefaultVisualIndex = 0; - for (i = 0; i < nxagentNumVisuals; i++) + for (int i = 0; i < nxagentNumVisuals; i++) { if (vi.visualid == nxagentVisuals[i].visualid) { @@ -1458,13 +1453,14 @@ void nxagentSetDefaultVisual(void) void nxagentInitVisuals(void) { - long mask = VisualScreenMask; XVisualInfo vi = { .screen = DefaultScreen(nxagentDisplay), - .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)) + .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), }; + long mask = VisualScreenMask; int viNumList; XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, mask, &vi, &viNumList); + nxagentVisuals = (XVisualInfo *) malloc(viNumList * sizeof(XVisualInfo)); nxagentNumVisuals = 0; @@ -1612,7 +1608,7 @@ XXX: Some X server doesn't list 1 among available depths... fprintf(stderr, "nxagentInitPixmapFormats: Got [%d] available remote pixmap formats:\n", nxagentRemoteNumPixmapFormats); - for (i = 0; i < nxagentRemoteNumPixmapFormats; i++) + for (int i = 0; i < nxagentRemoteNumPixmapFormats; i++) { fprintf(stderr, "nxagentInitPixmapFormats: Remote pixmap format [%d]: depth [%d] " "bits_per_pixel [%d] scanline_pad [%d].\n", i, nxagentRemotePixmapFormats[i].depth, @@ -1882,9 +1878,7 @@ void nxagentDisconnectDisplay(void) case ALLOC_DEF_COLORMAP: if (nxagentDefaultColormaps) { - int i; - - for (i = 0; i < nxagentNumDefaultColormaps; i++) + for (int i = 0; i < nxagentNumDefaultColormaps; i++) { nxagentDefaultColormaps[i] = None; } @@ -2044,7 +2038,6 @@ static int nxagentCheckForDepthsCompatibility(void) bool compatible = true; bool one_match = false; - bool matched = false; int total_matches = 0; /* @@ -2066,7 +2059,7 @@ static int nxagentCheckForDepthsCompatibility(void) */ for (int i = 0; i < nxagentNumDepths; ++i) { - matched = false; + bool matched = false; for (int j = 0; j < nxagentNumDepthsRecBackup; ++j) { @@ -2200,12 +2193,11 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) */ bool compatible = true; - bool matched = false; int total_matches = 0; for (int i = 0; i < nxagentNumPixmapFormats; ++i) { - matched = false; + bool matched = false; for (int j = 0; j < nxagentRemoteNumPixmapFormats; ++j) { @@ -2267,22 +2259,22 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) static int nxagentInitAndCheckVisuals(int flexibility) { /* FIXME: does this also need work? */ - bool matched; - bool compatible = true; long viMask = VisualScreenMask; XVisualInfo viTemplate = { .screen = DefaultScreen(nxagentDisplay), - .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)) + .depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)), }; int viNumList; XVisualInfo *viList = XGetVisualInfo(nxagentDisplay, viMask, &viTemplate, &viNumList); XVisualInfo *newVisuals = malloc(sizeof(XVisualInfo) * nxagentNumVisuals); + bool compatible = true; + for (int i = 0; i < nxagentNumVisuals; i++) { - matched = false; + bool matched = false; for (int n = 0; n < viNumList; n++) { @@ -2386,7 +2378,6 @@ static int nxagentCheckForColormapsCompatibility(int flexibility) "doesn't match with old colormaps [%d].\n", nxagentNumDefaultColormaps, nxagentNumDefaultColormapsRecBackup); #endif - return 0; } } @@ -2633,9 +2624,7 @@ Bool nxagentReconnectDisplay(void *p0) void nxagentAddXConnection(void) { - int fd = XConnectionNumber(nxagentDisplay); - - nxagentXConnectionNumber = fd; + nxagentXConnectionNumber = XConnectionNumber(nxagentDisplay); #ifdef TEST fprintf(stderr, "nxagentAddXConnection: Adding the X connection [%d] " -- cgit v1.2.3 From 827defa14148cd8429f5863612aa9bf935d77cec Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 00:30:05 +0200 Subject: Display.c: remove blank lines --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 51d75fefb..a93fd2418 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1934,7 +1934,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void) "is [%d], former default depth value is [%d].\n", tolerance, ToleranceChecksBypass, dDepth, nxagentDefaultDepthRecBackup); #endif - return 1; } @@ -1944,7 +1943,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void) fprintf(stderr, "nxagentCheckForDefaultDepthCompatibility: New default depth [%d] " "matches with old default depth.\n", dDepth); #endif - return 1; } else if ((ToleranceChecksSafe <= tolerance) && (nxagentDefaultDepthRecBackup < dDepth)) @@ -1954,7 +1952,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void) "higher than the old default depth [%d] at tolerance [%u].\n", dDepth, nxagentDefaultDepthRecBackup, tolerance); #endif - return 1; } else @@ -1964,7 +1961,6 @@ static int nxagentCheckForDefaultDepthCompatibility(void) "doesn't match with old default depth [%d] at tolerance [%u].\n", dDepth, nxagentDefaultDepthRecBackup, tolerance); #endif - return 0; } } @@ -1998,7 +1994,6 @@ static int nxagentCheckForDepthsCompatibility(void) "is [%d], number of old depths is [%d].\n", tolerance, ToleranceChecksBypass, nxagentNumDepths, nxagentNumDepthsRecBackup); #endif - return 1; } @@ -2010,7 +2005,6 @@ static int nxagentCheckForDepthsCompatibility(void) "depths [%d].\n", nxagentNumDepths, nxagentNumDepthsRecBackup); #endif - return 0; } @@ -2022,7 +2016,6 @@ static int nxagentCheckForDepthsCompatibility(void) "lower than number of old depths [%d].\n", tolerance, nxagentNumDepths, nxagentNumDepthsRecBackup); #endif - return 0; } @@ -2155,7 +2148,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) "pixmap formats is [%d], number of externally available pixmap formats is [%d].\n", tolerance, ToleranceChecksBypass, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); #endif - return 1; } @@ -2166,7 +2158,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) "of internal pixmap formats [%d] doesn't match with number of remote formats [%d].\n", nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); #endif - return 0; } @@ -2177,7 +2168,6 @@ static int nxagentCheckForPixmapFormatsCompatibility(void) "and number of internal pixmap formats [%d] higher than number of external formats [%d].\n", tolerance, nxagentNumPixmapFormats, nxagentRemoteNumPixmapFormats); #endif - return 0; } @@ -2368,7 +2358,6 @@ static int nxagentCheckForColormapsCompatibility(int flexibility) fprintf(stderr, "nxagentCheckForColormapsCompatibility: Number of new colormaps [%d] " "matches with old colormaps.\n", nxagentNumDefaultColormaps); #endif - return 1; } else -- cgit v1.2.3 From 0133d4619d3d7fbe216b6ce6f507818eff8b98d4 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 01:20:36 +0200 Subject: Drawable.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Drawable.c | 413 +++++++++++--------------- 1 file changed, 174 insertions(+), 239 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c index 7574ec7b0..d8a5fb60f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c @@ -55,26 +55,23 @@ #undef DUMP /* - * The list of rectangles composing a region - * s returned by nxagentGetOptimizedRegion- - * Boxes() instead of RegionRects(). + * The list of rectangles composing a region s returned by + * nxagentGetOptimizedRegion- Boxes() instead of RegionRects(). */ #define USE_OPTIMIZED_BOXES /* - * The rectangles composing a region are de- - * fragmented to reduce the number of synch- - * ronizing PutImage's. + * The rectangles composing a region are de- fragmented to reduce the + * number of synch- ronizing PutImage's. */ #define ADVANCED_BOXES_DEFRAG /* - * If defined, send the XClearArea at the end - * of the loop synchronizing the shadow pixmap. - * In this way, large images can be split but - * the user will see more updates together. + * If defined, send the XClearArea at the end of the loop + * synchronizing the shadow pixmap. In this way, large images can be + * split but the user will see more updates together. */ #undef COLLECTED_UPDATES @@ -104,9 +101,8 @@ _nxagentSynchronizationRec nxagentSynchronization = { (DrawablePtr) NULL, 0, 0, RegionPtr nxagentDeferredBackgroundExposures = NullRegion; /* - * Predicate functions used to synchronize the - * content of the remote drawable with the data - * stored in the virtual frame-buffer. + * Predicate functions used to synchronize the content of the remote + * drawable with the data stored in the virtual frame-buffer. */ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2); @@ -164,12 +160,10 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre } /* - * What we want here is to avoid drawing on the - * framebuffer and just perform the operation - * on the real X server. This is the purpose of - * the FB trap. At the same time we also want - * to avoid a split, so that the image will be - * transferred in a single operation. + * What we want here is to avoid drawing on the framebuffer and just + * perform the operation on the real X server. This is the purpose + * of the FB trap. At the same time we also want to avoid a split, + * so that the image will be transferred in a single operation. */ nxagentFBTrap = 1; @@ -249,9 +243,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask pDrawable); /* - * Synchronize the whole pixmap if we need - * to download a fresh copy with lossless - * compression turned off. + * Synchronize the whole pixmap if we need to download a fresh + * copy with lossless compression turned off. */ if (nxagentLosslessTrap == 1) @@ -289,10 +282,9 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask else if (nxagentReconnectTrap == 1) { /* - * The pixmap data is not synchronized unless - * we need it. We noticed we have to reconnect - * the pixmaps used by the GC's clip mask. - * The other data will be synchronized on demand. + * The pixmap data is not synchronized unless we need it. We + * noticed we have to reconnect the pixmaps used by the GC's + * clip mask. The other data will be synchronized on demand. */ if (pDrawable -> depth == 1) @@ -357,9 +349,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask } /* - * By calling this function with the NullRegion - * as parameter we are requesting to synchro- - * nize the full visible corrupted region of + * By calling this function with the NullRegion as parameter we are + * requesting to synchronize the full visible corrupted region of * the drawable. */ @@ -372,8 +363,8 @@ nxagentSynchronizeDrawableDataEnd: } /* - * If pRegion is NullRegion, all the viewable - * corrupted region will be synchronized. + * If pRegion is NullRegion, all the viewable corrupted region will be + * synchronized. */ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned int breakMask, WindowPtr owner) @@ -434,9 +425,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } /* - * The stored bitmap may be used if we - * are going to synchronize the full - * drawable. + * The stored bitmap may be used if we are going to synchronize the + * full drawable. */ useStoredBitmap = (nxagentDrawableBitmap(pDrawable) != NullPixmap && pRegion == NullRegion); @@ -454,24 +444,21 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned RegionNumRects(nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable)))); #endif - clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height); + RegionPtr clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height); /* - * Intersecting the viewable region of the - * drawable with the region remaining from - * a previous loop. + * Intersecting the viewable region of the drawable with the + * region remaining from a previous loop. */ RegionIntersect(clipRegion, clipRegion, nxagentCorruptedRegion((DrawablePtr) nxagentDrawableBitmap(pDrawable))); /* - * The bitmap regions used in the synchro- - * nizations are only those corrupted also - * on the drawable. In this way, if we put - * a tile in a bad position (e.g. if the - * corrupted region moves), the next synch- - * ronization will fix the error. + * The bitmap regions used in the synchronizations are only those + * corrupted also on the drawable. In this way, if we put a tile + * in a bad position (e.g. if the corrupted region moves), the + * next synchronization will fix the error. */ RegionIntersect(clipRegion, clipRegion, @@ -495,8 +482,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } /* - * Using the saved bitmap as source, instead - * of the drawable itself. + * Using the saved bitmap as source, instead of the drawable + * itself. */ pSrcDrawable = ((DrawablePtr) nxagentVirtualPixmap(nxagentDrawableBitmap(pDrawable))); @@ -524,15 +511,14 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } /* - * Creating a region containing the viewable - * area of drawable. + * Creating a region containing the viewable area of drawable. */ clipRegion = nxagentCreateRegion(pDrawable, NULL, 0, 0, pDrawable -> width, pDrawable -> height); /* - * If the corrupted region is not viewable, we - * can skip the synchronization. + * If the corrupted region is not viewable, we can skip the + * synchronization. */ RegionIntersect(clipRegion, clipRegion, nxagentCorruptedRegion(pDrawable)); @@ -550,10 +536,9 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } /* - * We can skip the synchronization if the re- - * quested region is not corrupted. Specifying - * a NullRegion as parameter, all the viewable - * corrupted region will be synchronized. + * We can skip the synchronization if the requested region is not + * corrupted. Specifying a NullRegion as parameter, all the + * viewable corrupted region will be synchronized. */ if (pRegion != NullRegion) @@ -618,12 +603,10 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #endif /* - * We are going to synchronize the corrupted - * area, so we use the corrupted extents as - * maximum size of the image data. It's im- - * portant to avoid using the drawable size, - * because in case of a huge window it had to - * result in a failed data memory allocation. + * We are going to synchronize the corrupted area, so we use the + * corrupted extents as maximum size of the image data. It's + * important to avoid using the drawable size, because in case of a + * huge window it had to result in a failed data memory allocation. */ extentWidth = clipRegion -> extents.x2 - clipRegion -> extents.x1; @@ -645,8 +628,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Failed to allocate memory for synchronization.\n"); /* - * Print detailed information if the - * image length is zero. + * Print detailed information if the image length is zero. */ if (length == 0) @@ -727,9 +709,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (canBreakOnTimeout(breakMask)) { /* - * Abort the synchronization loop if it - * lasts for more than DeferTimeout - * milliseconds. + * Abort the synchronization loop if it lasts for more than + * DeferTimeout milliseconds. */ elapsedTime = GetTimeInMillis() - now; @@ -794,8 +775,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned nxagentGetImage(pSrcDrawable, x, y, w, h, format, AllPlanes, data); /* - * Going to unmark the synchronized - * region. + * Going to unmark the synchronized region. */ RegionInit(&tileRegion, &tileBox, 1); @@ -809,20 +789,18 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (useStoredBitmap != 0) { /* - * When a bitmap's tile is synchronized, - * we can clear the corresponding region. - * We can't use the nxagentUnmarkCorrupted- - * Region because we have not a resource - * associated to this pixmap. + * When a bitmap's tile is synchronized, we can clear the + * corresponding region. We can't use the + * nxagentUnmarkCorruptedRegion because we have not a + * resource associated to this pixmap. */ RegionSubtract(nxagentPixmapCorruptedRegion(nxagentDrawableBitmap(pDrawable)), nxagentPixmapCorruptedRegion(nxagentDrawableBitmap(pDrawable)), &tileRegion); /* - * The drawable's corrupted region can - * be cleared if the bitmap's tile data - * matches the drawable's content at the + * The drawable's corrupted region can be cleared if the + * bitmap's tile data matches the drawable's content at the * same position. */ @@ -882,8 +860,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned } /* - * Realize the image after comparing the - * source data with the bitmap data. + * Realize the image after comparing the source data with the + * bitmap data. */ nxagentRealizeImage(pDrawable, pGC, pDrawable -> depth, @@ -921,9 +899,8 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #endif /* #if !defined(COLLECTED_UPDATES) */ /* - * Abort the loop on the user's input. - * This is done here to check for events - * read after the flush caused by the + * Abort the loop on the user's input. This is done here to + * check for events read after the flush caused by the * PutImage. */ @@ -959,10 +936,9 @@ nxagentSynchronizeRegionStop: if (nxagentSynchronization.abort == 1) { /* - * Storing the pointer to the drawable we - * were synchronizing when the loop aborted. - * It is used in nxagentSynchronizeDrawable- - * Predicate. + * Storing the pointer to the drawable we were synchronizing + * when the loop aborted. It is used in + * nxagentSynchronizeDrawablePredicate. */ nxagentSynchronization.pDrawable = pDrawable; @@ -1138,10 +1114,9 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2) int shouldClearHiddenRegion = 1; /* - * The nxagentSynchronization.abort propa- - * gates a break condition across the resour- - * ces loop, in order to block also the sub- - * sequent synchronizations. + * The nxagentSynchronization.abort propagates a break condition + * across the resources loop, in order to block also the subsequent + * synchronizations. */ if (nxagentSynchronization.abort == 1 || @@ -1151,10 +1126,9 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2) } /* - * In order to implement a kind of round-robin - * synchronization, the previous incomplete - * drawable synchronization is saved to jump - * to the next resource available of same type. + * In order to implement a kind of round-robin synchronization, the + * previous incomplete drawable synchronization is saved to jump to + * the next resource available of same type. */ if (nxagentSynchronization.pDrawable != NULL && @@ -1186,10 +1160,8 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2) if (pDrawable -> type == DRAWABLE_PIXMAP) { /* - * The pixmaps to be synchronized are those - * used as background or used as source of - * any deferred operations for at least 2 - * times. + * The pixmaps to be synchronized are those used as background or + * used as source of any deferred operations for at least 2 times. */ if (NXAGENT_SHOULD_SYNCHRONIZE_PIXMAP(pDrawable) == 0) @@ -1234,17 +1206,15 @@ void nxagentSynchronizeDrawablePredicate(void *p0, XID x1, void *p2) } /* - * Postpone the synchronization if we went - * out of bandwidth or if the display blocks. - * The pixmap synchronization is more careful + * Postpone the synchronization if we went out of bandwidth or if + * the display blocks. The pixmap synchronization is more careful * with bandwidth usage. */ /* -FIXME: This condition sounds only as a - complication, as the break parameters - are already checked while synchroni- - zing the drawable. +FIXME: This condition sounds only as a complication, as the break + parameters are already checked while synchronizing the + drawable. if (breakOnCongestion(*breakMask) == 1 || (pDrawable -> type == DRAWABLE_PIXMAP && @@ -1275,10 +1245,9 @@ FIXME: This condition sounds only as a #endif /* - * The stored bitmap is destroyed inside - * the synchronization loop, so we have - * to check here its presence to know if - * we can clear the dirty windows. + * The stored bitmap is destroyed inside the synchronization loop, + * so we have to check here its presence to know if we can clear the + * dirty windows. */ shouldClearHiddenRegion = (nxagentDrawableBitmap(pDrawable) == NullPixmap); @@ -1293,10 +1262,9 @@ FIXME: This condition sounds only as a #endif /* - * If the remaining corrupted region is on - * an hidden section (not viewable or outside - * of the pixmap's area) of a drawable, - * we can clear it. + * If the remaining corrupted region is on an hidden section (not + * viewable or outside of the pixmap's area) of a drawable, we can + * clear it. */ if (nxagentSynchronization.abort == 0 && @@ -1319,9 +1287,8 @@ void nxagentSynchronizationLoop(unsigned int mask) int doRoundRobin; /* -FIXME: All drawables should be set as synchronized and - never marked as corrupted while the display is - down. +FIXME: All drawables should be set as synchronized and never marked as + corrupted while the display is down. */ nxagentSkipImage = nxagentTooManyImageData(); @@ -1361,11 +1328,9 @@ FIXME: All drawables should be set as synchronized and breakMask = mask; /* - * The resource counter can be reset if we - * have not aborted the synchronization loop, - * if we are not skipping resources to do - * round-robin and if the bitmaps are all - * synchronized. + * The resource counter can be reset if we have not aborted the + * synchronization loop, if we are not skipping resources to do + * round-robin and if the bitmaps are all synchronized. */ doRoundRobin = (nxagentSynchronization.pDrawable != NULL); @@ -1436,11 +1401,10 @@ FIXME: All drawables should be set as synchronized and } /* - * If there is bandwidth remaining, synchronize - * the pixmaps. Synchronizing a pixmap doesn't - * produce any visible results. Better is to - * synchronize them on demand, before using the - * pixmap in a copy or in a composite operation. + * If there is bandwidth remaining, synchronize the + * pixmaps. Synchronizing a pixmap doesn't produce any visible + * results. Better is to synchronize them on demand, before using + * the pixmap in a copy or in a composite operation. */ if (nxagentSynchronization.abort == 0 && @@ -1474,9 +1438,8 @@ FIXME: All drawables should be set as synchronized and } /* - * If the last synchronized drawable has been - * removed, we have to reset the variable sto- - * ring its pointer. + * If the last synchronized drawable has been removed, we have to + * reset the variable sto- ring its pointer. */ if (nxagentSynchronization.pDrawable != NULL && @@ -1551,9 +1514,8 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, else { /* - * We use the clipList because the borderClip - * contains also parts of the window covered - * by its children. + * We use the clipList because the borderClip contains also parts + * of the window covered by its children. */ RegionTranslate(pRegion, @@ -1579,8 +1541,8 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, #endif /* - * If the pRegion is NIL we don't need - * to intersect it with the GC's clipmask. + * If the pRegion is NIL we don't need to intersect it with the GC's + * clipmask. */ if (RegionNil(pRegion) == 0 && @@ -1594,9 +1556,9 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, RegionCopy(&clipRegion, (RegionPtr) pGC -> clientClip); /* - * The clip origin is relative to the origin of - * the destination drawable. The clip mask coor- - * dinates are relative to the clip origin. + * The clip origin is relative to the origin of the destination + * drawable. The clip mask coor- dinates are relative to the clip + * origin. */ if (pGC -> clipOrg.x != 0 || pGC -> clipOrg.y != 0) @@ -1636,10 +1598,9 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) } /* - * If the drawable was synchronized, the counter - * reporting the number of corrupted drawables - * must be increased. Moreover the corrupted ti- - * mestamp must be set. + * If the drawable was synchronized, the counter reporting the + * number of corrupted drawables must be increased. Moreover the + * corrupted ti- mestamp must be set. */ if (nxagentDrawableStatus(pDrawable) == Synchronized) @@ -1752,9 +1713,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) } /* - * If the drawable becomes synchronized, the - * counter reporting the number of corrupted - * drawables must be decreased. Moreover the + * If the drawable becomes synchronized, the counter reporting the + * number of corrupted drawables must be decreased. Moreover the * corrupted timestamp must be reset. */ @@ -1777,8 +1737,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) nxagentResetCorruptedTimestamp(pDrawable); /* - * If the resource is no longer dirty, - * the associated bitmap is destroyed. + * If the resource is no longer dirty, the associated bitmap is + * destroyed. */ if (nxagentDrawableBitmap(pDrawable) != NullPixmap) @@ -1791,9 +1751,8 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask) { /* - * If a window is resized, its corrupted - * region is moved according to the bit - * gravity. + * If a window is resized, its corrupted region is moved according + * to the bit gravity. */ if (nxagentDrawableStatus((DrawablePtr) pWin) == NotSynchronized) @@ -1819,18 +1778,17 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask) nx, ny); /* - * Having moved the corrupted region, we - * need to invalidate the pending commits - * or otherwise the image will fall in - * the wrong area. + * Having moved the corrupted region, we need to invalidate the + * pending commits or otherwise the image will fall in the wrong + * area. */ nxagentValidateSplit((DrawablePtr) pWin, NULL); /* - * The window reconfiguration invalidates - * the synchronization bitmap. + * The window reconfiguration invalidates the synchronization + * bitmap. */ nxagentDestroyDrawableBitmap((DrawablePtr) pWin); @@ -1839,13 +1797,12 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask) } /* - * The DDX layer uses an 'Y-X banding' representation of - * regions: it sorts all rectangles composing a region - * using first the y-dimension, than the x-dimension; mo- - * reover it organizes the rectangles in 'bands' sharing - * the same y-dimension. This representation does not mi- - * nimize the number of rectangles. For example, the fol- - * lowing region has 4 rectangles: + * The DDX layer uses an 'Y-X banding' representation of regions: it + * sorts all rectangles composing a region using first the + * y-dimension, than the x-dimension; moreover it organizes the + * rectangles in 'bands' sharing the same y-dimension. This + * representation does not minimize the number of rectangles. For + * example, the following region has 4 rectangles: * * +-----------+ * | | +---+ @@ -1853,22 +1810,21 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask) * | | +---+ * +-----------+ * - * The rectangle 'B' creates a band which splits the rec- - * tangle A in 3 parts, for a total of 3 bands. The num- - * ber of rectangles composing the region is 4. + * The rectangle 'B' creates a band which splits the rectangle A in 3 + * parts, for a total of 3 bands. The number of rectangles composing + * the region is 4. * - * This kind of representation is not advisable for the - * lazy synchronization because, in the example above, - * the nxagent had to send 4 put images instead of 2. + * This kind of representation is not advisable for the lazy + * synchronization because, in the example above, the nxagent had to + * send 4 put images instead of 2. * - * To minimize the problem we use the following function: - * by traversing the list of rectangles we merge all bo- - * xes with same x coordinates and coincident y, in order - * to create an X-Y banding. + * To minimize the problem we use the following function: by + * traversing the list of rectangles we merge all boxes with same x + * coordinates and coincident y, in order to create an X-Y banding. * - * Be careful: all the coordinates of boxes merged are - * set to 0, so take care of this when looping through - * the box list returned by this function. + * Be careful: all the coordinates of boxes merged are set to 0, so + * take care of this when looping through the box list returned by + * this function. */ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) @@ -1903,17 +1859,15 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) #endif /* - * The boxes are now grouped to grown as much - * as possible, using their overlapping vertex - * as rule. + * The boxes are now grouped to grown as much as possible, using + * their overlapping vertex as rule. */ for (i = 0; i < nBox; i++) { /* - * If the coordinates are (0,0) the box - * has been already merged, so we can skip - * it. + * If the coordinates are (0,0) the box has been already merged, + * so we can skip it. */ if (pBox[i].x1 == 0 && pBox[i].y1 == 0 && @@ -1951,12 +1905,10 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) #endif /* - * Each consequent box is merged if its - * higher side overlaps the lower side - * of current box. - * In case of ADVANCED_BOXES_DEFRAG the higher - * side must be included within a range - * defined by INCLUDE_MARGIN. + * Each consequent box is merged if its higher side overlaps the + * lower side of current box. In case of ADVANCED_BOXES_DEFRAG + * the higher side must be included within a range defined by + * INCLUDE_MARGIN. */ #ifndef ADVANCED_BOXES_DEFRAG @@ -2006,11 +1958,9 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) } /* - * By appending a box to another, we have - * to remove it from the box list. We do - * this by setting its coordinates to (0,0) - * and by checking their value in the main - * loop. + * By appending a box to another, we have to remove it from + * the box list. We do this by setting its coordinates to + * (0,0) and by checking their value in the main loop. */ pBox[j].x1 = pBox[j].y1 = pBox[j].x2 = pBox[j].y2 = 0; @@ -2039,10 +1989,9 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) #ifdef ADVANCED_BOXES_DEFRAG /* - * The new list need to be validated to - * avoid boxes overlapping. This code may - * be improved to remove also the partial- - * ly overlapping boxes. + * The new list need to be validated to avoid boxes + * overlapping. This code may be improved to remove also the + * partial- ly overlapping boxes. */ for (i = 0; i < nBox; i++) @@ -2082,9 +2031,8 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) boxExtents.y2 >= pBox[j].y2)) { /* - * If a box is completely inside - * another, we set its coordinates - * to 0 to consider it as merged. + * If a box is completely inside another, we set its + * coordinates to 0 to consider it as merged. */ #ifdef DEBUG @@ -2172,9 +2120,8 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) } /* - * This function could be used to determine - * the ClearArea color of corrupted regions - * on screen. + * This function could be used to determine the ClearArea color of + * corrupted regions on screen. */ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion) @@ -2187,9 +2134,8 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion) } /* - * The pixel used as reference is the first - * outer pixel at the bottom right corner - * of corrupted region extents. + * The pixel used as reference is the first outer pixel at the + * bottom right corner of corrupted region extents. */ xPicker = pRegion -> extents.x2 + 1; @@ -2214,9 +2160,8 @@ unsigned long nxagentGetDrawableColor(DrawablePtr pDrawable) int xPicker, yPicker; /* - * The pixel used to determine the co- - * lor of a drawable is at coordinates - * (x + width - 4, y + 4). + * The pixel used to determine the color of a drawable is at + * coordinates (x + width - 4, y + 4). */ xPicker = pDrawable -> width - 4; @@ -2263,8 +2208,8 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) restore = 0; /* - * If the window has already a background, we - * can hope it will be nice. + * If the window has already a background, we can hope it will be + * nice. */ if (pWin -> backgroundState != None) @@ -2604,12 +2549,10 @@ void nxagentRegionsOnScreen(void) #endif /* - * If the synchronization loop breaks and the - * drawable synchronization cannot be completed, - * the remaining data is stored in a bitmap. - * The synchronization loop is then restarted - * using the bitmap as source instead of the - * drawable. + * If the synchronization loop breaks and the drawable synchronization + * cannot be completed, the remaining data is stored in a bitmap. The + * synchronization loop is then restarted using the bitmap as source + * instead of the drawable. */ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) @@ -2628,8 +2571,7 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) #endif /* - * The bitmap is created only in the - * nxagent. + * The bitmap is created only in the nxagent. */ saveTrap = nxagentGCTrap; @@ -2646,9 +2588,8 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) } /* - * Should create a function to append - * a bitmap to another, instead of - * destroying the old one. + * Should create a function to append a bitmap to another, instead + * of destroying the old one. */ if (nxagentDrawableBitmap(pDrawable) != NullPixmap) @@ -2683,13 +2624,11 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) } /* - * FIXME: A better way it would be create the bitmap - * with the same extents of the clipRegion. This - * requires to save the offset with respect to the - * drawable origin like in the backing store. This - * becomes particularly important when the drawable - * is a huge window, because the pixmap creation - * would fail. + * FIXME: A better way it would be create the bitmap with the same + * extents of the clipRegion. This requires to save the offset with + * respect to the drawable origin like in the backing store. This + * becomes particularly important when the drawable is a huge + * window, because the pixmap creation would fail. */ pBitmap = nxagentCreatePixmap(pDrawable -> pScreen, pDrawable -> width, pDrawable -> height, pDrawable -> depth, 0); @@ -2850,9 +2789,8 @@ void nxagentAllocateCorruptedResource(DrawablePtr pDrawable, RESTYPE type) if (nxagentPixmapPriv(pRealPixmap) -> corruptedBackgroundId == 0) { /* - * When a pixmap is added to the background - * corrupted resources, it must be removed - * from the pixmap corrupted resources. + * When a pixmap is added to the background corrupted resources, + * it must be removed from the pixmap corrupted resources. */ nxagentDestroyCorruptedResource(pDrawable, RT_NX_CORR_PIXMAP); @@ -2873,8 +2811,8 @@ void nxagentAllocateCorruptedResource(DrawablePtr pDrawable, RESTYPE type) else if (type == RT_NX_CORR_PIXMAP) { /* - * The shared memory pixmaps are always dirty - * and shouldn't be synchronized. + * The shared memory pixmaps are always dirty and shouldn't be + * synchronized. */ if (nxagentPixmapUsageCounter((PixmapPtr) pDrawable) >= MINIMUM_PIXMAP_USAGE_COUNTER && @@ -3044,11 +2982,9 @@ int nxagentSynchronizationPredicate(void) } /* - * If there are resources to synchronize - * but the conditions to start the loop - * are not satisfied, a little delay is - * requested to check for a new loop as - * soon as possible. + * If there are resources to synchronize but the conditions to start + * the loop are not satisfied, a little delay is requested to check + * for a new loop as soon as possible. */ return Delayed; @@ -3232,9 +3168,8 @@ int nxagentClipAndSendClearExpose(WindowPtr pWin, void * ptr) RegionIntersect(exposeRgn, remoteExposeRgn, &pWin -> clipList); /* - * If the region will be synchronized, - * the expose on corrupted regions can - * be ignored. + * If the region will be synchronized, the expose on corrupted + * regions can be ignored. */ RegionSubtract(exposeRgn, exposeRgn, nxagentCorruptedRegion((DrawablePtr) pWin)); -- cgit v1.2.3 From d94f472744355c71987d145727aecace1e8455b6 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 01:23:29 +0200 Subject: Drawable.c: code simplifications / scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Drawable.c | 364 ++++++++------------------ 1 file changed, 116 insertions(+), 248 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c index d8a5fb60f..7c69c99d9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c @@ -122,12 +122,8 @@ int nxagentSkipImage = 0; static int nxagentTooManyImageData(void) { - unsigned int r; - unsigned int limit; - - limit = nxagentOption(ImageRateLimit); - - r = nxagentGetDataRate() / 1000; + unsigned int limit = nxagentOption(ImageRateLimit); + unsigned int r = nxagentGetDataRate() / 1000; #ifdef TEST if (r > limit) @@ -141,8 +137,6 @@ static int nxagentTooManyImageData(void) int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int breakMask, WindowPtr owner) { - int result; - pDrawable = nxagentSplitDrawable(pDrawable); if (nxagentLosslessTrap == 0) @@ -170,7 +164,7 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre nxagentSplitTrap = 1; - result = nxagentSynchronizeDrawableData(pDrawable, breakMask, owner); + int result = nxagentSynchronizeDrawableData(pDrawable, breakMask, owner); nxagentSplitTrap = 0; @@ -182,7 +176,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre } #ifdef TEST - if (nxagentDrawableStatus(pDrawable) == Synchronized) { fprintf(stderr, "nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] now synchronized.\n", @@ -193,7 +186,6 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre fprintf(stderr, "nxagentSynchronizeDrawable: Drawable %s [%p] with id [%ld] not fully synchronized.\n", nxagentDrawableType(pDrawable), (void *) pDrawable, pDrawable -> id); } - #endif return result; @@ -201,31 +193,27 @@ int nxagentSynchronizeDrawable(DrawablePtr pDrawable, int wait, unsigned int bre int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask, WindowPtr owner) { - int width, height, depth, length; - unsigned int leftPad, format; - char *data = NULL; - DrawablePtr pSrcDrawable; - GCPtr pGC; - int success; if (pDrawable -> type == DRAWABLE_PIXMAP) { - leftPad = 0; + GCPtr pGC; + + unsigned int leftPad = 0; - width = pDrawable -> width; - height = pDrawable -> height; - depth = pDrawable -> depth; + int width = pDrawable -> width; + int height = pDrawable -> height; + int depth = pDrawable -> depth; #ifdef TEST fprintf(stderr, "nxagentSynchronizeDrawableData: Synchronizing drawable (%s) with geometry [%d][%d][%d].\n", nxagentDrawableType(pDrawable), width, height, depth); #endif - format = (depth == 1) ? XYPixmap : ZPixmap; + unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - length = nxagentImageLength(width, height, format, leftPad, depth); + int length = nxagentImageLength(width, height, format, leftPad, depth); if ((data = malloc(length)) == NULL) { @@ -238,9 +226,9 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask goto nxagentSynchronizeDrawableDataEnd; } - pSrcDrawable = (pDrawable -> type == DRAWABLE_PIXMAP ? - ((DrawablePtr) nxagentVirtualPixmap((PixmapPtr) pDrawable)) : - pDrawable); + DrawablePtr pSrcDrawable = (pDrawable -> type == DRAWABLE_PIXMAP ? + ((DrawablePtr) nxagentVirtualPixmap((PixmapPtr) pDrawable)) : + pDrawable); /* * Synchronize the whole pixmap if we need to download a fresh @@ -369,47 +357,20 @@ nxagentSynchronizeDrawableDataEnd: int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned int breakMask, WindowPtr owner) { - GCPtr pGC; DrawablePtr pSrcDrawable; - BoxPtr pBox; - RegionPtr clipRegion; - RegionRec tileRegion; - RegionRec exposeRegion; - BoxRec box; - BoxRec tileBox; + int leftPad = 0; + int success = 0; + char *data = NULL; + GCPtr pGC = NULL; + RegionPtr clipRegion = NullRegion; #ifdef COLLECTED_UPDATES RegionRec collectedUpdates; - #endif - - char *data; - - int nBox; - int x, y; - int w, h; - int extentWidth, extentHeight; - int tileWidth, tileHeight; - int length, format, leftPad; - int i; - int saveTrap; - int success; - int useStoredBitmap; - - unsigned long now; - unsigned long elapsedTime; - - - leftPad = 0; - success = 0; - data = NULL; - pGC = NULL; - clipRegion = NullRegion; - - #ifdef COLLECTED_UPDATES RegionInit(&collectedUpdates, NullBox, 1); #endif + RegionRec exposeRegion; RegionInit(&exposeRegion, NullBox, 1); if (nxagentDrawableBitmap(pDrawable) != NullPixmap && @@ -429,7 +390,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned * full drawable. */ - useStoredBitmap = (nxagentDrawableBitmap(pDrawable) != NullPixmap && pRegion == NullRegion); + int useStoredBitmap = (nxagentDrawableBitmap(pDrawable) != NullPixmap && pRegion == NullRegion); if (useStoredBitmap != 0) { @@ -570,7 +531,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned nxagentDrawableType(pDrawable), (void *) pDrawable); #endif - saveTrap = nxagentGCTrap; + int saveTrap = nxagentGCTrap; nxagentGCTrap = 0; @@ -609,6 +570,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned * huge window it had to result in a failed data memory allocation. */ + int w, h, extentWidth, extentHeight, tileWidth, tileHeight; extentWidth = clipRegion -> extents.x2 - clipRegion -> extents.x1; extentHeight = clipRegion -> extents.y2 - clipRegion -> extents.y1; @@ -619,6 +581,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned fprintf(stderr, "nxagentSynchronizeRegion: Using tiles of size [%dx%d].\n", tileWidth, tileHeight); #endif + int length, format; data = nxagentAllocateImageData(w, h, pDrawable -> depth, &length, &format); if (data == NULL) @@ -646,17 +609,17 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #ifndef USE_OPTIMIZED_BOXES - pBox = RegionRects(clipRegion); + BoxPtr pBox = RegionRects(clipRegion); #else - pBox = nxagentGetOptimizedRegionBoxes(clipRegion); + BoxPtr pBox = nxagentGetOptimizedRegionBoxes(clipRegion); #endif /* USE_OPTIMIZED_BOXES */ - nBox = RegionNumRects(clipRegion); + int nBox = RegionNumRects(clipRegion); - now = GetTimeInMillis(); + unsigned long now = GetTimeInMillis(); nxagentSynchronization.abort = 0; @@ -664,7 +627,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned * Going to split the updated region into small blocks. */ - for (i = 0; i < nBox; i++) + for (int i = 0; i < nBox; i++) { #ifdef USE_OPTIMIZED_BOXES @@ -676,13 +639,13 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned #endif - box = pBox[i]; + BoxRec box = pBox[i]; - for (y = box.y1; y < box.y2; y += h) + for (int y = box.y1; y < box.y2; y += h) { h = min(box.y2 - y, tileHeight); - for (x = box.x1; x < box.x2; x += w) + for (int x = box.x1; x < box.x2; x += w) { w = min(box.x2 - x, tileWidth); @@ -713,7 +676,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned * DeferTimeout milliseconds. */ - elapsedTime = GetTimeInMillis() - now; + unsigned long elapsedTime = GetTimeInMillis() - now; if (elapsedTime > nxagentOption(DeferTimeout)) { @@ -762,10 +725,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned goto nxagentSynchronizeRegionStop; } - tileBox.x1 = x; - tileBox.y1 = y; - tileBox.x2 = x + w; - tileBox.y2 = y + h; + BoxRec tileBox = {.x1 = x, .y1 = y, .x2 = x + w, .y2 = y + h}; #ifdef DEBUG fprintf(stderr, "nxagentSynchronizeRegion: Going to synchronize tile [%d,%d,%d,%d].\n", @@ -778,6 +738,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned * Going to unmark the synchronized region. */ + RegionRec tileRegion; RegionInit(&tileRegion, &tileBox, 1); RegionUnion(&exposeRegion, &exposeRegion, &tileRegion); @@ -806,11 +767,9 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned if (nxagentDrawableStatus(pDrawable) == NotSynchronized) { - char *cmpData; - int cmpLength, cmpFormat; - cmpData = nxagentAllocateImageData(w, h, pDrawable -> depth, &cmpLength, &cmpFormat); + char *cmpData = nxagentAllocateImageData(w, h, pDrawable -> depth, &cmpLength, &cmpFormat); if (cmpData != NULL) { @@ -877,16 +836,11 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned (nxagentOption(XRatio) != DONT_SCALE || nxagentOption(YRatio) != DONT_SCALE)) { - int scaledx; - int scaledy; - int scaledw; - int scaledh; + int scaledx = nxagentScale(x, nxagentOption(XRatio)); + int scaledy = nxagentScale(y, nxagentOption(YRatio)); - scaledx = nxagentScale(x, nxagentOption(XRatio)); - scaledy = nxagentScale(y, nxagentOption(YRatio)); - - scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx; - scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy; + int scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx; + int scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy; XClearArea(nxagentDisplay, nxagentWindow(owner), scaledx, scaledy, scaledw, scaledh, 0); } @@ -969,14 +923,12 @@ nxagentSynchronizeRegionStop: nxagentIsCorruptedBackground((PixmapPtr) pDrawable) == 1 && RegionNil(&exposeRegion) == 0) { - struct nxagentExposeBackground eb; - - int i; + struct nxagentExposeBackground eb = { + .pBackground = (PixmapPtr) pDrawable, + .pExpose = &exposeRegion, + }; - eb.pBackground = (PixmapPtr) pDrawable; - eb.pExpose = &exposeRegion; - - for (i = 0; i < MAXCLIENTS; i++) + for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i] != NULL) { @@ -995,27 +947,22 @@ nxagentSynchronizeRegionStop: RegionValidate(&collectedUpdates, &overlap); - for (i = 0; i < RegionNumRects(&collectedUpdates); i++) + for (int i = 0; i < RegionNumRects(&collectedUpdates); i++) { - x = RegionRects(&collectedUpdates)[i].x1; - y = RegionRects(&collectedUpdates)[i].y1; - w = RegionRects(&collectedUpdates)[i].x2 - RegionRects(&collectedUpdates)[i].x1; - h = RegionRects(&collectedUpdates)[i].y2 - RegionRects(&collectedUpdates)[i].y1; + int x = RegionRects(&collectedUpdates)[i].x1; + int y = RegionRects(&collectedUpdates)[i].y1; + int w = RegionRects(&collectedUpdates)[i].x2 - RegionRects(&collectedUpdates)[i].x1; + int h = RegionRects(&collectedUpdates)[i].y2 - RegionRects(&collectedUpdates)[i].y1; if (nxagentOption(Shadow) == 1 && (nxagentOption(XRatio) != DONT_SCALE || nxagentOption(YRatio) != DONT_SCALE)) { - int scaledx; - int scaledy; - int scaledw; - int scaledh; - - scaledx = nxagentScale(x, nxagentOption(XRatio)); - scaledy = nxagentScale(y, nxagentOption(YRatio)); + int scaledx = nxagentScale(x, nxagentOption(XRatio)); + int scaledy = nxagentScale(y, nxagentOption(YRatio)); - scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx; - scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy; + int scaledw = nxagentScale(x + w, nxagentOption(XRatio)) - scaledx; + int scaledh = nxagentScale(y + h, nxagentOption(YRatio)) - scaledy; XClearArea(nxagentDisplay, nxagentWindow(owner), scaledx, scaledy, scaledw, scaledh, 0); } @@ -1050,8 +997,6 @@ nxagentSynchronizeRegionFree: void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox, unsigned int breakMask) { - RegionPtr pRegion; - if (nxagentDrawableStatus(pDrawable) == Synchronized) { #ifdef TEST @@ -1078,7 +1023,7 @@ void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox, unsigned int brea pBox -> x1, pBox -> y1, pBox -> x2, pBox -> y2); #endif - pRegion = nxagentCreateRegion(pDrawable, NULL, pBox -> x1, pBox -> y1, + RegionPtr pRegion = nxagentCreateRegion(pDrawable, NULL, pBox -> x1, pBox -> y1, pBox -> x2 - pBox -> x1, pBox -> y2 - pBox -> y1); @@ -1282,10 +1227,6 @@ FIXME: This condition sounds only as a complication, as the break void nxagentSynchronizationLoop(unsigned int mask) { - unsigned int breakMask; - - int doRoundRobin; - /* FIXME: All drawables should be set as synchronized and never marked as corrupted while the display is down. @@ -1325,7 +1266,7 @@ FIXME: All drawables should be set as synchronized and never marked as "blocking [%d].\n", nxagentCongestion, nxagentBlocking); #endif - breakMask = mask; + unsigned int breakMask = mask; /* * The resource counter can be reset if we have not aborted the @@ -1333,7 +1274,7 @@ FIXME: All drawables should be set as synchronized and never marked as * round-robin and if the bitmaps are all synchronized. */ - doRoundRobin = (nxagentSynchronization.pDrawable != NULL); + int doRoundRobin = (nxagentSynchronization.pDrawable != NULL); nxagentSynchronization.abort = 0; @@ -1471,15 +1412,8 @@ FIXME: All drawables should be set as synchronized and never marked as RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height) { - RegionPtr pRegion; - BoxRec box; - - box.x1 = x; - box.y1 = y; - box.x2 = x + width; - box.y2 = y + height; - - pRegion = RegionCreate(&box, 1); + BoxRec box = {.x1 = x, .y1 = y, .x2 = x + width, .y2 = y + height}; + RegionPtr pRegion = RegionCreate(&box, 1); /* * Clipping the region. @@ -1487,22 +1421,17 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, if (pDrawable -> type == DRAWABLE_PIXMAP) { - BoxRec tmpBox; - RegionRec tmpRegion; - /* - * The region created doesn't need to be clipped - * if it has the pixmap dimensions. + * The region created doesn't need to be clipped if it has the + * pixmap dimensions. */ if (x != 0 || y != 0 || width != pDrawable -> width || height != pDrawable -> height) { - tmpBox.x1 = 0; - tmpBox.y1 = 0; - tmpBox.x2 = pDrawable -> width; - tmpBox.y2 = pDrawable -> height; + BoxRec tmpBox = {.x1 = 0, .y1 = 0, .x2 = pDrawable -> width, .y2 = pDrawable -> height}; + RegionRec tmpRegion; RegionInit(&tmpRegion, &tmpBox, 1); @@ -1582,11 +1511,6 @@ RegionPtr nxagentCreateRegion(DrawablePtr pDrawable, GCPtr pGC, int x, int y, void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) { - int x; - int y; - int width; - int height; - if (pRegion != NullRegion && RegionNil(pRegion) == 1) { #ifdef TEST @@ -1615,11 +1539,11 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) if (pRegion == NullRegion) { - x = 0; - y = 0; + int x = 0; + int y = 0; - width = pDrawable -> width; - height = pDrawable -> height; + int width = pDrawable -> width; + int height = pDrawable -> height; #ifdef TEST fprintf(stderr, "nxagentMarkCorruptedRegion: Fully invalidating %s [%p] with " @@ -1661,8 +1585,6 @@ void nxagentMarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) { - int oldStatus; - if (pRegion != NullRegion && RegionNil(pRegion) == 1) { #ifdef TEST @@ -1673,7 +1595,7 @@ void nxagentUnmarkCorruptedRegion(DrawablePtr pDrawable, RegionPtr pRegion) return; } - oldStatus = nxagentDrawableStatus(pDrawable); + int oldStatus = nxagentDrawableStatus(pDrawable); if (oldStatus == Synchronized) { @@ -1829,20 +1751,11 @@ void nxagentMoveCorruptedRegion(WindowPtr pWin, unsigned int mask) BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) { - BoxPtr pBox; - BoxRec boxExtents; - int nBox; - int i, j; - - #ifdef DEBUG - int nBoxOptim; - #endif - - pBox = RegionRects(pRegion); + BoxPtr pBox = RegionRects(pRegion); - nBox = RegionNumRects(pRegion); + int nBox = RegionNumRects(pRegion); #ifdef TEST fprintf(stderr, "nxagentGetOptimizedRegionBoxes: Going to optimize region at [%p] with [%d] rects.\n", @@ -1855,7 +1768,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) } #ifdef DEBUG - nBoxOptim = nBox; + int nBoxOptim = nBox; #endif /* @@ -1863,7 +1776,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) * their overlapping vertex as rule. */ - for (i = 0; i < nBox; i++) + for (int i = 0; i < nBox; i++) { /* * If the coordinates are (0,0) the box has been already merged, @@ -1891,7 +1804,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) boxExtents.y2 = pBox[i].y2; - for (j = i+1; j < nBox; j++) + for (int j = i+1; j < nBox; j++) { if (pBox[j].x1 == 0 && pBox[j].y1 == 0 && pBox[j].x2 == 0 && pBox[j].y2 == 0) @@ -1994,7 +1907,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) * partial- ly overlapping boxes. */ - for (i = 0; i < nBox; i++) + for (int i = 0; i < nBox; i++) { if (pBox[i].x1 == 0 && pBox[i].y1 == 0 && pBox[i].x2 == 0 && pBox[i].y2 == 0) @@ -2012,7 +1925,7 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) boxExtents.x2 = pBox[i].x2; boxExtents.y2 = pBox[i].y2; - for (j = i+1; j < nBox; j++) + for (int j = i+1; j < nBox; j++) { if (pBox[j].x1 == 0 && pBox[j].y1 == 0 && pBox[j].x2 == 0 && pBox[j].y2 == 0) @@ -2063,19 +1976,14 @@ BoxPtr nxagentGetOptimizedRegionBoxes(RegionPtr pRegion) unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) { - XImage *ximage; - Visual *pVisual; - char *data; - - int depth, format, length; int leftPad = 0; - unsigned long pixel; - depth = pDrawable -> depth; - format = (depth == 1) ? XYPixmap : ZPixmap; - length = nxagentImageLength(1, 1, format, leftPad, depth); + int depth = pDrawable -> depth; + int format = (depth == 1) ? XYPixmap : ZPixmap; + int length = nxagentImageLength(1, 1, format, leftPad, depth); - if ((data = malloc(length)) == NULL) + char * data = malloc(length); + if (data == NULL) { #ifdef WARNING fprintf(stderr, "nxagentGetColor: WARNING! Failed to allocate memory for the operation.\n"); @@ -2084,7 +1992,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) return -1; } - pVisual = nxagentImageVisual(pDrawable, depth); + Visual *pVisual = nxagentImageVisual(pDrawable, depth); if (pVisual == NULL) { @@ -2097,9 +2005,9 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) fbGetImage(pDrawable, xPixel, yPixel, 1, 1, format, AllPlanes, data); - ximage = XCreateImage(nxagentDisplay, pVisual, depth, format, leftPad, (char *) data, - 1, 1, BitmapPad(nxagentDisplay), - nxagentImagePad(1, format, leftPad, 1)); + XImage *ximage = XCreateImage(nxagentDisplay, pVisual, depth, format, leftPad, (char *) data, + 1, 1, BitmapPad(nxagentDisplay), + nxagentImagePad(1, format, leftPad, 1)); if (ximage == NULL) { @@ -2112,7 +2020,7 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) return -1; } - pixel = XGetPixel(ximage, 0, 0); + unsigned long pixel = XGetPixel(ximage, 0, 0); XDestroyImage(ximage); @@ -2126,8 +2034,6 @@ unsigned long nxagentGetColor(DrawablePtr pDrawable, int xPixel, int yPixel) unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion) { - int xPicker, yPicker; - if (RegionNil(pRegion) == 1) { return nxagentGetDrawableColor(pDrawable); @@ -2138,14 +2044,14 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion) * bottom right corner of corrupted region extents. */ - xPicker = pRegion -> extents.x2 + 1; + int xPicker = pRegion -> extents.x2 + 1; if (xPicker > pDrawable -> width) { xPicker = pDrawable -> width; } - yPicker = pRegion -> extents.y2 + 1; + int yPicker = pRegion -> extents.y2 + 1; if (yPicker > pDrawable -> height) { @@ -2157,29 +2063,17 @@ unsigned long nxagentGetRegionColor(DrawablePtr pDrawable, RegionPtr pRegion) unsigned long nxagentGetDrawableColor(DrawablePtr pDrawable) { - int xPicker, yPicker; - /* * The pixel used to determine the color of a drawable is at * coordinates (x + width - 4, y + 4). */ - xPicker = pDrawable -> width - 4; - - yPicker = 4; - - return nxagentGetColor(pDrawable, xPicker, yPicker); + return nxagentGetColor(pDrawable, pDrawable -> width - 4, 4); } void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) { - WindowPtr pWin; - BoxPtr pBox; - - unsigned long color; unsigned long backupPixel = 0; - int nBox, i; - int restore; #ifdef DEBUG static int nBoxCleared; @@ -2203,9 +2097,9 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) return; } - pWin = (WindowPtr) pDrawable; + WindowPtr pWin = (WindowPtr) pDrawable; - restore = 0; + int restore = 0; /* * If the window has already a background, we can hope it will be @@ -2227,7 +2121,7 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) backupPixel = pWin -> background.pixel; - color = nxagentGetDrawableColor((DrawablePtr) pWin); + unsigned long color = nxagentGetDrawableColor((DrawablePtr) pWin); if (color == -1) { @@ -2247,11 +2141,11 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) restore = 1; } - pBox = nxagentGetOptimizedRegionBoxes(pRegion); + BoxPtr pBox = nxagentGetOptimizedRegionBoxes(pRegion); - nBox = RegionNumRects(pRegion); + int nBox = RegionNumRects(pRegion); - for (i = 0; i < nBox; i++) + for (int i = 0; i < nBox; i++) { if (pBox[i].x1 == 0 && pBox[i].y1 == 0 && pBox[i].x2 == 0 && pBox[i].y2 == 0) @@ -2284,21 +2178,14 @@ void nxagentClearRegion(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion) { - GCPtr pGC; - BoxPtr pBox; - XRectangle *pRects; - - int nrects; - int i; - if (RegionNil(pRegion) == 1) { return; } - pGC = nxagentGetGraphicContext(pDrawable); + GCPtr pGC = nxagentGetGraphicContext(pDrawable); - nrects = RegionNumRects(pRegion); + int nrects = RegionNumRects(pRegion); #ifdef TEST fprintf(stderr, "nxagentFillRemoteRegion: Going to fill remote region [%d,%d,%d,%d] rects [%d] with color [%lu].\n", @@ -2315,11 +2202,10 @@ void nxagentFillRemoteRegion(DrawablePtr pDrawable, RegionPtr pRegion) } else { - pBox = RegionRects(pRegion); + BoxPtr pBox = RegionRects(pRegion); + XRectangle *pRects = malloc(nrects * sizeof(XRectangle)); - pRects = malloc(nrects * sizeof(XRectangle)); - - for (i = 0; i < nrects; i++) + for (int i = 0; i < nrects; i++) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; @@ -2373,20 +2259,14 @@ int nxagentDestroyCorruptedBackgroundResource(void * p, XID id) void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode, int nPoints, xPoint *pPoints) { - RegionPtr pRegion; - RegionRec tmpRegion; - BoxRec box, extents; - - xPoint *xp; - int np; - - np = nPoints; - xp = pPoints; - - pRegion = RegionCreate(NullBox, 1); + RegionPtr pRegion = RegionCreate(NullBox, 1); + int np = nPoints; while (np--) { + BoxRec box; + xPoint *xp = pPoints; + if (CoordModePrevious) { box.x1 = box.x2 = (xp-1) -> x + xp -> x; @@ -2408,6 +2288,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode, * this loop could become less expensive. */ + RegionRec tmpRegion; RegionInit(&tmpRegion, &box, 1); RegionUnion(pRegion, pRegion, &tmpRegion); @@ -2417,7 +2298,7 @@ void nxagentPointsToDirtyRegion(DrawablePtr pDrawable, int mode, xp++; } - extents = *RegionExtents(pRegion); + BoxRec extents = *RegionExtents(pRegion); RegionReset(pRegion, &extents); @@ -2557,14 +2438,9 @@ void nxagentRegionsOnScreen(void) void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) { - PixmapPtr pBitmap; GCPtr pGC = NULL; RegionPtr pClipRegion = NullRegion; - int x, y; - int w, h; - int saveTrap; - #ifdef TEST fprintf(stderr, "nxagentCreateDrawableBitmap: Creating synchronization bitmap for [%s] at [%p].\n", nxagentDrawableType(pDrawable), (void *) pDrawable); @@ -2574,7 +2450,7 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) * The bitmap is created only in the nxagent. */ - saveTrap = nxagentGCTrap; + int saveTrap = nxagentGCTrap; nxagentGCTrap = 1; @@ -2631,6 +2507,7 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) * window, because the pixmap creation would fail. */ + PixmapPtr pBitmap; pBitmap = nxagentCreatePixmap(pDrawable -> pScreen, pDrawable -> width, pDrawable -> height, pDrawable -> depth, 0); if (pBitmap == NULL) @@ -2646,10 +2523,10 @@ void nxagentCreateDrawableBitmap(DrawablePtr pDrawable) ValidateGC((DrawablePtr) pBitmap, pGC); - x = pClipRegion -> extents.x1; - y = pClipRegion -> extents.y1; - w = pClipRegion -> extents.x2 - pClipRegion -> extents.x1; - h = pClipRegion -> extents.y2 - pClipRegion -> extents.y1; + int x = pClipRegion -> extents.x1; + int y = pClipRegion -> extents.y1; + int w = pClipRegion -> extents.x2 - pClipRegion -> extents.x1; + int h = pClipRegion -> extents.y2 - pClipRegion -> extents.y1; nxagentCopyArea(pDrawable, (DrawablePtr) pBitmap, pGC, x, y, w, h, x, y); @@ -3086,7 +2963,6 @@ nxagentSendBackgroundExposeEnd: void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2) { WindowPtr pWin = (WindowPtr) p0; - WindowPtr pParent; struct nxagentExposeBackground *pPair = p2; @@ -3112,7 +2988,7 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2) (void *) pWin); #endif - pParent = pWin -> parent; + WindowPtr pParent = pWin -> parent; while (pParent != NULL) { @@ -3140,21 +3016,14 @@ void nxagentExposeBackgroundPredicate(void *p0, XID x1, void *p2) int nxagentClipAndSendClearExpose(WindowPtr pWin, void * ptr) { - RegionPtr exposeRgn; - RegionPtr remoteExposeRgn; - - #ifdef DEBUG - BoxRec box; - #endif - - remoteExposeRgn = (RegionRec *) ptr; + RegionPtr remoteExposeRgn = (RegionRec *) ptr; if (nxagentWindowPriv(pWin) -> deferredBackgroundExpose == 1) { - exposeRgn = RegionCreate(NULL, 1); + RegionPtr exposeRgn = RegionCreate(NULL, 1); #ifdef DEBUG - box = *RegionExtents(remoteExposeRgn); + BoxRec box = *RegionExtents(remoteExposeRgn); fprintf(stderr, "nxagentClipAndSendClearExpose: Background expose extents: [%d,%d,%d,%d].\n", box.x1, box.y1, box.x2, box.y2); @@ -3230,4 +3099,3 @@ void nxagentSendDeferredBackgroundExposures(void) RegionEmpty(nxagentDeferredBackgroundExposures); } } - -- cgit v1.2.3 From 6d783bac27b665e1c1bc223ec2e7692dc42399da Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 01:30:06 +0200 Subject: Error.c: Code simplification --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index ed1580efa..6b91ea94d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -434,7 +434,6 @@ char *nxagentGetRootPath(void) */ struct stat dirStat; - if ((stat(nxagentRootDir, &dirStat) == -1) && (errno == ENOENT)) { if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST)) @@ -530,7 +529,6 @@ char *nxagentGetSessionPath(void) SAFE_free(rootPath); struct stat dirStat; - if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT)) { if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST)) @@ -567,7 +565,6 @@ char *nxagentGetSessionPath(void) void nxagentGetClientsPath(void) { - if (*nxagentClientsLogName == '\0') { char *sessionPath = nxagentGetSessionPath(); -- cgit v1.2.3 From 7f636648c700ff24a345bd0afb79b368e3e5edb1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 01:43:54 +0200 Subject: Font.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Font.c | 48 +++++++++++++------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 09ad471c8..a11fbda3c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -159,8 +159,7 @@ static struct _nxagentFailedToReconnectFonts } nxagentFailedToReconnectFonts = {NULL, NULL, 0, 0}; /* - * This is used if nxagentFullGeneration is true - * in CloseDisplay(). + * This is used if nxagentFullGeneration is true in CloseDisplay(). */ void nxagentFreeFontCache(void) @@ -218,8 +217,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) } /* - * Avoid querying again the remote - * fonts. + * Avoid querying again the remote fonts. */ if (nxagentRemoteFontList.length > 0) @@ -228,13 +226,11 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) } /* - * We can't retrieve the full remote font - * list with a single query, because the - * number of dashes in the pattern acts as - * a rule to select how to search for the - * font names, so the pattern '*' is useful - * to retrieve the font aliases, while the - * other one will select the 'real' fonts. + * We can't retrieve the full remote font list with a single query, + * because the number of dashes in the pattern acts as a rule to + * select how to search for the font names, so the pattern '*' is + * useful to retrieve the font aliases, while the other one will + * select the 'real' fonts. */ for (int p = 0; p < patternsQt; p++) @@ -246,8 +242,8 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) #endif /* - * Add the ListFont request pattern to the list with - * the last requested maxnames. + * Add the ListFont request pattern to the list with the last + * requested maxnames. */ nxagentListRemoteAddName(searchPattern, maxNames); @@ -686,11 +682,10 @@ int nxagentDestroyNewFontResourceType(void * p, XID id) #endif /* -FIXME: It happens that this resource had been already - destroyed. We should verify if the same font is - assigned both to the server client and another - client. We had a crash when freeing server client - resources. +FIXME: It happens that this resource had been already destroyed. We + should verify if the same font is assigned both to the server + client and another client. We had a crash when freeing server + client resources. */ if (nxagentFontPriv((FontPtr) p) != NULL) { @@ -706,8 +701,8 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP char substFontBuf[512];; - /* X Logical Font Description Conventions - * require 14 fields in the font names. + /* X Logical Font Description Conventions require 14 fields in the + * font names. * */ char *searchFields[FIELDS+1]; @@ -1067,8 +1062,7 @@ static void nxagentCleanCacheAfterReconnect(void) for (j = CACHE_INDEX - 1; CACHE_FSTRUCT(j) == NULL; j--); /* - * Now we can swap the two entry - * and reduce the Cache index + * Now we can swap the two entry and reduce the Cache index */ swapEntryPtr = CACHE_ENTRY(i); CACHE_ENTRY(i) = CACHE_ENTRY(j); @@ -1109,9 +1103,8 @@ Bool nxagentReconnectAllFonts(void *p0) #endif /* - * The resource type RT_NX_FONT is created on the - * server client only, so we can avoid to loop - * through all the clients. + * The resource type RT_NX_FONT is created on the server client + * only, so we can avoid to loop through all the clients. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, @@ -1341,9 +1334,8 @@ Bool nxagentDisconnectAllFonts(void) nxagentFreeCacheBeforeReconnect(); /* - * The resource type RT_NX_FONT is created on the - * server client only, so we can avoid to loop - * through all the clients. + * The resource type RT_NX_FONT is created on the server client + * only, so we can avoid to loop through all the clients. */ FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, -- cgit v1.2.3 From 5b3af018270e62ef7ceef88e93793427dad77574 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 01:44:19 +0200 Subject: Font.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Font.c | 45 +++++++++++-------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index a11fbda3c..93fb93295 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -707,8 +707,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP */ char *searchFields[FIELDS+1]; char *fontNameFields[FIELDS+1]; - int i; - int j; int numSearchFields = 0; int numFontFields = 0; int weight = 0; @@ -748,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP } else { - for (i = 1 ; i < nxagentRemoteFontList.length ; i++) + for (int i = 1 ; i < nxagentRemoteFontList.length ; i++) { numSearchFields = nxagentSplitString(nxagentRemoteFontList.list[i]->name, searchFields, FIELDS+1, "-"); @@ -773,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP tempWeight = 0; - for (j = 0; j < FIELDS; j++) + for (int j = 0; j < FIELDS; j++) { if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 || strcmp(searchFields[fieldOrder[j]], "") == 0 || @@ -801,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP #endif } - for (j = 0; j < numSearchFields; j++) + for (int j = 0; j < numSearchFields; j++) { SAFE_free(searchFields[j]); } @@ -818,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont); - for (j = 0; j < numFontFields; j++) + for (int j = 0; j < numFontFields; j++) { SAFE_free(fontNameFields[j]); } @@ -828,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) { - nxagentPrivFont *privFont; Bool *pBool = (Bool*)param2; if (pFont == NULL || !*pBool) return; - privFont = nxagentFontPriv(pFont); + nxagentPrivFont *privFont = nxagentFontPriv(pFont); #ifdef NXAGENT_RECONNECT_FONT_DEBUG fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n", @@ -931,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2) { int i; - nxagentPrivFont *privFont; Bool *pBool = (Bool*)param2; if (pFont == NULL) return; - privFont = nxagentFontPriv(pFont); + nxagentPrivFont *privFont = nxagentFontPriv(pFont); #ifdef NXAGENT_RECONNECT_FONT_DEBUG fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n", @@ -1622,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs) int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) { - int seplen; - int fieldlen; - int last; - int len; - int i; - - char *current; - char *next; - - seplen = strlen(sep); - len = strlen(string); + int seplen = strlen(sep); + int len = strlen(string); - current = string; + char *current = string; - i = 0; - last = 0; + int i = 0; + int last = 0; for (;;) { - next = NULL; + char *next = NULL; if (current < string + len) { @@ -1654,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) last = 1; } - fieldlen = next - current; + int fieldlen = next - current; if (i < nfields) { @@ -1681,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) { char *scalableFontName; - const char *s; - int field; /* FIXME: use str(n)dup()? */ if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL) @@ -1701,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) goto MakeScalableFontNameError; } - s = fontName; + const char *s = fontName; - field = 0; + int field = 0; while (s != NULL) { -- cgit v1.2.3 From fb03e31e564aa16128054038e66b9341eb5c7055 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 03:37:53 +0200 Subject: GC.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index df2fd2bb0..9d3ce2741 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -319,11 +319,11 @@ void nxagentChangeGC(GCPtr pGC, unsigned long mask) nxagentGCTrap == 0) { /* - * If the tile is corrupted and is not too much large, it can - * be synchronized imme- diately. In the other cases, the tile - * is cleared with a solid color to become usable. This - * approach should solve the high delay on slow links waiting - * for a background tile to be synchronized. + * If the tile is corrupted and is not too large, it can be + * synchronized immediately. In the other cases, the tile is + * cleared with a solid color to become usable. This approach + * should solve the high delay on slow links waiting for a + * background tile to be synchronized. */ if (nxagentOption(DeferLevel) >= 2 && -- cgit v1.2.3 From da60cb8cac23460c0ca4a8fa8014a3461fb5bdfa Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 03:38:37 +0200 Subject: GC.c: code simplifications / scope improvements --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 9d3ce2741..e7be173b3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -1112,10 +1112,9 @@ static void nxagentReconnectClip(GCPtr pGC, int type, void * pValue, int nRects) case CT_REGION: if (nxagentGCPriv(pGC)->pPixmap == NULL) { - XRectangle *pRects; nRects = RegionNumRects((RegionPtr)pValue); - int size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); + int size = nRects * sizeof(XRectangle *); + XRectangle *pRects = (XRectangle *) malloc(size); BoxPtr pBox = RegionRects((RegionPtr)pValue); for (int i = nRects; i-- > 0;) { pRects[i].x = pBox[i].x1; @@ -1409,12 +1408,12 @@ GCPtr nxagentCreateGraphicContext(int depth) return NULL; } - XID attributes[2]; - /* * Color used in nxagentFillRemoteRegion(). */ + XID attributes[2]; + attributes[0] = 0xc1c1c1; if (depth == 15 || depth == 16) -- cgit v1.2.3 From 193bda764f74a2c9c619cdf0675f3a78439c2e5e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 03:39:20 +0200 Subject: GC.c: blank line cleanup --- nx-X11/programs/Xserver/hw/nxagent/GC.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index e7be173b3..1feb62a4d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -66,6 +66,7 @@ is" without express or implied warranty. #include "../../fb/fb.h" RESTYPE RT_NX_GC; + /* * Set here the required log level. */ -- cgit v1.2.3 From 41bc1de9868233f155b459a3be0f821cc39ff931 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 04:05:37 +0200 Subject: GCOps.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index ebb993229..b4ddd5643 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -95,8 +95,7 @@ static int nxagentSaveGCTrap; RegionPtr nxagentBitBlitHelper(GC *pGC); /* - * The NX agent implementation of the - * X server's graphics functions. + * The NX agent implementation of the X server's graphics functions. */ void nxagentFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nSpans, @@ -170,7 +169,7 @@ void nxagentQueryBestSize(int class, unsigned short *pwidth, case StippleShape: width = *pwidth; if (!width) break; - /* Return the closes power of two not less than what they gave me */ + /* Return the closest power of two not less than what they gave me */ test = 0x80000000; /* Find the highest 1 bit in the width given */ while(!(test & width)) @@ -456,9 +455,8 @@ FIXME: The popup could be synchronized with one single put image, if (RegionNumRects(pClipRegion) == 1) { /* - * If the region to copy is formed by one - * rectangle, we change only the copy coor- - * dinates. + * If the region to copy is formed by one rectangle, we change + * only the copy coordinates. */ srcx = srcx + pClipRegion -> extents.x1 - dstx; -- cgit v1.2.3 From 8e66435a54f2d8c74249329503555e3e216b369b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 04:08:21 +0200 Subject: GCOps.c: code simplification / scope improvements --- nx-X11/programs/Xserver/hw/nxagent/GCOps.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c index b4ddd5643..5ac341990 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCOps.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GCOps.c @@ -296,7 +296,6 @@ FIXME: The popup could be synchronized with one single put image, #endif RegionRec corruptedRegion; - RegionInit(&corruptedRegion, NullBox, 1); RegionIntersect(&corruptedRegion, @@ -374,7 +373,6 @@ FIXME: The popup could be synchronized with one single put image, else { RegionRec tmpRegion; - RegionInit(&tmpRegion, NullBox, 1); #ifdef DEBUG @@ -540,14 +538,13 @@ FIXME: The popup could be synchronized with one single put image, { RegionPtr pSrcRegion = nxagentCreateRegion(pSrcDrawable, NULL, srcx, srcy, width, height); - RegionRec corruptedRegion; - #ifdef DEBUG fprintf(stderr, "nxagentDeferCopyArea: Source region [%d,%d,%d,%d].\n", pSrcRegion -> extents.x1, pSrcRegion -> extents.y1, pSrcRegion -> extents.x2, pSrcRegion -> extents.y2); #endif + RegionRec corruptedRegion; RegionInit(&corruptedRegion, NullBox, 1); RegionIntersect(&corruptedRegion, @@ -728,9 +725,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - int leftPad = 0; - - int length = nxagentImageLength(width, height, format, leftPad, depth); + int length = nxagentImageLength(width, height, format, 0, depth); if ((data = malloc(length)) == NULL) { @@ -742,7 +737,6 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } unsigned long planeMask = 0xffffffff; - fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* @@ -751,7 +745,7 @@ RegionPtr nxagentCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, */ nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty, - width, height, leftPad, format, data); + width, height, 0, format, data); #ifdef TEST fprintf(stderr,"nxagentCopyArea: Realize Pixmap %p virtual %p x %d y %d w %d h %d\n", @@ -939,9 +933,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, unsigned int format = (depth == 1) ? XYPixmap : ZPixmap; - int leftPad = 0; - - int length = nxagentImageLength(width, height, format, leftPad, depth); + int length = nxagentImageLength(width, height, format, 0, depth); if ((data = malloc(length)) == NULL) { @@ -953,7 +945,6 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, } unsigned long planeMask = 0xffffffff; - fbGetImage(nxagentVirtualDrawable(pSrcDrawable), srcx, srcy, width, height, format, planeMask, data); /* @@ -962,7 +953,7 @@ RegionPtr nxagentCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, */ nxagentPutImage(pDstDrawable, pGC, depth, dstx, dsty, - width, height, leftPad, format, data); + width, height, 0, format, data); #ifdef TEST fprintf(stderr,"nxagentCopyPlane: Synchronize Pixmap %p virtual %p x %d y %d w %d h %d \n", -- cgit v1.2.3 From d87988aa2b8bfb4dbab6a9f36a6ccd587088ecba Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 14:22:23 +0200 Subject: Handlers.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Handlers.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c index 2c0ee731a..f1455b935 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Handlers.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Handlers.c @@ -287,22 +287,19 @@ void nxagentBlockHandler(void * data, struct timeval **timeout, void * mask) /* * The synchronization function requires a mask as parameter: * - * EVENT_BREAK Breaks if an user input, like - * a key press or a mouse move, - * is detected. + * EVENT_BREAK Breaks if an user input, like a key press + * or a mouse move, is detected. * - * CONGESTION_BREAK Breaks if the congestion beco- - * mes greater than 4. + * CONGESTION_BREAK Breaks if the congestion becomes greater + * than 4. * - * BLOCKING_BREAK Breaks if the display descript- - * or becomes blocked for write - * during the loop. + * BLOCKING_BREAK Breaks if the display descriptor becomes + * blocked for write during the loop. * - * ALWAYS_BREAK Any of the previous conditions - * is met. + * ALWAYS_BREAK Any of the previous conditions is met. * - * NEVER_BREAK The loop continues until all - * the drawables are synchronized. + * NEVER_BREAK The loop continues until all the drawables + * are synchronized. */ if (synchronize == 1) -- cgit v1.2.3 From c5c821482235048edc1f995b5ade00f38d5b7068 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 14:37:18 +0200 Subject: Init.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Init.c | 94 ++++++++++--------------------- 1 file changed, 31 insertions(+), 63 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 0b4ffd601..c6952c52c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -89,44 +89,35 @@ is" without express or implied warranty. /* * ProcVector array defined in tables.c. */ - extern int (*ProcVector[256])(ClientPtr); /* * From the fb code. */ - extern int fbGCPrivateIndex; +#ifdef DPMSExtension /* * Stubs for the DPMS extension. */ - -#ifdef DPMSExtension - void DPMSSet(int level); int DPMSGet(int *level); Bool DPMSSupported(void); - #endif /* * Our error logging function. */ - void OsVendorVErrorFFunction(const char *f, va_list args); /* * True if this is a fatal error. */ - extern int OsVendorVErrorFFatal; /* - * Redirect the error output to a - * different file + * Redirect the error output to a different file */ - extern void (*OsVendorStartRedirectErrorFProc)(); extern void (*OsVendorEndRedirectErrorFProc)(); @@ -136,11 +127,8 @@ void OsVendorStartRedirectErrorFFunction(); void OsVendorEndRedirectErrorFFunction(); /* - * Called by InitGlobals() in the - * new X server tree. + * Called by InitGlobals() in the new X server tree. */ - - static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data, void *args); @@ -164,12 +152,11 @@ void ddxInitGlobals(void) } /* - * Set if the remote display supports - * backing store. + * Set if the remote display supports backing store. */ /* -FIXME: These, if not removed, should at least - be moved to Display.h and Display.c. +FIXME: These, if not removed, should at least be moved to Display.h + and Display.c. */ int nxagentBackingStore; int nxagentSaveUnder; @@ -187,7 +174,6 @@ int nxagentSaveUnder; * nxagentOpenScreen * InitInput */ - int nxagentDoFullGeneration = 1; /* @@ -197,9 +183,8 @@ int nxagentDoFullGeneration = 1; Bool nxagentX2go; /* - * Check if agent is x2go agent + * Check if agent is X2goAgent */ - void checkX2goAgent(void) { #ifdef TEST @@ -215,11 +200,9 @@ void checkX2goAgent(void) nxagentX2go = False; } - /* * Called at X server's initialization. */ - void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) { /* @@ -244,8 +227,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) } /* - * Avoid slowness due to buggy_repeat workaround - * in libcairo versions >= 1.10. + * Avoid slowness due to buggy_repeat workaround in libcairo + * versions >= 1.10. */ SetVendorRelease(70000000); @@ -260,9 +243,8 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) } /* - * Unset the LD_LIBRARY_PATH variable in - * Popen() before calling execl() in the - * child process. + * Unset the LD_LIBRARY_PATH variable in Popen() before calling + * execl() in the child process. */ NXUnsetLibraryPath(1); @@ -314,15 +296,13 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) nxagentInitBSPixmapList(); /* - * Open the display. We are at the early startup and - * the information we'll get from the remote X server - * will mandate some of the characteristics of the - * session, like the screen depth. Note that this re- - * liance on the remote display at session startup - * should be removed. We should always operate at 32 - * bpp, internally, and do the required translations - * as soon as the graphic operation needs to be real- - * ized on the remote display. + * Open the display. We are at the early startup and the information + * we'll get from the remote X server will mandate some of the + * characteristics of the session, like the screen depth. Note that + * this reliance on the remote display at session startup should be + * removed. We should always operate at 32 bpp, internally, and do + * the required translations as soon as the graphic operation needs + * to be realized on the remote display. */ nxagentOpenDisplay(argc, argv); @@ -393,9 +373,8 @@ FIXME: These variables, if not removed at all because have probably nxagentNumScreens = screenInfo->numScreens; /* - * Initialize the GCs used by the synchro- - * nization put images. We do it here beca- - * use we use the nxagentDefaultScreen. + * Initialize the GCs used by the synchronization put images. We do + * it here because we use the nxagentDefaultScreen. */ nxagentAllocateGraphicContexts(); @@ -403,8 +382,7 @@ FIXME: These variables, if not removed at all because have probably nxagentDoFullGeneration = nxagentFullGeneration; /* - * Use a solid black root window - * background. + * Use a solid black root window background. */ if (!whiteRoot) @@ -440,9 +418,8 @@ void InitInput(argc, argv) mieqInit(kbd, ptr); /* - * Add the display descriptor to the - * set of descriptors awaited by the - * dispatcher. + * Add the display descriptor to the set of descriptors awaited by + * the dispatcher. */ nxagentAddXConnection(); @@ -457,10 +434,9 @@ void InitInput(argc, argv) } /* - * We let the proxy flush the link on our behalf - * after having opened the display. We are now - * entering the dispatcher. From now on we'll - * flush the proxy link explicitly. + * We let the proxy flush the link on our behalf after having opened + * the display. We are now entering the dispatcher. From now on + * we'll flush the proxy link explicitly. */ #ifdef TEST @@ -471,11 +447,9 @@ void InitInput(argc, argv) } /* - * DDX specific abort routine. This is called - * by AbortServer() that, in turn, is called - * by FatalError(). + * DDX specific abort routine. This is called by AbortServer() that, + * in turn, is called by FatalError(). */ - void AbortDDX(void) { nxagentDoFullGeneration = True; @@ -483,9 +457,8 @@ void AbortDDX(void) nxagentCloseDisplay(); /* - * Do the required finalization if we - * are not going through the normal - * X server shutdown. + * Do the required finalization if we are not going through the + * normal X server shutdown. */ if ((dispatchException & DE_TERMINATE) == 0) @@ -497,7 +470,6 @@ void AbortDDX(void) /* * Called by GiveUp(). */ - void ddxGiveUp(void) { AbortDDX(); @@ -515,12 +487,10 @@ void OsVendorInit(void) void OsVendorFatalError(void) { /* - * Let the session terminate gracely - * from an user's standpoint. + * Let the session terminate gracely from an user's standpoint. */ fprintf(stderr, "Session: Aborting session at '%s'.\n", GetTimeAsString()); - fprintf(stderr, "Session: Session aborted at '%s'.\n", GetTimeAsString()); } @@ -566,7 +536,6 @@ static void nxagentGrabServerCallback(CallbackListPtr *callbacks, void *data, } #ifdef DPMSExtension - void DPMSSet(int level) { } @@ -580,5 +549,4 @@ Bool DPMSSupported(void) { return 0; } - #endif -- cgit v1.2.3 From e3b4405474972a8528f5a108b9990885760e067a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 14:37:29 +0200 Subject: Init.c: rewrite two function prototypes --- nx-X11/programs/Xserver/hw/nxagent/Init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index c6952c52c..3cba1a89d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -397,15 +397,12 @@ FIXME: These variables, if not removed at all because have probably nxagentInitAtoms(); } -void -nxagentNotifyConnection(int fd, int ready, void *data) +void nxagentNotifyConnection(int fd, int ready, void *data) { nxagentDispatchEvents(NULL); } -void InitInput(argc, argv) - int argc; - char *argv[]; +void InitInput(int argc, char *argv[]) { void *ptr, *kbd; -- cgit v1.2.3 From 58415b5609c13c8efe58a674366f136f6217e060 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 14:40:10 +0200 Subject: Keyboard.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 43 +++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index a79052080..1ff058659 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -104,10 +104,9 @@ static void nxagentWriteKeyboardFile(char *rules, char *model, char *layout, cha #endif /* - * Unfortunately we cannot just include XKBlib.h. - * It conflicts with the server side definitions - * of the same symbols. This is more a X problem - * than our. + * Unfortunately we cannot just include XKBlib.h. It conflicts with + * the server side definitions of the same symbols. This is more a X + * problem than our. */ #ifdef XKB @@ -158,8 +157,7 @@ static char *nxagentRemoteOptions = NULL; XkbAgentInfoRec nxagentXkbInfo = { -1, -1, -1, -1, -1 }; /* - * Keyboard status, updated through XKB - * events. + * Keyboard status, updated through XKB events. */ XkbAgentStateRec nxagentXkbState = { 0, 0, 0, 0, 0 }; @@ -283,9 +281,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) /* * We want to prevent agent generating auto-repeated - * keystrokes. Let's intercept any attempt by appli- - * cations to change the default timeouts on the - * nxagent device. + * keystrokes. Let's intercept any attempt by appli- cations to + * change the default timeouts on the nxagent device. */ #ifdef TEST @@ -305,8 +302,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) #endif /* - * If enabled, propagate the changes to the - * devices attached to the real X server. + * If enabled, propagate the changes to the devices attached to the + * real X server. */ if (nxagentOption(DeviceControl)) @@ -328,8 +325,8 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) }; /* - * Don't propagate the auto repeat mode. It is forced to be - * off in the agent server. + * Don't propagate the auto repeat mode. It is forced to be off in + * the agent server. * * value_mask |= KBAutoRepeatMode; * values.auto_repeat_mode = ctrl->autoRepeat ? @@ -339,9 +336,9 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) XChangeKeyboardControl(nxagentDisplay, value_mask, &values); /* - * At this point, we need to walk through the vector and - * compare it to the current server vector. If there are - * differences, report them. + * At this point, we need to walk through the vector and compare + * it to the current server vector. If there are differences, + * report them. */ value_mask = KBLed | KBLedMode; @@ -403,11 +400,11 @@ N/A #endif /* - * Prevent agent from generating auto-repeat keystroke. - * Note that this is working only if XKB is enabled. - * A better solution should account cases where XKB is - * not available. Check also the behaviour of the - * DeviceControl nxagent option. + * Prevent agent from generating auto-repeat keystroke. Note + * that this is working only if XKB is enabled. A better + * solution should account cases where XKB is not + * available. Check also the behaviour of the DeviceControl + * nxagent option. */ XkbDfltRepeatDelay = ~ 0; @@ -607,8 +604,8 @@ XkbError: } /* - * There is no description for pc105 on Solaris. - * Need to revert to the closest approximation. + * There is no description for pc105 on Solaris. Need to + * revert to the closest approximation. */ #ifdef TEST -- cgit v1.2.3 From cb283d4aa42fb8564cf1e8f3760517dd74b7d590 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Sep 2019 14:56:46 +0200 Subject: Keyboard.c: code simplification / scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 64 ++++++++++++--------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 1ff058659..faabb2ebe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -312,10 +312,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) fprintf(stderr, "%s: WARNING! Propagating changes to keyboard settings.\n", __func__); #endif - unsigned long value_mask = KBKeyClickPercent | - KBBellPercent | - KBBellPitch | - KBBellDuration; + unsigned long value_mask = KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration; XKeyboardControl values = { .key_click_percent = ctrl->click, @@ -426,10 +423,9 @@ N/A #ifdef _XSERVER64 { KeySym64 *keymap64 = XGetKeyboardMapping(nxagentDisplay, - min_keycode, - max_keycode - min_keycode + 1, - &mapWidth); - + min_keycode, + max_keycode - min_keycode + 1, + &mapWidth); if (keymap64 == NULL) { XFreeModifiermap(modifier_keymap); @@ -867,7 +863,6 @@ void nxagentNotifyKeyboardChanges(int oldMinKeycode, int oldMaxKeycode) #endif xEvent event = {0}; - event.u.u.type = MappingNotify; event.u.mappingNotify.request = MappingKeyboard; event.u.mappingNotify.firstKeyCode = inputInfo.keyboard -> key -> curKeySyms.minKeyCode; @@ -940,12 +935,11 @@ int nxagentResetKeyboard(void) } #endif - dev->key=NULL; + dev->key = NULL; } - dev->focus=NULL; - - dev->kbdfeed=NULL; + dev->focus = NULL; + dev->kbdfeed = NULL; #ifdef XKB nxagentTuneXkbWrapper(); @@ -1091,37 +1085,37 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) if (dev->key) { - #ifdef XKB - if (noXkbExtension == 0 && dev->key->xkbInfo) - { - XkbFreeInfo(dev->key->xkbInfo); - dev->key->xkbInfo = NULL; - } - #endif + #ifdef XKB + if (noXkbExtension == 0 && dev->key->xkbInfo) + { + XkbFreeInfo(dev->key->xkbInfo); + dev->key->xkbInfo = NULL; + } + #endif - SAFE_free(dev->key->curKeySyms.map); - SAFE_free(dev->key->modifierKeyMap); - SAFE_free(dev->key); + SAFE_free(dev->key->curKeySyms.map); + SAFE_free(dev->key->modifierKeyMap); + SAFE_free(dev->key); } if (dev->focus) { - SAFE_free(dev->focus->trace); - SAFE_free(dev->focus); + SAFE_free(dev->focus->trace); + SAFE_free(dev->focus); } if (dev->kbdfeed) { - for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext) - { - knext = k->next; - #ifdef XKB - if (k->xkb_sli) - XkbFreeSrvLedInfo(k->xkb_sli); - #endif - SAFE_free(k); - } - dev->kbdfeed = NULL; + for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext) + { + knext = k->next; + #ifdef XKB + if (k->xkb_sli) + XkbFreeSrvLedInfo(k->xkb_sli); + #endif + SAFE_free(k); + } + dev->kbdfeed = NULL; } #ifdef DEBUG -- cgit v1.2.3 From 53b3d4df3abdbc036ff07e253739822118e239a5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 00:31:28 +0100 Subject: Split.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Split.c | 101 ++++++++++++----------------- 1 file changed, 41 insertions(+), 60 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c index 33005e86d..f2005e9d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Split.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c @@ -36,7 +36,6 @@ #include "compext/Compext.h" - /* * Set here the required log level. */ @@ -47,9 +46,8 @@ #undef DEBUG /* - * This should be a macro but for now - * we make it a real function to log - * a warning in the logs. + * This should be a macro but for now we make it a real function to + * log a warning in the logs. */ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable) @@ -348,8 +346,7 @@ int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC) pResource -> commit = 1; /* - * Make a copy of the GC so the client - * can safely remove it. + * Make a copy of the GC so the client can safely remove it. */ pResource -> gc = CreateScratchGC(pDrawable -> pScreen, pDrawable -> depth); @@ -400,8 +397,7 @@ FIXME: What do we do here? } /* - * Set the region to be the current - * streaming region. + * Set the region to be the current streaming region. */ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) @@ -442,9 +438,9 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) } /* - * Remove the association between the drawable - * and the split resource. The resource is not - * deallocated until the end of the split. + * Remove the association between the drawable and the split + * resource. The resource is not deallocated until the end of the + * split. */ void nxagentReleaseSplit(DrawablePtr pDrawable) @@ -477,10 +473,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) if (pResource -> region != NullRegion) { /* - * If we have a region the commits - * had to be still valid. In this - * case tell the proxy to abort the - * data transfer. + * If we have a region the commits had to be still valid. In this + * case tell the proxy to abort the data transfer. */ #ifdef TEST @@ -528,8 +522,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) } /* - * Remove the association between the - * drawable and the resource record. + * Remove the association between the drawable and the resource + * record. */ #ifdef TEST @@ -547,9 +541,8 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) } /* - * Invalidate the commits and remove the - * association between the resource and - * the drawable. + * Invalidate the commits and remove the association between the + * resource and the drawable. */ pResource -> drawable = NULL; @@ -607,9 +600,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) #endif /* - * If a null region is passed as parameter, - * we assume that all the commits have to - * be discarded. + * If a null region is passed as parameter, we assume that all the + * commits have to be discarded. */ if (pRegion == NullRegion) @@ -626,9 +618,8 @@ void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) RegionRec tmpRegion; /* - * Check if the provided region overlaps - * the area covered by the image being - * streamed. + * Check if the provided region overlaps the area covered by the + * image being streamed. */ RegionInit(&tmpRegion, NullBox, 1); @@ -698,10 +689,9 @@ void nxagentFreeSplit(int resource) else { /* - * The end of the split has come after we have - * invalidated the operation and removed the - * association to the drawable. This happens, - * for example, if the drawable is destroyed. + * The end of the split has come after we have invalidated the + * operation and removed the association to the drawable. This + * happens, for example, if the drawable is destroyed. */ fprintf(stderr, "nxagentFreeSplit: WARNING! Releasing invalidated resource [%d].\n", @@ -718,8 +708,8 @@ void nxagentFreeSplit(int resource) } /* -FIXME: This must be enabled when the vanilla - synchronization procedure is working. +FIXME: This must be enabled when the vanilla synchronization procedure + is working. */ #define USE_FINISH_SPLIT @@ -747,8 +737,7 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) #endif /* - * Be sure we intercept an I/O error - * as well as an interrupt. + * Be sure we intercept an I/O error as well as an interrupt. */ #ifdef USE_FINISH_SPLIT @@ -762,21 +751,18 @@ void nxagentWaitDrawable(DrawablePtr pDrawable) for (;;) { /* - * Handling all the possible events here - * preempts the queue and makes a better - * use of the link. + * Handling all the possible events here preempts the queue and + * makes a better use of the link. * - * We should better use XIfEvent() instead - * of looping again and again through the - * event queue. + * We should better use XIfEvent() instead of looping again and + * again through the event queue. */ nxagentDispatchEvents(NULL); /* - * Wait indefinitely until the resource - * is released or the display is shut - * down. + * Wait indefinitely until the resource is released or the display + * is shut down. */ if (nxagentSplitResource(pDrawable) == NULL || @@ -821,16 +807,14 @@ void nxagentWaitCommitEvent(int resource) XEvent event; /* - * Check if there is any commit pending. As - * we are at it, handle any commit, even those - * commits pertaining to other resources. + * Check if there is any commit pending. As we are at it, handle any + * commit, even those commits pertaining to other resources. * - * We can receive some commits even if we'll - * later receive a no-split event. The proxy, - * in fact, may have missed to find the image - * in the memory cache and could have loaded it - * from disk (so requiring a commit) before we - * marked the end of the split sequence. + * We can receive some commits even if we'll later receive a + * no-split event. The proxy, in fact, may have missed to find the + * image in the memory cache and could have loaded it from disk (so + * requiring a commit) before we marked the end of the split + * sequence. */ while (nxagentCheckEvents(nxagentDisplay, &event, @@ -866,9 +850,8 @@ int nxagentWaitSplitEvent(int resource) int split = 0; /* - * Don't flush the link. We only want to - * query the NX transport to check whether - * the operation caused a split. + * Don't flush the link. We only want to query the NX transport to + * check whether the operation caused a split. */ NXFlushDisplay(nxagentDisplay, NXFlushBuffer); @@ -1223,10 +1206,9 @@ void nxagentSetCorruptedTimestamp(DrawablePtr pDrawable) } /* - * Reset the timestamp taken when the drawable - * became initially corrupted. The timestamp is - * reset only after the drawable has been fully - * synchronized. + * Reset the timestamp taken when the drawable became initially + * corrupted. The timestamp is reset only after the drawable has been + * fully synchronized. */ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable) @@ -1253,4 +1235,3 @@ void nxagentResetCorruptedTimestamp(DrawablePtr pDrawable) } } } - -- cgit v1.2.3 From bcca31996c07ee57d7507009b94e8d9c40a37a99 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 00:32:12 +0100 Subject: Split.c: scope improvements/code simplification --- nx-X11/programs/Xserver/hw/nxagent/Split.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Split.c b/nx-X11/programs/Xserver/hw/nxagent/Split.c index f2005e9d5..4dac8f5b2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Split.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Split.c @@ -71,13 +71,11 @@ DrawablePtr nxagentSplitDrawable(DrawablePtr pDrawable) void nxagentInitSplitResources(void) { - int resource; - #ifdef TEST fprintf(stderr, "nxagentInitSplitResources: Initializing the split resources.\n"); #endif - for (resource = 0; resource < NXNumberOfResources; resource++) + for (int resource = 0; resource < NXNumberOfResources; resource++) { SplitResourcePtr pResource = &nxagentSplitResources[resource]; @@ -95,8 +93,6 @@ SplitResourcePtr nxagentAllocSplitResource(void) { int resource; - SplitResourcePtr pResource; - for (;;) { resource = NXAllocSplit(nxagentDisplay, NXAnyResource); @@ -122,7 +118,7 @@ FIXME: Must deal with the case all resources are exausted. } } - pResource = &nxagentSplitResources[resource]; + SplitResourcePtr pResource = &nxagentSplitResources[resource]; if (pResource -> pending != 0 || pResource -> split != NXNoResource || pResource -> unpack != NXNoResource || pResource -> drawable != NULL || @@ -215,13 +211,11 @@ FIXME: This must be implemented. void nxagentReleaseAllSplits(void) { - int resource; - #ifdef TEST fprintf(stderr, "nxagentReleaseAllSplits: Going to release all the split resources.\n"); #endif - for (resource = 0; resource < NXNumberOfResources; resource++) + for (int resource = 0; resource < NXNumberOfResources; resource++) { SplitResourcePtr pResource = &nxagentSplitResources[resource]; @@ -327,11 +321,9 @@ static void nxagentCheckResource(SplitResourcePtr pResource, int resource) int nxagentCreateSplit(DrawablePtr pDrawable, GCPtr *pGC) { - SplitResourcePtr pResource; - pDrawable = nxagentSplitDrawable(pDrawable); - pResource = nxagentAllocSplitResource(); + SplitResourcePtr pResource = nxagentAllocSplitResource(); if (pDrawable -> type == DRAWABLE_PIXMAP) { @@ -402,11 +394,9 @@ FIXME: What do we do here? void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) { - SplitResourcePtr pResource; - pDrawable = nxagentSplitDrawable(pDrawable); - pResource = nxagentSplitResource(pDrawable); + SplitResourcePtr pResource = nxagentSplitResource(pDrawable); #ifdef TEST @@ -445,11 +435,9 @@ void nxagentRegionSplit(DrawablePtr pDrawable, RegionPtr pRegion) void nxagentReleaseSplit(DrawablePtr pDrawable) { - SplitResourcePtr pResource; - pDrawable = nxagentSplitDrawable(pDrawable); - pResource = nxagentSplitResource(pDrawable); + SplitResourcePtr pResource = nxagentSplitResource(pDrawable); if (pResource == NULL) { @@ -551,11 +539,9 @@ void nxagentReleaseSplit(DrawablePtr pDrawable) void nxagentValidateSplit(DrawablePtr pDrawable, RegionPtr pRegion) { - SplitResourcePtr pResource; - pDrawable = nxagentSplitDrawable(pDrawable); - pResource = nxagentSplitResource(pDrawable); + SplitResourcePtr pResource = nxagentSplitResource(pDrawable); if (pResource == NULL) { -- cgit v1.2.3 From 5db6217ccdb03f5841498f6c69e338da7f06c04b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:28:18 +0100 Subject: Visual.c: code improvements/desginated initializers --- nx-X11/programs/Xserver/hw/nxagent/Visual.c | 36 +++++++++++------------------ 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.c b/nx-X11/programs/Xserver/hw/nxagent/Visual.c index a29560d43..ea73ce50e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.c @@ -64,19 +64,17 @@ Visual nxagentAlphaVisual; Visual *nxagentVisual(VisualPtr pVisual) { - XVisualInfo visual; - - int i; - - visual.class = pVisual->class; - visual.bits_per_rgb = pVisual->bitsPerRGBValue; - visual.colormap_size = pVisual->ColormapEntries; - visual.depth = pVisual->nplanes; - visual.red_mask = pVisual->redMask; - visual.green_mask = pVisual->greenMask; - visual.blue_mask = pVisual->blueMask; - - for (i = 0; i < nxagentNumVisuals; i++) + XVisualInfo visual = { + .class = pVisual->class, + .bits_per_rgb = pVisual->bitsPerRGBValue, + .colormap_size = pVisual->ColormapEntries, + .depth = pVisual->nplanes, + .red_mask = pVisual->redMask, + .green_mask = pVisual->greenMask, + .blue_mask = pVisual->blueMask + }; + + for (int i = 0; i < nxagentNumVisuals; i++) { if (nxagentCompareVisuals(visual, nxagentVisuals[i]) == 1) { @@ -89,9 +87,7 @@ Visual *nxagentVisual(VisualPtr pVisual) Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual) { - int i; - - for (i = 0; i < pScreen->numVisuals; i++) + for (int i = 0; i < pScreen->numVisuals; i++) { if (pScreen->visuals[i].vid == visual) { @@ -104,9 +100,7 @@ Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual) Colormap nxagentDefaultVisualColormap(Visual *visual) { - int i; - - for (i = 0; i < nxagentNumVisuals; i++) + for (int i = 0; i < nxagentNumVisuals; i++) { if (nxagentVisuals[i].visual == visual) { @@ -126,9 +120,7 @@ Colormap nxagentDefaultVisualColormap(Visual *visual) Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) { - int i; - - for (i = 0; i < pScreen->numVisuals; i++) + for (int i = 0; i < pScreen->numVisuals; i++) { if (pScreen->visuals[i].nplanes == depth) { -- cgit v1.2.3 From 1bb0e999eb7ad6bbc6c470a2ecf833c22500b5c1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:28:51 +0100 Subject: Visual.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Visual.c | 17 +++++++---------- nx-X11/programs/Xserver/hw/nxagent/Visual.h | 13 +++++-------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.c b/nx-X11/programs/Xserver/hw/nxagent/Visual.c index ea73ce50e..43f582f16 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.c @@ -112,10 +112,9 @@ Colormap nxagentDefaultVisualColormap(Visual *visual) } /* - * This is currently unused. It should serve - * the scope of matching a visual whenever - * a drawable has a different depth than the - * real display. + * This is currently unused. It should serve the scope of matching a + * visual whenever a drawable has a different depth than the real + * display. */ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) @@ -132,9 +131,8 @@ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) } /* - * Create a fake 32 bits depth visual and - * initialize it based on the endianness - * of the remote display. + * Create a fake 32 bits depth visual and initialize it based on the + * endianness of the remote display. */ void nxagentInitAlphaVisual(void) @@ -142,9 +140,8 @@ void nxagentInitAlphaVisual(void) nxagentAlphaVisual.visualid = XAllocID(nxagentDisplay); /* - * Color masks are referred to bits inside - * the pixel. This is independent from the - * endianness. + * Color masks are referred to bits inside the pixel. This is + * independent from the endianness. */ nxagentAlphaVisual.red_mask = 0x00ff0000; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.h b/nx-X11/programs/Xserver/hw/nxagent/Visual.h index 70799f3f8..cfb0f8977 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.h @@ -50,17 +50,14 @@ Colormap nxagentDefaultVisualColormap(Visual *visual); nxagentVisualFromID((pScreen), (pScreen) -> rootVisual) /* - * Visual generated by Xorg and Xfree86 at - * 16-bit depth differs on the bits_per_rgb - * value, so we avoid checking it. + * Visual generated by Xorg and Xfree86 at 16-bit depth differs on the + * bits_per_rgb value, so we avoid checking it. */ /* - * Some Solaris X servers uses the color - * masks inverted, so that the red and - * the blue mask are switched. To reconnect - * the session on this displays, we do a - * double check, as workaround. + * Some Solaris X servers uses the color masks inverted, so that the + * red and the blue mask are switched. To reconnect the session on + * this displays, we do a double check, as workaround. */ #define nxagentCompareVisuals(v1, v2) \ -- cgit v1.2.3 From 22f01d23a0a324d8a7a74a8e688ff05caf828f6e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:29:11 +0100 Subject: Visual.{ch}: disable unused code --- nx-X11/programs/Xserver/hw/nxagent/Visual.c | 2 ++ nx-X11/programs/Xserver/hw/nxagent/Visual.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.c b/nx-X11/programs/Xserver/hw/nxagent/Visual.c index 43f582f16..6be82148f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.c @@ -111,6 +111,7 @@ Colormap nxagentDefaultVisualColormap(Visual *visual) return None; } +#if 0 /* * This is currently unused. It should serve the scope of matching a * visual whenever a drawable has a different depth than the real @@ -129,6 +130,7 @@ Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth) return NULL; } +#endif /* * Create a fake 32 bits depth visual and initialize it based on the diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.h b/nx-X11/programs/Xserver/hw/nxagent/Visual.h index cfb0f8977..40946f3c0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.h @@ -42,7 +42,10 @@ is" without express or implied warranty. Visual *nxagentVisual(VisualPtr pVisual); Visual *nxagentVisualFromID(ScreenPtr pScreen, VisualID visual); + +#if 0 Visual *nxagentVisualFromDepth(ScreenPtr pScreen, int depth); +#endif Colormap nxagentDefaultVisualColormap(Visual *visual); -- cgit v1.2.3 From c9549f3c912136e5a99888b0959438b2693591f2 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:32:19 +0100 Subject: Pointer.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Pointer.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index d344f34b0..ab5496773 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -66,8 +66,8 @@ is" without express or implied warranty. #undef DEBUG /* - * The nxagentReversePointerMap array is used to - * memorize remote display pointer map. + * The nxagentReversePointerMap array is used to memorize remote + * display pointer map. */ unsigned char nxagentReversePointerMap[MAXBUTTONS]; @@ -76,13 +76,12 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) { /* * The original behaviour was to reset the pointer settings - * (acceleration and alas) to the default values. What the - * average user expects, on the contrary, is to have agent - * inheriting whatever value is set on the real X display. - * Having to reflect changes made inside the agent session, - * the correct behavior would be saving the original values - * and restoring them as soon as focus leaves the agent's - * window. + * (acceleration and alas) to the default values. What the average + * user expects, on the contrary, is to have agent inheriting + * whatever value is set on the real X display. Having to reflect + * changes made inside the agent session, the correct behavior would + * be saving the original values and restoring them as soon as focus + * leaves the agent's window. */ if (nxagentOption(DeviceControl) == True) -- cgit v1.2.3 From 024a2bc2e56d5851c584fd34c497d6749170593c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:32:35 +0100 Subject: Pointer.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Pointer.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index ab5496773..379a19fa0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -103,10 +103,6 @@ void nxagentChangePointerControl(DeviceIntPtr pDev, PtrCtrl *ctrl) int nxagentPointerProc(DeviceIntPtr pDev, int onoff) { - CARD8 map[MAXBUTTONS]; - int nmap; - int i; - switch (onoff) { case DEVICE_INIT: @@ -120,8 +116,10 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) return Success; } - nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS); - for (i = 0; i <= nmap; i++) + CARD8 map[MAXBUTTONS]; + + int nmap = XGetPointerMapping(nxagentDisplay, map, MAXBUTTONS); + for (int i = 0; i <= nmap; i++) map[i] = i; /* buttons are already mapped */ InitPointerDeviceStruct((DevicePtr) pDev, map, nmap, miPointerGetMotionEvents, @@ -173,10 +171,6 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) void nxagentInitPointerMap(void) { - int numButtons; - - int i; - unsigned char pointerMap[MAXBUTTONS]; #ifdef DEBUG @@ -184,13 +178,13 @@ void nxagentInitPointerMap(void) "pointer map from remote display.\n"); #endif - numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS); + int numButtons = XGetPointerMapping(nxagentDisplay, pointerMap, MAXBUTTONS); /* * Computing revers pointer map. */ - for (i = 1; i <= numButtons; i++) + for (int i = 1; i <= numButtons; i++) { nxagentReversePointerMap[pointerMap[i - 1]] = i; } -- cgit v1.2.3 From 78bb80a84a4e4f0955e11d05bf20710ea97e0997 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:33:54 +0100 Subject: Options.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Options.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.c b/nx-X11/programs/Xserver/hw/nxagent/Options.c index 5c3a44c23..9e11dc5f2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.c @@ -34,10 +34,9 @@ #include "Utils.h" /* - * Instead of having a single options repository - * data could be attached to the display or the - * screen. The macro nxagentOption() should make - * the transition simple. + * Instead of having a single options repository data could be + * attached to the display or the screen. The macro nxagentOption() + * should make the transition simple. */ AgentOptionsRec nxagentOptions; @@ -52,8 +51,8 @@ AgentOptionsPtr nxagentOptionsPtr = &nxagentOptions; unsigned int nxagentPrintGeometryFlags = 0; /* - * This must be called at startup to initialize - * the options repository to the default values. + * This must be called at startup to initialize the options repository + * to the default values. */ void nxagentInitOptions(void) @@ -176,12 +175,10 @@ void nxagentInitOptions(void) } /* - * This is called at session reconnection - * to reset some options to their default - * values. The reason to avoid calling the - * nxagentInitOptions() is that not all the - * options can change value when reconnec- - * ting. + * This is called at session reconnection to reset some options to + * their default values. The reason to avoid calling the + * nxagentInitOptions() is that not all the options can change value + * when reconnecting. */ void nxagentResetOptions(void) -- cgit v1.2.3 From 6a02a67957bbe600d508b316e6c6115a050b3e90 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:39:36 +0100 Subject: Options.h: reformat --- nx-X11/programs/Xserver/hw/nxagent/Options.h | 194 ++++++++------------------- 1 file changed, 57 insertions(+), 137 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Options.h b/nx-X11/programs/Xserver/hw/nxagent/Options.h index 02e1890b3..d791d2294 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Options.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Options.h @@ -94,346 +94,267 @@ typedef enum _KeycodeConversion typedef struct _AgentOptions { /* - * Link type of the NX connection or none, - * if this is a direct X11 connection. + * Link type of the NX connection or none, if this is a direct X11 + * connection. */ - int LinkType; /* - * Is agent running in desktop mode? This - * is presently the default. + * Is agent running in desktop mode? This is presently the default. */ - int Desktop; /* * True if user activated rootless mode. */ - int Rootless; /* * True for shadow mode. */ - int Shadow; /* * True if user activated persistent mode. */ - int Persistent; /* * True if user activated fullscreen mode. */ - int Fullscreen; /* - * True if the fullscreen NX session will - * extend on all available screens. + * True if the fullscreen NX session will extend on all available + * screens. */ - int AllScreens; /* - * Set to the auto-disconnect timeout, if - * the user activated this feature. + * Set to the auto-disconnect timeout, if the user activated this + * feature. */ - int Timeout; /* * Geometry of the agent's window. */ - - int X; - int Y; - int Width; - int Height; + int X, Y, Width, Height; int BorderWidth; /* - * Geometry of the agent's window in window - * mode. Used to restore window size when - * switching back to window mode from full- - * screen. + * Geometry of the agent's window in window mode. Used to restore + * window size when switching back to window mode from fullscreen. */ - int WMBorderWidth; int WMTitleHeight; - int SavedX; - int SavedY; - int SavedWidth; - int SavedHeight; + int SavedX, SavedY, SavedWidth, SavedHeight; - int SavedRootWidth; - int SavedRootHeight; + int SavedRootWidth, SavedRootHeight; /* - * Set if agent is running nested in another - * agent X server. + * Set if agent is running nested in another agent X server. */ - int Nested; /* * Selected backing-store mode. */ - BackingStoreMode BackingStore; /* * Selected clipboard mode. */ - ClipboardMode Clipboard; /* - * Enable agent to use the MITSHM extension in - * path from remote proxy to the real X server. + * Enable agent to use the MITSHM extension in path from remote + * proxy to the real X server. */ - int SharedMemory; /* * Enable agent to use shared Pixmaps */ - int SharedPixmaps; /* - * Enable agent to propagate keyboard and pointer - * device configuration to the remote X server. + * Enable agent to propagate keyboard and pointer device + * configuration to the remote X server. */ - int DeviceControl; /* * Explicitly asked config propagation. */ - int DeviceControlUserDefined; /* - * Resuming keyboard device corrects keymap if session - * migrates across platforms with different keycode - * layout. + * Resuming keyboard device corrects keymap if session migrates + * across platforms with different keycode layout. */ - int ResetKeyboardAtResume; /* * Reset server when the last client disconnects. */ - int Reset; /* - * Geometry of the agent root window, relative to - * the agent default window. + * Geometry of the agent root window, relative to the agent default + * window. */ - - int RootX; - int RootY; - int RootWidth; - int RootHeight; + int RootX, RootY, RootWidth, RootHeight; /* - * Horizontal and vertical span of the - * agent viewport. + * Horizontal and vertical span of the agent viewport. */ - - int ViewportXSpan; - int ViewportYSpan; + int ViewportXSpan, ViewportYSpan; /* - * True if the user can resize the desktop - * by dragging the window border. + * True if the user can resize the desktop by dragging the window + * border. */ - int DesktopResize; /* * The scaling ratio of the shadow agent. */ + int Ratio, XRatio, YRatio; - int Ratio; - - int XRatio; - - int YRatio; - - float FloatRatio; - - float FloatXRatio; - - float FloatYRatio; + float FloatRatio, FloatXRatio, FloatYRatio; /* * The shadow agent uses the Damage extension. */ - int UseDamage; /* * Was the agent run with the -B option? */ - int Binder; - char *BinderOptions; /* - * Set if the agent has to connect to a - * desktop manager to start the session. + * Set if the agent has to connect to a desktop manager to start the + * session. */ - int Xdmcp; /* - * Size of the Xlib display buffer. The - * default is set according to the link - * type. + * Size of the Xlib display buffer. The default is set according to + * the link type. */ - int DisplayBuffer; /* * Buffer coalescence timeout. */ - int DisplayCoalescence; /* - * Use the composite extension when - * available on the remote display. + * Use the composite extension when available on the remote display. */ - int Composite; /* - * If set, don't skip internal operations - * when the agent window is not fully visible. + * If set, don't skip internal operations when the agent window is + * not fully visible. */ - int IgnoreVisibility; /* - * If set, prevent the shadow session to - * interact with master display. + * If set, prevent the shadow session to interact with master + * display. */ - int ViewOnly; /* - * If true select a lossy or lossless comp- - * ression method based on the characterist- - * ics of the image. + * If true select a lossy or lossless compression method based on + * the characteristics of the image. */ - int Adaptive; /* - * Stream the images and update the display - * when the image has been completely trans- - * ferred. + * Stream the images and update the display when the image has been + * completely transerred. */ - int Streaming; /* - * Use a lazy approach in updating the remote - * display. This means delaying the bandwidth - * consuming graphic operations and synchroniz- - * ing the screen at idle time. + * Use a lazy approach in updating the remote display. This means + * delaying the bandwidth consuming graphic operations and + * synchronizing the screen at idle time. */ - int DeferLevel; /* - * Maximum elapsed time before a new full - * synchronization. + * Maximum elapsed time before a new full synchronization. */ - unsigned long DeferTimeout; /* - * Maximum size of the tile used when sending - * an image to the remote display. + * Maximum size of the tile used when sending an image to the remote + * display. */ - - int TileWidth; - int TileHeight; + int TileWidth, TileHeight; /* * Enabling/disabling the pulldown menu. */ - int Menu; /* * Enabling/disabling the magic pixel. */ - int MagicPixel; /* * Specify the Operative System of the client. */ - int ClientOs; /* * Inhibit some XKEYBOARD requests. */ - int InhibitXkb; /* - * Maximum number of bytes that can be pasted from - * an NX session into an external application. + * Maximum number of bytes that can be pasted from an NX session + * into an external application. */ - int CopyBufferSize; /* * Max image data rate to the encoder input. */ - int ImageRateLimit; /* - * True if agent should not exit if there are no - * clients in rootless mode + * True if agent should not exit if there are no clients in rootless + * mode */ - int NoRootlessExit; /* * Store if the user wants Xinerama. There are variables called * noPanoramiXExtension and noRRXineramaExtensison in os/utils.c but * we cannot rely on them because RandR and PanoramiX change their - * values when trying to initialize. So we use this variable to - * save the user preference provided by the -/+(rr)xinerama parameter(s) + * values when trying to initialize. So we use this variable to save + * the user preference provided by the -/+(rr)xinerama parameter(s) * before initializing those extensions. */ - int Xinerama; /* * Sleep delay in microseconds. */ - unsigned int SleepTime; /* * Tolerance - tightens or loosens reconnect checks. */ - ToleranceChecksMode ReconnectTolerance; /* @@ -473,8 +394,7 @@ extern AgentOptionsPtr nxagentOptionsPtr; extern void nxagentInitOptions(void); /* - * Initialize some options to the default values - * at reconnection. + * Initialize some options to the default values at reconnection. */ extern void nxagentResetOptions(void); @@ -486,8 +406,8 @@ extern void nxagentResetOptions(void); extern void nxagentSaveOptions(void); /* - * Restore the options reset by nxagentResetOptions - * to their backup value. + * Restore the options reset by nxagentResetOptions to their backup + * value. */ extern void nxagentRestoreOptions(void); -- cgit v1.2.3 From fc991b93a9f8c4ea53a8d53ab24f3906f3ca3004 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:48:18 +0100 Subject: Pixels.c: scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Pixels.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c index 93038eab6..5e5573ada 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c @@ -56,8 +56,6 @@ static int nxagentComparePixels(const void *p1, const void *p2) int nxagentUniquePixels(XImage *image) { - int i = 0; - int pixels[PIXEL_ELEMENTS]; int elements = PIXEL_ELEMENTS; @@ -140,7 +138,7 @@ int nxagentUniquePixels(XImage *image) { case 32: { - for (i = 0; i < elements; i++) + for (int i = 0; i < elements; i++) { pixels[i] = Get32(next, image -> byte_order); @@ -156,7 +154,7 @@ int nxagentUniquePixels(XImage *image) } case 24: { - for (i = 0; i < elements; i++) + for (int i = 0; i < elements; i++) { pixels[i] = Get24(next, image -> byte_order); @@ -181,7 +179,7 @@ int nxagentUniquePixels(XImage *image) * the image data. */ - for (i = 0; i < elements; i++) + for (int i = 0; i < elements; i++) { pixels[i] = Get16(next, image -> byte_order); @@ -212,7 +210,7 @@ int nxagentUniquePixels(XImage *image) qsort(pixels, elements, sizeof(int), nxagentComparePixels); - for (i = 0; i < elements; i++) + for (int i = 0; i < elements; i++) { if (last != pixels[i]) { -- cgit v1.2.3 From adca0cc92abed6f7f6184b91d807a4befb80e856 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 31 Oct 2019 01:49:12 +0100 Subject: Pixels.c: reformat comments --- nx-X11/programs/Xserver/hw/nxagent/Pixels.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c index 5e5573ada..8aaa9ecd8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixels.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixels.c @@ -130,8 +130,7 @@ int nxagentUniquePixels(XImage *image) #endif /* - * Take one pixel every n from the image and - * add it to the array. + * Take one pixel every n from the image and add it to the array. */ switch (image -> bits_per_pixel) @@ -172,11 +171,9 @@ int nxagentUniquePixels(XImage *image) case 15: { /* - * Note that the padding bytes at the end - * of the scanline are included in the set. - * This is not a big problem. What we want - * to find out is just how compressible is - * the image data. + * Note that the padding bytes at the end of the scanline are + * included in the set. This is not a big problem. What we want + * to find out is just how compressible is the image data. */ for (int i = 0; i < elements; i++) -- cgit v1.2.3