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:
t/dwm.h?h=5.7.2&id=bf357945070a9f4722b8dcbf61d61b34d1aae0aa'>bf35794 ^
1076f2b
7b5638f ^

c53980c ^
8b59083 ^
8b59083 ^


bf35794 ^

8b59083 ^

650a1fb ^
8b59083 ^
8b59083 ^

0025572 ^
bf35794 ^


8b59083 ^

1076f2b
da2bbd3 ^
3399650 ^
1173723 ^

a05beb6 ^
2e836ec ^
a05beb6 ^
95e8d12 ^
901b3ed ^
4688ad1 ^
b355755 ^
1076f2b
72707c2 ^
bf35794 ^

1076f2b

b355755 ^
8cc7f3b ^
d7413ff ^
ee31e38 ^
66da153 ^

bf35794 ^
292ccc4 ^
efa7e51 ^
bf35794 ^


bf35794 ^
39677ec ^
439e15d ^
dba2306 ^
3399650 ^
adaa28a ^


dba2306 ^
adaa28a ^
adaa28a ^
adaa28a ^
04eb016 ^
adaa28a ^

4688ad1 ^
adaa28a ^

3399650 ^
d7e1708 ^
dba2306 ^
c0705ee ^
adaa28a ^
c0705ee ^

8cc7f3b ^
d7e1708 ^
dba2306 ^
29355bd ^
b6ad663 ^
b9da4b0 ^
9e8b325 ^
adaa28a ^
c47da14 ^
dba2306 ^
adaa28a ^
9e8b325 ^
dba2306 ^
dba2306 ^

e21d93b ^
d7413ff ^
937cabf ^
72707c2 ^
d4b7a9a ^
adaa28a ^
19da197 ^
4688ad1 ^
19da197 ^
349cada ^
19da197 ^
29355bd ^
8b59083 ^
8b59083 ^
adaa28a ^
d4b7a9a ^
c47da14 ^
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138