equal
deleted
inserted
replaced
8 #include <X11/Xutil.h> |
8 #include <X11/Xutil.h> |
9 |
9 |
10 /* static */ |
10 /* static */ |
11 |
11 |
12 static void |
12 static void |
|
13 attachstack(Client *c) { |
|
14 c->snext = stack; |
|
15 stack = c; |
|
16 } |
|
17 |
|
18 static void |
|
19 detachstack(Client *c) { |
|
20 Client **tc; |
|
21 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
|
22 *tc = c->snext; |
|
23 } |
|
24 |
|
25 static void |
13 grabbuttons(Client *c, Bool focused) { |
26 grabbuttons(Client *c, Bool focused) { |
14 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
27 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
15 |
28 |
16 if(focused) { |
29 if(focused) { |
17 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, |
30 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, |
66 long data[] = {state, None}; |
79 long data[] = {state, None}; |
67 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
80 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
68 PropModeReplace, (unsigned char *)data, 2); |
81 PropModeReplace, (unsigned char *)data, 2); |
69 } |
82 } |
70 |
83 |
|
84 static void |
|
85 togglemax(Client *c) { |
|
86 XEvent ev; |
|
87 |
|
88 if(c->isfixed) |
|
89 return; |
|
90 if((c->ismax = !c->ismax)) { |
|
91 c->rx = c->x; |
|
92 c->ry = c->y; |
|
93 c->rw = c->w; |
|
94 c->rh = c->h; |
|
95 resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); |
|
96 } |
|
97 else |
|
98 resize(c, c->rx, c->ry, c->rw, c->rh, True); |
|
99 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
100 } |
|
101 |
71 static int |
102 static int |
72 xerrordummy(Display *dsply, XErrorEvent *ee) { |
103 xerrordummy(Display *dsply, XErrorEvent *ee) { |
73 return 0; |
104 return 0; |
74 } |
105 } |
75 |
106 |
79 attach(Client *c) { |
110 attach(Client *c) { |
80 if(clients) |
111 if(clients) |
81 clients->prev = c; |
112 clients->prev = c; |
82 c->next = clients; |
113 c->next = clients; |
83 clients = c; |
114 clients = c; |
84 } |
|
85 |
|
86 void |
|
87 attachstack(Client *c) { |
|
88 c->snext = stack; |
|
89 stack = c; |
|
90 } |
115 } |
91 |
116 |
92 void |
117 void |
93 configure(Client *c) { |
118 configure(Client *c) { |
94 XConfigureEvent ce; |
119 XConfigureEvent ce; |
114 if(c->next) |
139 if(c->next) |
115 c->next->prev = c->prev; |
140 c->next->prev = c->prev; |
116 if(c == clients) |
141 if(c == clients) |
117 clients = c->next; |
142 clients = c->next; |
118 c->next = c->prev = NULL; |
143 c->next = c->prev = NULL; |
119 } |
|
120 |
|
121 void |
|
122 detachstack(Client *c) { |
|
123 Client **tc; |
|
124 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
|
125 *tc = c->snext; |
|
126 } |
144 } |
127 |
145 |
128 void |
146 void |
129 focus(Client *c) { |
147 focus(Client *c) { |
130 if(c && !isvisible(c)) |
148 if(c && !isvisible(c)) |
252 XMapWindow(dpy, c->win); |
270 XMapWindow(dpy, c->win); |
253 setclientstate(c, NormalState); |
271 setclientstate(c, NormalState); |
254 if(isvisible(c)) |
272 if(isvisible(c)) |
255 focus(c); |
273 focus(c); |
256 arrange(); |
274 arrange(); |
|
275 } |
|
276 |
|
277 Client * |
|
278 nexttiled(Client *c) { |
|
279 for(; c && (c->isfloat || !isvisible(c)); c = c->next); |
|
280 return c; |
257 } |
281 } |
258 |
282 |
259 void |
283 void |
260 resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
284 resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
261 float actual, dx, dy, max, min; |
285 float actual, dx, dy, max, min; |
414 XSync(dpy, False); |
438 XSync(dpy, False); |
415 XSetErrorHandler(xerror); |
439 XSetErrorHandler(xerror); |
416 XUngrabServer(dpy); |
440 XUngrabServer(dpy); |
417 arrange(); |
441 arrange(); |
418 } |
442 } |
|
443 |
|
444 void |
|
445 zoom(Arg *arg) { |
|
446 unsigned int n; |
|
447 Client *c; |
|
448 |
|
449 if(!sel) |
|
450 return; |
|
451 if(sel->isfloat || (arrange == dofloat)) { |
|
452 togglemax(sel); |
|
453 return; |
|
454 } |
|
455 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
456 n++; |
|
457 |
|
458 if((c = sel) == nexttiled(clients)) |
|
459 if(!(c = nexttiled(c->next))) |
|
460 return; |
|
461 detach(c); |
|
462 attach(c); |
|
463 focus(c); |
|
464 arrange(); |
|
465 } |