comparison client.c @ 372:a9b4077ec058

applied sanders focus_ patches
author Anselm R. Garbe <arg@10kloc.org>
date Mon, 28 Aug 2006 08:06:50 +0200
parents a1901753deef
children b1159a638d0a
comparison
equal deleted inserted replaced
371:fc9d35252ab4 372:a9b4077ec058
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 10
11 /* static functions */ 11 /* static functions */
12 12
13 static void 13 static void
14 grabbutton(Client *c, unsigned int button, unsigned int modifier) 14 grabbuttons(Client *c, Bool focus)
15 { 15 {
16 XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK, 16 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
17 GrabModeAsync, GrabModeSync, None, None); 17
18 XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK, 18 if(focus) {
19 GrabModeAsync, GrabModeSync, None, None); 19 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
20 XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK, 20 GrabModeAsync, GrabModeSync, None, None);
21 GrabModeAsync, GrabModeSync, None, None); 21 XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
22 XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK, 22 GrabModeAsync, GrabModeSync, None, None);
23 GrabModeAsync, GrabModeSync, None, None); 23 XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
24 GrabModeAsync, GrabModeSync, None, None);
25 XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
26 GrabModeAsync, GrabModeSync, None, None);
27
28 XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
29 GrabModeAsync, GrabModeSync, None, None);
30 XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
31 GrabModeAsync, GrabModeSync, None, None);
32 XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
33 GrabModeAsync, GrabModeSync, None, None);
34 XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
35 GrabModeAsync, GrabModeSync, None, None);
36
37 XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
38 GrabModeAsync, GrabModeSync, None, None);
39 XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
40 GrabModeAsync, GrabModeSync, None, None);
41 XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
42 GrabModeAsync, GrabModeSync, None, None);
43 XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
44 GrabModeAsync, GrabModeSync, None, None);
45 }
46 else
47 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
48 GrabModeAsync, GrabModeSync, None, None);
49
24 } 50 }
25 51
26 static void 52 static void
27 resizetitle(Client *c) 53 resizetitle(Client *c)
28 { 54 {
36 if(isvisible(c)) 62 if(isvisible(c))
37 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th); 63 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
38 else 64 else
39 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th); 65 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
40 66
41 }
42
43 static void
44 ungrabbutton(Client *c, unsigned int button, unsigned int modifier)
45 {
46 XUngrabButton(dpy, button, modifier, c->win);
47 XUngrabButton(dpy, button, modifier | LockMask, c->win);
48 XUngrabButton(dpy, button, modifier | numlockmask, c->win);
49 XUngrabButton(dpy, button, modifier | numlockmask | LockMask, c->win);
50 } 67 }
51 68
52 static int 69 static int
53 xerrordummy(Display *dsply, XErrorEvent *ee) 70 xerrordummy(Display *dsply, XErrorEvent *ee)
54 { 71 {
75 sel = c; 92 sel = c;
76 else if(sel != c) { 93 else if(sel != c) {
77 if(sel->ismax) 94 if(sel->ismax)
78 togglemax(NULL); 95 togglemax(NULL);
79 sel = c; 96 sel = c;
80 grabbutton(old, AnyButton, 0); 97 grabbuttons(old, False);
81 drawtitle(old); 98 drawtitle(old);
82 } 99 }
83 ungrabbutton(c, AnyButton, 0); 100 grabbuttons(c, True);
84 drawtitle(c); 101 drawtitle(c);
85 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 102 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
86 } 103 }
87 104
88 Client * 105 Client *
218 if(clients) 235 if(clients)
219 clients->prev = c; 236 clients->prev = c;
220 c->next = clients; 237 c->next = clients;
221 clients = c; 238 clients = c;
222 239
223 grabbutton(c, Button1, MODKEY); 240 grabbuttons(c, False);
224 grabbutton(c, Button2, MODKEY);
225 grabbutton(c, Button3, MODKEY);
226 241
227 if((tc = getclient(trans))) /* inherit tags */ 242 if((tc = getclient(trans))) /* inherit tags */
228 for(i = 0; i < ntags; i++) 243 for(i = 0; i < ntags; i++)
229 c->tags[i] = tc->tags[i]; 244 c->tags[i] = tc->tags[i];
230 else 245 else
382 } 397 }
383 398
384 void 399 void
385 unmanage(Client *c) 400 unmanage(Client *c)
386 { 401 {
402 Client *tc;
403 Window trans;
387 XGrabServer(dpy); 404 XGrabServer(dpy);
388 XSetErrorHandler(xerrordummy); 405 XSetErrorHandler(xerrordummy);
406
407 XGetTransientForHint(dpy, c->win, &trans);
389 408
390 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 409 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
391 XDestroyWindow(dpy, c->twin); 410 XDestroyWindow(dpy, c->twin);
392 411
393 if(c->prev) 412 if(c->prev)
394 c->prev->next = c->next; 413 c->prev->next = c->next;
395 if(c->next) 414 if(c->next)
396 c->next->prev = c->prev; 415 c->next->prev = c->prev;
397 if(c == clients) 416 if(c == clients)
398 clients = c->next; 417 clients = c->next;
399 if(sel == c) 418 if(sel == c) {
400 sel = getnext(clients); 419 if(trans && (tc = getclient(trans)) && isvisible(tc))
420 sel = tc;
421 else
422 sel = getnext(clients);
423 }
401 free(c->tags); 424 free(c->tags);
402 free(c); 425 free(c);
403 426
404 XSync(dpy, False); 427 XSync(dpy, False);
405 XSetErrorHandler(xerror); 428 XSetErrorHandler(xerror);