Subject: patch for close box
From: "AMidthune"<amidthune@wnjrhs.org>
To: <elliot.hughes@genedata.com>

--simple boundary
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

     Here's a patch that fulfills one of the lines in your TODO file. It 
     fixes the close box so it only works when you click AND release in the 
     box... it's a bit of a kluge but it works with all the tests I've 
     given it.
        I'm sure there's a more elegant way to do it, but I couldn't think 
     of anything else ;-)
        As for the other line in TODO, I'm against it since the frame takes 
     different actions depending on the mouse button you use (except in the 
     box... maybe the pirate bitmap there?)
     
     Cheers,
                Andy
     
     P.S. "mv close_pa.dif lwm/; cd lwm; patch -Np1 < close_pa.dif"



--simple boundary
Content-Type: text/plain; charset=US-ASCII; name="close_pa.dif"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="close_pa.dif"

diff -Naur lwm/CHANGES lwm.new/CHANGES
--- lwm/CHANGES	Mon Jul 19 11:16:09 1999
+++ lwm.new/CHANGES	Thu Jul  8 10:47:22 1999
@@ -1,10 +1,5 @@
 Change Log for "lwm"
 
-1999-07-19	enh	Basel
-
-	Added a handler for circulation events so that other programs
-	can offer "Alt-Tab" functionality.
-
 1999-07-08	enh	Basel
 
 	Fixed the cosmetic problem with titlebars of dialogue boxes. If
diff -Naur lwm/client.c lwm.new/client.c
--- lwm/client.c	Thu Jun 17 07:03:16 1999
+++ lwm.new/client.c	Sun Jul 25 23:05:12 1999
@@ -115,6 +115,7 @@
 	c->wmcmaps = 0;
 	c->accepts_focus = 1;
 	c->next = clients;
+        c->close_pending = False;
 
 	/* Add to head of list of clients. */
 	return (clients = c);
@@ -385,6 +386,13 @@
 	}
 }
 
+void
+Client_Close_Pend(Client *c) {
+        if (c == 0)
+                return;
+        c->close_pending = True;
+}
+       
 void
 Client_SetState(Client *c, int state) {
 	long	data[2];
diff -Naur lwm/disp.c lwm.new/disp.c
--- lwm/disp.c	Mon Jul 19 11:09:12 1999
+++ lwm.new/disp.c	Sun Jul 25 23:14:18 1999
@@ -31,7 +31,6 @@
 static void property(XEvent *);
 static void reparent(XEvent *);
 static void enter(XEvent *);
-static void circulaterequest(XEvent *);
 static void motionnotify(XEvent *);
 
 void reshaping_motionnotify(XEvent *);
@@ -51,7 +50,7 @@
 	{PropertyNotify, property},
 	{ReparentNotify, reparent},
 	{EnterNotify, enter},
-	{CirculateRequest, circulaterequest},
+	{CirculateRequest, 0},
 	{ConfigureNotify, 0},
 	{CreateNotify, 0},
 	{GravityNotify, 0},
@@ -126,7 +125,7 @@
 		/* The ``box''. */
 		quarter = (border + titleHeight()) / 4;
 		if (e->x > (quarter + 2) && e->x < (3 + 3*quarter) && e->y > quarter && e->y <= 3*quarter) {
-			Client_Close(c);
+			Client_Close_Pend(c);
 			return;
 		}
 
@@ -192,24 +191,26 @@
 
 static void
 buttonrelease(XEvent *ev) {
-	if (mode == wm_menu_up)
+        int quarter;
+	XButtonEvent *e = &ev->xbutton;
+	Client * c;
+	
+        c = Client_Get(e->window);
+        
+        if (mode == wm_menu_up)
 		menu_buttonrelease(ev);
 	else if (mode == wm_reshaping)
 		XUnmapWindow(dpy, current_screen->popup);
-	
+        else if ((e->window == c->parent) && c->close_pending) {
+		/* The ``box''. */
+		quarter = (border + titleHeight()) / 4;
+		if (e->x > (quarter + 2) && e->x < (3 + 3*quarter) && e->y > quarter && e->y <= 3*quarter) {
+			Client_Close(c);
+		}
+        }
 	mode = wm_idle;
 }
 
-static void circulaterequest(XEvent *ev) {
-	XCirculateRequestEvent * e = &ev->xcirculaterequest;
-	
-	if (e->place == PlaceOnTop) {
-		XRaiseWindow(e->display, e->window);
-	} else {
-		XLowerWindow(e->display, e->window);
-	}
-}
-
 static void
 maprequest(XEvent *ev) {
 	Client * c;
@@ -448,8 +449,10 @@
 
 	if (c != current && !c->hidden) {
 		/* Take focus away from current holder. */
-		if (current)
+		if (current) {
+                        current->close_pending = False;
 			setactive(current, 0, 0L);
+                }
 
 		/* Give focus to new holder. */
 		current = c;
diff -Naur lwm/lwm.h lwm.new/lwm.h
--- lwm/lwm.h	Tue Jun 22 04:15:08 1999
+++ lwm.new/lwm.h	Sun Jul 25 23:04:08 1999
@@ -88,6 +88,7 @@
 	int state;				/* Window state. See ICCCM and <X11/Xutil.h> */
 
 	Bool hidden;			/* True if this client is hidden. */
+        Bool close_pending;
 	IState internal_state;
 	int proto;
 
@@ -150,6 +151,7 @@
 
 /*	client.c */
 extern Edge interacting_edge;
+extern Bool close_pending;
 extern Client *Client_Get(Window);
 extern Client *Client_Add(Window, Window);
 extern void Client_MakeSane(Client *, Edge, int *, int *, int *, int *);
@@ -162,6 +164,7 @@
 extern void Client_SetState(Client *, int);
 extern void Client_Back(Client *);
 extern void Client_Close(Client *);
+extern void Client_Close_Pend(Client *);
 extern void Client_Remove(Client *);
 extern void Client_FreeAll(void);
 extern void Client_ColourMap(XEvent*);


--simple boundary--
