From 6b2033bd2c1ae12b91127d26d3f99d8299f6495e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:03:15 +0200 Subject: nxagent: use nxagentWMIsRunning as Bool all over the place has been used as integer sometimes (technically correct, but not nice) Fixes ArcticaProject/nx-libs#698 --- nx-X11/programs/Xserver/hw/nxagent/Atoms.c | 6 +++--- nx-X11/programs/Xserver/hw/nxagent/Events.c | 10 +++++----- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Window.c | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c index 1e9a4bd37..c36c38e2f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c @@ -106,7 +106,7 @@ static void catchAndRedirect(Display* dpy, XErrorEvent* X) X -> request_code == X_ChangeWindowAttributes && X -> resourceid == DefaultRootWindow(dpy)) { - nxagentWMIsRunning = TRUE; + nxagentWMIsRunning = True; } else { @@ -122,7 +122,7 @@ static void startWMDetection(void) * window. */ - nxagentWMIsRunning = FALSE; + nxagentWMIsRunning = False; previousErrorHandler = XSetErrorHandler((XErrorHandler)&catchAndRedirect); @@ -166,7 +166,7 @@ static void finishWMDetection(Bool verbose) void nxagentWMDetect() { Bool verbose = False; - int windowManagerWasRunning = nxagentWMIsRunning; + Bool windowManagerWasRunning = nxagentWMIsRunning; startWMDetection(); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 071e93b32..c0263cc81 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2046,7 +2046,7 @@ FIXME: Don't enqueue the KeyRelease event if the key was * event that would trigger xinerama updates. So we do that once * the nxagent window gets mapped. */ - if (nxagentWMIsRunning == 0 && + if (!nxagentWMIsRunning && X.xmap.window == nxagentDefaultWindows[nxagentScreen(X.xmap.window)->myNum]) { nxagentChangeScreenConfig(nxagentScreen(X.xmap.window)->myNum, nxagentOption(Width), @@ -2767,7 +2767,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) if (X -> xclient.window == (nxagentOption(Fullscreen) ? nxagentIconWindow : nxagentDefaultWindows[0]) || - nxagentWMIsRunning == 0) + !nxagentWMIsRunning) { *result = doCloseSession; } @@ -3353,7 +3353,7 @@ int nxagentHandleConfigureNotify(XEvent* X) * by the window manager are relevant, see ICCCM Chapter 4, * "Configuring the Window" */ - Bool updatePos = (nxagentWMIsRunning == 0 || X -> xconfigure.send_event != 0); + Bool updatePos = (!nxagentWMIsRunning || X -> xconfigure.send_event != 0); int newX = X -> xconfigure.x; int newY = X -> xconfigure.y; @@ -3395,7 +3395,7 @@ int nxagentHandleConfigureNotify(XEvent* X) count++; #endif - if (nxagentWMIsRunning == 0 || X -> xconfigure.send_event) + if (!nxagentWMIsRunning || X -> xconfigure.send_event) { updatePos = True; newX = X -> xconfigure.x; @@ -3626,7 +3626,7 @@ int nxagentHandleReparentNotify(XEvent* X) return 1; } - else if (nxagentWMIsRunning == 1 && nxagentOption(Fullscreen) == 0 && + else if (nxagentWMIsRunning && nxagentOption(Fullscreen) == 0 && nxagentOption(WMBorderWidth) == -1) { XlibWindow w; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 9a6cbf28b..6d15f2021 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -402,7 +402,7 @@ void nxagentDisconnectSession(void) nxagentDisconnectAllGCs(); nxagentDisconnectDisplay(); - nxagentWMIsRunning = 0; + nxagentWMIsRunning = False; #ifdef TEST fprintf(stderr, "nxagentDisconnectSession: Disconnection completed. SigHup is [%d]. IoError is [%d].\n", diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index b5aabf8bd..8df5ec546 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -977,7 +977,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * fullscreen mode. */ - if (nxagentOption(Rootless) == False && nxagentWMIsRunning == False) + if (nxagentOption(Rootless) == False && !nxagentWMIsRunning) { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Forcing fullscreen mode with no window manager running.\n"); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 5373d4889..bde1c7d8a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -762,7 +762,7 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) isItTimeToYield = 1; - if (nxagentWMIsRunning == 0) + if (!nxagentWMIsRunning) { #ifdef WARNING fprintf(stderr, "Warning: Can't switch to window mode, no window manager " @@ -2552,7 +2552,7 @@ void nxagentMapDefaultWindows(void) * Windows client. */ - if (nxagentOption(Shadow) == 0 || nxagentWMIsRunning == 0) + if (nxagentOption(Shadow) == 0 || !nxagentWMIsRunning) { #ifdef TEST fprintf(stderr, "nxagentMapDefaultWindows: Mapping default window id [%ld].\n", @@ -2561,7 +2561,7 @@ void nxagentMapDefaultWindows(void) XMapWindow(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum]); - if (nxagentOption(Fullscreen) == 1 && nxagentWMIsRunning == 1) + if (nxagentOption(Fullscreen) == 1 && nxagentWMIsRunning) { nxagentMaximizeToFullScreen(pScreen); } -- cgit v1.2.3 From 1a8c4532e6640e20eba772c0e4f8f36b933c66ae Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:08:18 +0200 Subject: nxagent: use nxagentWMPassed as Bool all over the place has been used as integer sometimes (technically correct, but not nice) --- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 2 +- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 5cfa92769..22d5f191e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -142,7 +142,7 @@ void nxagentWaitDisplay(void); void nxagentListRemoteFonts(const char *, int); unsigned int nxagentWMtimeout = 0; -Bool nxagentWMPassed = 0; +Bool nxagentWMPassed = False; /* * Timeouts based on screen saver time. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 8df5ec546..d8cf695a0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3057,7 +3057,7 @@ int nxagentShadowPoll(PixmapPtr nxagentShadowPixmapPtr, GCPtr nxagentShadowGCPtr if (result == 1) { - if (nxagentWMPassed == 0) + if (!nxagentWMPassed) { nxagentRemoveSplashWindow(NULL); } -- cgit v1.2.3 From f91f02d9d0cff938e9d50770de2071d366d7095f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:19:08 +0200 Subject: Pixmap.c: use some Bools as Bools not integers --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 421e023c1..be154f9c2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -860,10 +860,10 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) Bool *pBool = (Bool*) p2; nxagentPrivPixmapPtr pPixmapPriv; - if (*pBool == 0 || pPixmap == NULL || + if (!*pBool || pPixmap == NULL || NXDisplayError(nxagentDisplay) == 1) { - *pBool = 0; + *pBool = False; #ifdef TEST fprintf(stderr, "nxagentReconnectPixmap: Ignoring pixmap at [%p] while " @@ -929,7 +929,7 @@ void nxagentReconnectPixmap(void *p0, XID x1, void *p2) nxagentSplitTrap = 0; - if (*pBool == 0) + if (!*pBool) { #ifdef PANIC fprintf(stderr, "nxagentReconnectPixmap: PANIC! Failed to synchronize the pixmap.\n"); @@ -1035,7 +1035,7 @@ static void nxagentCheckOnePixmapIntegrity(void *p0, XID x1, void *p2) PixmapPtr pPixmap = (PixmapPtr) p0; Bool *pBool = (Bool*) p2; - if (*pBool == False) + if (!*pBool) { return; } @@ -1065,7 +1065,7 @@ static void nxagentCheckOnePixmapIntegrity(void *p0, XID x1, void *p2) Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) { - Bool integrity = 1; + Bool integrity = True; XImage *image; char *data; int format; @@ -1121,11 +1121,11 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) if (image != NULL && memcmp(image -> data, data, length) != 0) { - integrity = 0; + integrity = False; } else { - integrity = 1; + integrity = True; #ifdef TEST fprintf(stderr, "nxagentCheckPixmapIntegrity: Pixmap at [%p] has been realized. " @@ -1135,7 +1135,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) #ifdef WARNING - if (integrity == 0) + if (!integrity) { int i; -- cgit v1.2.3 From 67432ac25901bd56a13a3c8885be796f39918880 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:24:49 +0200 Subject: Render.c: improve Bool usage --- nx-X11/programs/Xserver/hw/nxagent/Render.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index b58a16f3d..9d91b1ff1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -2784,7 +2784,7 @@ void nxagentReconnectGlyphSet(void* p0, XID x1, void *p2) Bool nxagentReconnectAllGlyphSet(void *p) { - Bool success = TRUE; + Bool success = True; int i; nxagentQueryFormats(); @@ -2826,7 +2826,7 @@ void nxagentReconnectPicture(void * p0, XID x1, void *p2) * and that the involved objects are valid. */ - if (*pBool == 0 || pPicture == NULL || + if (!*pBool || pPicture == NULL || nxagentPicture(pPicture) != 0) { return; @@ -2959,7 +2959,7 @@ Bool nxagentReconnectAllPicture(void *p) fprintf(stderr, "nxagentReconnectAllPicture: Going to recreate all pictures.\n"); #endif - for (i = 0, r = 1; i < MAXCLIENTS; i++) + for (i = 0, r = True; i < MAXCLIENTS; i++) { if (clients[i]) { @@ -2967,7 +2967,7 @@ Bool nxagentReconnectAllPicture(void *p) #ifdef WARNING - if (r == False) + if (!r) { fprintf(stderr, "nxagentReconnectAllPicture: WARNING! Failed to recreate " "picture for client [%d].\n", i); @@ -3015,7 +3015,7 @@ Bool nxagentDisconnectAllPicture(void) fprintf(stderr, "nxagentDisconnectAllPicture.\n"); #endif - for (i = 0, r = 1; i < MAXCLIENTS; i++) + for (i = 0, r = True; i < MAXCLIENTS; i++) { if (clients[i]) { @@ -3023,7 +3023,7 @@ Bool nxagentDisconnectAllPicture(void) #ifdef WARNING - if (r == False) + if (!r) { fprintf(stderr, "nxagentDisconnectAllPicture: WARNING! Failed to disconnect " "picture for client [%d].\n", i); -- cgit v1.2.3 From 7b8aef83ab2ac6c0b059064951e03f0bb18b5e77 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:36:50 +0200 Subject: nxagentInitAndCheckVisuals: adapt bool usage to match the previous function One question remains: why are we using "bool" instead of "Bool" here? --- nx-X11/programs/Xserver/hw/nxagent/Display.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 3ca3db2a3..448969d44 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -2492,12 +2492,10 @@ static int nxagentInitAndCheckVisuals(int flexibility) long viMask; int i, n; - int matched; - int compatible; + bool matched; + bool compatible = true; int viNumList; - compatible = 1; - viMask = VisualScreenMask; viTemplate.screen = DefaultScreen(nxagentDisplay); viTemplate.depth = DefaultDepth(nxagentDisplay, DefaultScreen(nxagentDisplay)); @@ -2507,7 +2505,7 @@ static int nxagentInitAndCheckVisuals(int flexibility) for (i = 0; i < nxagentNumVisuals; i++) { - matched = 0; + matched = false; for (n = 0; n < viNumList; n++) { @@ -2528,7 +2526,7 @@ FIXME: Should the visual be ignored in this case? #endif } - matched = 1; + matched = true; nxagentVisualHasBeenIgnored[i] = FALSE; @@ -2538,7 +2536,7 @@ FIXME: Should the visual be ignored in this case? } } - if (matched == 0) + if (!matched) { if (nxagentVisuals[i].class == DirectColor) { @@ -2564,7 +2562,7 @@ FIXME: Should the visual be ignored in this case? fprintf(stderr, "\tbits_per_rgb = %d\n", nxagentVisuals[i].bits_per_rgb); #endif - compatible = 0; + compatible = false; break; } @@ -2573,7 +2571,7 @@ FIXME: Should the visual be ignored in this case? XFree(viList); - if (compatible == 1) + if (compatible) { #ifdef TEST fprintf(stderr, "nxagentInitAndCheckVisuals: New visuals match with old visuals.\n"); -- cgit v1.2.3 From 1584395554707c75599f58c2bf8dfd3434053e13 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:47:28 +0200 Subject: Window.c: improve Bool usage --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index bde1c7d8a..55eeaa0d0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -310,7 +310,7 @@ Bool nxagentCreateWindow(pWin) /* FIXME: We need to set save under on the real display? */ - if (nxagentSaveUnder == True) + if (nxagentSaveUnder) { mask |= CWSaveUnder; attributes.save_under = False; @@ -749,7 +749,7 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) return; } - if (switchOn == 0) + if (!switchOn) { nxagentWMDetect(); @@ -793,7 +793,7 @@ void nxagentSwitchFullscreen(ScreenPtr pScreen, Bool switchOn) XSendEvent(nxagentDisplay, DefaultRootWindow(nxagentDisplay), False, SubstructureRedirectMask, &e); - if (switchOn == 1) + if (switchOn) { nxagentFullscreenWindow = nxagentDefaultWindows[pScreen -> myNum]; @@ -2683,7 +2683,7 @@ void nxagentDisconnectWindow(void * p0, XID x1, void * p2) nxagentDisconnectCursor(pCursor, (XID)0, pBool); - if (*pBool == False) + if (!*pBool) { #ifdef WARNING fprintf(stderr, "nxagentDisconnectWindow: WARNING failed disconnection of cursor at [%p]" @@ -2937,7 +2937,7 @@ static void nxagentReconnectWindow(void * param0, XID param1, void * data_buffer /* FIXME: Do we need to set save unders attribute here? */ - if (nxagentSaveUnder == True) + if (nxagentSaveUnder) { mask |= CWSaveUnder; attributes.save_under = pWin->saveUnder; -- cgit v1.2.3 From 7f7895ee5674bf2bd507632408432cd5bd7090e3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:47:45 +0200 Subject: Window.c: remove useless code --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 55eeaa0d0..d25424d7c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -2725,8 +2725,6 @@ Bool nxagentReconnectAllWindows(void *p0) { int flexibility = *(int *) p0; - flexibility = flexibility; - #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_WINDOW_DEBUG) fprintf(stderr, "nxagentReconnectAllWindows\n"); #endif @@ -2845,8 +2843,6 @@ Bool nxagentSetWindowCursors(void *p0) { int flexibility = *(int *) p0; - flexibility = flexibility; - #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_WINDOW_DEBUG) fprintf(stderr, "nxagentSetWindowCursors: Going to loop over the windows.\n"); #endif -- cgit v1.2.3 From 450760bcafc8d2a708b9f6087f3c0c2cdab046a8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 24 Sep 2018 21:49:23 +0200 Subject: Events.c: improve Bool usage --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index c0263cc81..94480c45c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -373,7 +373,7 @@ void nxagentRemoteWindowID(Window window, Bool newline) } } - if (newline == TRUE) + if (newline) { fprintf(stderr, "\n"); } @@ -411,7 +411,7 @@ void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine) (attributes.override_redirect == 0) ? "No" : "Yes" ); - if (newLine == TRUE) + if (newLine) { fprintf(stderr, "\n"); } @@ -537,7 +537,7 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) (pWin -> overrideRedirect == 0) ? "No" : "Yes"); - if (newLine == TRUE) + if (newLine) { fprintf(stderr, "\n"); } @@ -4061,8 +4061,7 @@ void nxagentHandleCollectPropertyEvent(XEvent *X) nxagentImportProperty(window, property, atomReturnType, resultFormat, ulReturnItems, ulReturnBytesLeft, pszReturnData); } - - if (result == 0) + else { #ifdef DEBUG fprintf (stderr, "nxagentHandleCollectPropertyEvent: Failed to get reply data for client [%d].\n", -- cgit v1.2.3