changeset 39:0f2ba00462dd

Iconify.c: clang-format
author ng0@n0.is
date Fri, 03 May 2019 19:23:21 +0000
parents 603944a9eab1
children 6f3211a1f826
files Iconify.c
diffstat 1 files changed, 207 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/Iconify.c	Fri May 03 19:20:55 2019 +0000
+++ b/Iconify.c	Fri May 03 19:23:21 2019 +0000
@@ -39,7 +39,6 @@
  */
 
 
- 
 /*
  * MODIFICATION HISTORY
  *
@@ -50,186 +49,225 @@
  * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  *  Western Software Lab. Port to X11.
  */
- 
+
 #ifndef lint
 static char *sccsid = "%W%	%G%";
 #endif
- 
+
 #include "uwm.h"
 #include <stdbool.h>
- 
-bool Iconify(window, mask, button, x, y)
-Window window;                          /* Event window. */
-int mask;                               /* Button/key mask. */
-int button;                             /* Button event detail. */
-int x, y;                               /* Event mouse position. */
+
+/*
+ * Window window: Event window.
+ * int mask: Button/key mask.
+ * int button: Button event detail.
+ * int x, y: Event mouse position.
+ */
+bool
+Iconify (Window window, int mask, int button, int x, int y)
 {
-    XWindowAttributes window_info;	/* Event window info. */
-    XWindowAttributes assoc_info;	/* Associated window info. */
-    int mse_x, mse_y;			/* Mouse X and Y coordinates. */
-    int sub_win_x, sub_win_y;		/* relative Mouse coordinates. */
-    int icon_x, icon_y;			/* Icon U. L. X and Y coordinates. */
-    int icon_w, icon_h;			/* Icon width and height. */
-    int icon_bdr;			/* Icon border width. */
-    int num_vectors;			/* Number of vectors in zap buffer. */
-    int mmask;				/* Mouse state */
-    Window root;			/* Mouse root window. */
-    Window assoc;			/* Associated window. */
-    Window sub_win;			/* Mouse position sub-window. */
-    XSegment zap[MAX_ZAP_VECTORS];	/* Zap effect vertex buffer. */
-    bool iconifying;			/* Are we iconifying? */
- 
-    /*
-     * Do not try to iconify the root window.
-     */
-    if (window == RootWindow(dpy, scr))
-        return(FALSE);
- 
-    /*
-     * Clear the vector buffer.
-     */
-    if (Zap) bzero(zap, sizeof(zap));
- 
-    /*
-     * Get the mouse cursor position in case we must put a new
-     * icon there.
-     */
-    XQueryPointer(dpy, RootWindow(dpy, scr), &root, &sub_win, 
-    	&mse_x, &mse_y, &sub_win_x, &sub_win_y, &mmask);
- 
-    /*
-     * Gather info about the window.
-     */
-    status = XGetWindowAttributes(dpy, window, &window_info);
-    if (status == FAILURE) return(FALSE);
- 
-    /*
-     * If the event window is an icon, de-iconify it and return.
-     */
-    if (IsIcon(window, mse_x, mse_y, TRUE, &assoc)) {
- 
- 
+        XWindowAttributes window_info; /* Event window info. */
+        XWindowAttributes assoc_info; /* Associated window info. */
+        int mse_x, mse_y; /* Mouse X and Y coordinates. */
+        int sub_win_x, sub_win_y; /* relative Mouse coordinates. */
+        int icon_x, icon_y; /* Icon U. L. X and Y coordinates. */
+        int icon_w, icon_h; /* Icon width and height. */
+        int icon_bdr; /* Icon border width. */
+        int num_vectors; /* Number of vectors in zap buffer. */
+        int mmask; /* Mouse state */
+        Window root; /* Mouse root window. */
+        Window assoc; /* Associated window. */
+        Window sub_win; /* Mouse position sub-window. */
+        XSegment zap[MAX_ZAP_VECTORS]; /* Zap effect vertex buffer. */
+        bool iconifying; /* Are we iconifying? */
+
+        /*
+         * Do not try to iconify the root window.
+         */
+        if (window == RootWindow (dpy, scr))
+                return (FALSE);
+
+        /*
+         * Clear the vector buffer.
+         */
+        if (Zap)
+                bzero (zap, sizeof (zap));
+
+        /*
+         * Get the mouse cursor position in case we must put a new
+         * icon there.
+         */
+        XQueryPointer (dpy,
+                       RootWindow (dpy, scr),
+                       &root,
+                       &sub_win,
+                       &mse_x,
+                       &mse_y,
+                       &sub_win_x,
+                       &sub_win_y,
+                       &mmask);
+
         /*
-         * Gather info about the assoc window.
+         * Gather info about the window.
          */
-        status = XGetWindowAttributes(dpy, assoc, &assoc_info);
-        if (status == FAILURE) return(FALSE);
- 
+        status = XGetWindowAttributes (dpy, window, &window_info);
+        if (status == FAILURE)
+                return (FALSE);
+
         /*
-         * Store the zap vector buffer.
+         * If the event window is an icon, de-iconify it and return.
          */
-        if (Zap) {
-                num_vectors = StoreZap(
-                    zap,
-                    assoc_info.x - 1,
-                    assoc_info.y - 1,
-                    assoc_info.x + assoc_info.width +
-                        (assoc_info.border_width << 1),
-                    assoc_info.y + assoc_info.height +
-                        (assoc_info.border_width << 1),
-                    window_info.x - 1,
-                    window_info.y - 1,
-                    window_info.x + window_info.width +
-                        (window_info.border_width << 1),
-                    window_info.y + window_info.height +
-                        (window_info.border_width << 1));
-        }
- 
-        /*
-         * Map the window and synchronize.
-         */
-        XMapRaised(dpy, assoc);
-	XRemoveFromSaveSet(dpy, assoc);
- 
-            if (Zap) {
+        if (IsIcon (window, mse_x, mse_y, TRUE, &assoc))
+        {
+
+
+                /*
+                 * Gather info about the assoc window.
+                 */
+                status = XGetWindowAttributes (dpy, assoc, &assoc_info);
+                if (status == FAILURE)
+                        return (FALSE);
+
                 /*
-                 * Draw the zap lines.
+                 * Store the zap vector buffer.
+                 */
+                if (Zap)
+                {
+                        num_vectors =
+                          StoreZap (zap,
+                                    assoc_info.x - 1,
+                                    assoc_info.y - 1,
+                                    assoc_info.x + assoc_info.width +
+                                      (assoc_info.border_width << 1),
+                                    assoc_info.y + assoc_info.height +
+                                      (assoc_info.border_width << 1),
+                                    window_info.x - 1,
+                                    window_info.y - 1,
+                                    window_info.x + window_info.width +
+                                      (window_info.border_width << 1),
+                                    window_info.y + window_info.height +
+                                      (window_info.border_width << 1));
+                }
+
+                /*
+                 * Map the window and synchronize.
                  */
-                DrawZap();
-            }
- 
-        /*
-         * Unmap the icon window.
-         */
-        XUnmapWindow(dpy, window);
- 
-	/*
-	 * Optionally warp the mouse to the upper right corner of the
-         *  window.
-         */
-        if (WarpOnDeIconify) {
-	    status = XGetWindowAttributes (dpy, assoc, &assoc_info);
-            if (status == FAILURE) return(FALSE);
-	    status = XWarpPointer (dpy, None, assoc, 
-	    			 0, 0, 0, 0,
-				 assoc_info.width >= 7 ?
-                                 assoc_info.width - 7 : assoc_info.width / 2,
-                                 assoc_info.height >= 10 ? 10 :
-                                 assoc_info.height / 2);
-            if (status == FAILURE) return(FALSE);
-	}
-    }
-    else {
-        /*
-         * We have an icon window; all we have to do is
-         * map it.
-         */
-        status = XGetWindowAttributes(dpy, assoc, &assoc_info);
-        if (status == FAILURE) return(FALSE);
-        icon_x = assoc_info.x;
-        icon_y = assoc_info.y;
-        icon_w = assoc_info.width;
-        icon_h = assoc_info.height;
-	icon_bdr = assoc_info.border_width;
- 
-        if (Zap) {
-        /*
-         * Store the zap effect vectors.
-         */
-        num_vectors = StoreZap(
-            zap,
-            window_info.x - 1,
-            window_info.y - 1,
-            window_info.x + window_info.width + (window_info.border_width << 1),
-            window_info.y + window_info.height + (window_info.border_width << 1),
-            icon_x - 1,
-            icon_y - 1,
-            icon_x + icon_w + (icon_bdr << 1),
-            icon_y + icon_h + (icon_bdr << 1)
-        );
+                XMapRaised (dpy, assoc);
+                XRemoveFromSaveSet (dpy, assoc);
+
+                if (Zap)
+                {
+                        /*
+                         * Draw the zap lines.
+                         */
+                        DrawZap ();
+                }
+
+                /*
+                 * Unmap the icon window.
+                 */
+                XUnmapWindow (dpy, window);
+
+                /*
+                 * Optionally warp the mouse to the upper right corner of the
+                 *  window.
+                 */
+                if (WarpOnDeIconify)
+                {
+                        status = XGetWindowAttributes (dpy, assoc, &assoc_info);
+                        if (status == FAILURE)
+                                return (FALSE);
+                        status = XWarpPointer (dpy,
+                                               None,
+                                               assoc,
+                                               0,
+                                               0,
+                                               0,
+                                               0,
+                                               assoc_info.width >= 7
+                                                 ? assoc_info.width - 7
+                                                 : assoc_info.width / 2,
+                                               assoc_info.height >= 10
+                                                 ? 10
+                                                 : assoc_info.height / 2);
+                        if (status == FAILURE)
+                                return (FALSE);
+                }
         }
- 
-        /*
-         * Map the icon window.
-         */
-        XMapWindow(dpy, assoc);
- 
-        if (Zap) {
-        /*
-         * Draw zap lines from the window to its icon.
-         */
-            DrawZap();
-            DrawZap();
+        else
+        {
+                /*
+                 * We have an icon window; all we have to do is
+                 * map it.
+                 */
+                status = XGetWindowAttributes (dpy, assoc, &assoc_info);
+                if (status == FAILURE)
+                        return (FALSE);
+                icon_x = assoc_info.x;
+                icon_y = assoc_info.y;
+                icon_w = assoc_info.width;
+                icon_h = assoc_info.height;
+                icon_bdr = assoc_info.border_width;
+
+                if (Zap)
+                {
+                        /*
+                         * Store the zap effect vectors.
+                         */
+                        num_vectors =
+                          StoreZap (zap,
+                                    window_info.x - 1,
+                                    window_info.y - 1,
+                                    window_info.x + window_info.width +
+                                      (window_info.border_width << 1),
+                                    window_info.y + window_info.height +
+                                      (window_info.border_width << 1),
+                                    icon_x - 1,
+                                    icon_y - 1,
+                                    icon_x + icon_w + (icon_bdr << 1),
+                                    icon_y + icon_h + (icon_bdr << 1));
+                }
+
+                /*
+                 * Map the icon window.
+                 */
+                XMapWindow (dpy, assoc);
+
+                if (Zap)
+                {
+                        /*
+                         * Draw zap lines from the window to its icon.
+                         */
+                        DrawZap ();
+                        DrawZap ();
+                }
+
+                /*
+                 * Unmap the event window.
+                 */
+                XAddToSaveSet (dpy, window);
+                XUnmapWindow (dpy, window);
+
+                /*
+                 * Optionally warp the mouse to the icon center.
+                 */
+                if (WarpOnIconify)
+                {
+                        status = XGetWindowAttributes (dpy, assoc, &assoc_info);
+                        if (status == FAILURE)
+                                return (FALSE);
+                        status = XWarpPointer (dpy,
+                                               None,
+                                               assoc,
+                                               0,
+                                               0,
+                                               0,
+                                               0,
+                                               assoc_info.width / 2,
+                                               assoc_info.height / 2);
+                        if (status == FAILURE)
+                                return (FALSE);
+                }
         }
- 
-        /*
-         * Unmap the event window.
-         */
-	XAddToSaveSet(dpy, window);
-        XUnmapWindow(dpy, window);
- 
-	/*
-	 * Optionally warp the mouse to the icon center.
-         */
-        if (WarpOnIconify) {
-            status = XGetWindowAttributes(dpy, assoc, &assoc_info);
-            if (status == FAILURE) return(FALSE);
-	    status = XWarpPointer (dpy, None, assoc, 
-	    			 0, 0, 0, 0,
-				 assoc_info.width / 2, assoc_info.height / 2);
-            if (status == FAILURE) return(FALSE);
-	}
- 
-    }
-    return(TRUE);
+        return (TRUE);
 }