about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c73
-rw-r--r--event.c2
2 files changed, 49 insertions, 26 deletions
diff --git a/client.c b/client.c
index c18d88b..e8fe150 100644
--- a/client.c
+++ b/client.c
@@ -11,16 +11,42 @@
 /* static functions */
 
 static void
-grabbutton(Client *c, unsigned int button, unsigned int modifier)
+grabbuttons(Client *c, Bool focus)
 {
-	XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK,
-			GrabModeAsync, GrabModeSync, None, None);
-	XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK,
-			GrabModeAsync, GrabModeSync, None, None);
-	XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK,
-			GrabModeAsync, GrabModeSync, None, None);
-	XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK,
-			GrabModeAsync, GrabModeSync, None, None);
+	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+
+	if(focus) {
+		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+
+		XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+
+		XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+		XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+	}
+	else
+		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
+				GrabModeAsync, GrabModeSync, None, None);
+
 }
 
 static void
@@ -40,15 +66,6 @@ resizetitle(Client *c)
 
 }
 
-static void
-ungrabbutton(Client *c, unsigned int button, unsigned int modifier)
-{
-	XUngrabButton(dpy, button, modifier, c->win);
-	XUngrabButton(dpy, button, modifier | LockMask, c->win);
-	XUngrabButton(dpy, button, modifier | numlockmask, c->win);
-	XUngrabButton(dpy, button, modifier | numlockmask | LockMask, c->win);
-}
-
 static int
 xerrordummy(Display *dsply, XErrorEvent *ee)
 {
@@ -77,10 +94,10 @@ focus(Client *c)
 		if(sel->ismax)
 			togglemax(NULL);
 		sel = c;
-		grabbutton(old, AnyButton, 0);
+		grabbuttons(old, False);
 		drawtitle(old);
 	}
-	ungrabbutton(c, AnyButton, 0);
+	grabbuttons(c, True);
 	drawtitle(c);
 	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
 }
@@ -220,9 +237,7 @@ manage(Window w, XWindowAttributes *wa)
 	c->next = clients;
 	clients = c;
 
-	grabbutton(c, Button1, MODKEY);
-	grabbutton(c, Button2, MODKEY);
-	grabbutton(c, Button3, MODKEY);
+	grabbuttons(c, False);
 
 	if((tc = getclient(trans))) /* inherit tags */
 		for(i = 0; i < ntags; i++)
@@ -384,9 +399,13 @@ togglemax(Arg *arg)
 void
 unmanage(Client *c)
 {
+	Client *tc;
+	Window trans;
 	XGrabServer(dpy);
 	XSetErrorHandler(xerrordummy);
 
+	XGetTransientForHint(dpy, c->win, &trans);
+
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 	XDestroyWindow(dpy, c->twin);
 
@@ -396,8 +415,12 @@ unmanage(Client *c)
 		c->next->prev = c->prev;
 	if(c == clients)
 		clients = c->next;
-	if(sel == c)
-		sel = getnext(clients);
+	if(sel == c) {
+		if(trans && (tc = getclient(trans)) && isvisible(tc))
+			sel = tc;
+		else
+			sel = getnext(clients);
+	}
 	free(c->tags);
 	free(c);
 
diff --git a/event.c b/event.c
index 1d2227d..c7a0b15 100644
--- a/event.c
+++ b/event.c
@@ -123,7 +123,7 @@ buttonpress(XEvent *e)
 	}
 	else if((c = getclient(ev->window))) {
 		focus(c);
-		if(CLEANMASK(ev->state) == 0)
+		if(CLEANMASK(ev->state) != MODKEY)
 			return;
 		switch(ev->button) {
 		default:
16 02:03:46 +0100 incremented version number and updated pydoc html files' href='/akspecs/ranger/commit/doc/pydoc/ranger.fsobject.html?h=v1.2.2&id=34a60763e79546e0f84e30fbcc430632f3dbb39e'>34a60763 ^
f07bb12f ^

34a60763 ^
f07bb12f ^

f07bb12f ^

34a60763 ^

f07bb12f ^












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110