changeset 45:19920299b91b

MoveOpaque.c: clang-format, c style
author ng0@n0.is
date Fri, 03 May 2019 19:49:00 +0000
parents 30c664d5bd22
children 48b8cc8508b9
files MoveOpaque.c
diffstat 1 files changed, 107 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/MoveOpaque.c	Fri May 03 19:46:43 2019 +0000
+++ b/MoveOpaque.c	Fri May 03 19:49:00 2019 +0000
@@ -1,6 +1,7 @@
 #ifndef lint
-static char *rcsid_MoveOpaque_c = "$XConsortium: MoveOpaque.c,v 1.12 88/10/22 15:20:54 jim Exp $";
-#endif	/* lint */
+static char *rcsid_MoveOpaque_c =
+  "$XConsortium: MoveOpaque.c,v 1.12 88/10/22 15:20:54 jim Exp $";
+#endif /* lint */
 
 /*
  * Copyright 1985, 1986, 1987, 1988, 1989 by the
@@ -42,7 +43,6 @@
  */
 
 
-
 /*
  * MODIFICATION HISTORY
  *
@@ -59,95 +59,116 @@
 #include <X11/Xatom.h>
 #include <stdbool.h>
 
-bool MoveOpaque(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
+MoveOpaque (Window window, int mask, int button, int x, int y)
 {
-    int prev_x, prev_y;			/* Previous mouse location. */
-    int cur_x, cur_y;			/* Current mouse location. */
-    int win_x, win_y;			/* Current window location. */
-    int root_x;				/* Root window X location. */
-    int root_y;				/* Root window Y location. */
-    int ptrmask;			/* state of ptr when queried */
-    XWindowAttributes window_info;	/* Event window information. */
-    Window sub_window;			/* Query mouse event sub-window. */
-    Window root;			/* Query mouse event root. */
-    XEvent button_event;		/* Button event packet. */
+        int prev_x, prev_y; /* Previous mouse location. */
+        int cur_x, cur_y; /* Current mouse location. */
+        int win_x, win_y; /* Current window location. */
+        int root_x; /* Root window X location. */
+        int root_y; /* Root window Y location. */
+        int ptrmask; /* state of ptr when queried */
+        XWindowAttributes window_info; /* Event window information. */
+        Window sub_window; /* Query mouse event sub-window. */
+        Window root; /* Query mouse event root. */
+        XEvent button_event; /* Button event packet. */
+
+        /*
+         * Do not try to move the root window.
+         */
+        if (window == RootWindow (dpy, scr))
+                return (FALSE);
 
-    /*
-     * Do not try to move the root window.
-     */
-    if (window == RootWindow(dpy, scr))
-        return(FALSE);
-
-    /*
-     * Change the cursor.
-     */
-    XChangeActivePointerGrab(dpy, EVENTMASK, ArrowCrossCursor, CurrentTime);
+        /*
+         * Change the cursor.
+         */
+        XChangeActivePointerGrab (dpy,
+                                  EVENTMASK,
+                                  ArrowCrossCursor,
+                                  CurrentTime);
 
-    /*
-     * Gather info on the event window.
-     */
-    status = XGetWindowAttributes(dpy, window, &window_info);
-    if (status == FAILURE) return(FALSE);
+        /*
+         * Gather info on the event window.
+         */
+        status = XGetWindowAttributes (dpy, window, &window_info);
+        if (status == FAILURE)
+                return (FALSE);
 
-    /*
-     * Initialize movement variables.
-     */
-    prev_x = cur_x = x;
-    prev_y = cur_y = y;
-    win_x = window_info.x;
-    win_y = window_info.y;
+        /*
+         * Initialize movement variables.
+         */
+        prev_x = cur_x = x;
+        prev_y = cur_y = y;
+        win_x = window_info.x;
+        win_y = window_info.y;
+
+        /*
+         * Main loop.
+         */
+        while (TRUE)
+        {
 
-    /*
-     * Main loop.
-     */
-    while (TRUE) {
-
-        XQueryPointer(dpy, RootWindow(dpy, scr), 
-		&root, &sub_window, &root_x, &root_y, &cur_x, &cur_y, 
-		&ptrmask);
+                XQueryPointer (dpy,
+                               RootWindow (dpy, scr),
+                               &root,
+                               &sub_window,
+                               &root_x,
+                               &root_y,
+                               &cur_x,
+                               &cur_y,
+                               &ptrmask);
 
-    	/*
-	 * Check to see if we have a change in mouse button status.
-	 * This is how we get out of this "while" loop.
-	 */
-	if (XCheckMaskEvent(dpy,
-			    ButtonPressMask|ButtonReleaseMask,
-			    &button_event)) {
-	    XButtonEvent *be = (XButtonEvent *) &button_event;
+                /*
+                 * Check to see if we have a change in mouse button status.
+                 * This is how we get out of this "while" loop.
+                 */
+                if (XCheckMaskEvent (dpy,
+                                     ButtonPressMask | ButtonReleaseMask,
+                                     &button_event))
+                {
+                        XButtonEvent *be = (XButtonEvent *) &button_event;
 
-	    /*
-	     * If the button event was something other than the
-             * release of the original button pressed, then move the
-             * window back to where it was originally.
-	     */
-            if ((button_event.type != ButtonRelease) || 
-	        (be->button != button)) {
-                ResetCursor(button);
-		XMoveWindow(dpy, window, window_info.x, window_info.y);
-	    } else {
-		win_x += (be->x_root - prev_x);
-		win_y += (be->y_root - prev_y);
-		XMoveWindow (dpy, window, win_x, win_y);
-	    }
+                        /*
+                         * If the button event was something other than the
+                         * release of the original button pressed, then move the
+                         * window back to where it was originally.
+                         */
+                        if ((button_event.type != ButtonRelease) ||
+                            (be->button != button))
+                        {
+                                ResetCursor (button);
+                                XMoveWindow (dpy,
+                                             window,
+                                             window_info.x,
+                                             window_info.y);
+                        }
+                        else
+                        {
+                                win_x += (be->x_root - prev_x);
+                                win_y += (be->y_root - prev_y);
+                                XMoveWindow (dpy, window, win_x, win_y);
+                        }
 
-            return(TRUE);
-	}
-	
-        /*
-         * Take care of all the little things that have changed; 
-         * i.e., move the window, if necessary.
-         */
-        if ((cur_x != prev_x) || (cur_y != prev_y)) {
-            win_x += (cur_x - prev_x);
-            win_y += (cur_y - prev_y);
-            XMoveWindow(dpy, window, win_x, win_y);
-    	    prev_x = cur_x;
-    	    prev_y = cur_y;
-    	}
-    }
+                        return (TRUE);
+                }
+
+                /*
+                 * Take care of all the little things that have changed;
+                 * i.e., move the window, if necessary.
+                 */
+                if ((cur_x != prev_x) || (cur_y != prev_y))
+                {
+                        win_x += (cur_x - prev_x);
+                        win_y += (cur_y - prev_y);
+                        XMoveWindow (dpy, window, win_x, win_y);
+                        prev_x = cur_x;
+                        prev_y = cur_y;
+                }
+        }
 }
-