rev |
line source |
garbeam@5
|
1 /*
|
garbeam@5
|
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
garbeam@5
|
3 * See LICENSE file for license details.
|
garbeam@5
|
4 */
|
garbeam@76
|
5 #include "dwm.h"
|
garbeam@10
|
6 #include <stdlib.h>
|
garbeam@5
|
7 #include <string.h>
|
garbeam@5
|
8 #include <X11/Xatom.h>
|
garbeam@32
|
9 #include <X11/Xutil.h>
|
garbeam@5
|
10
|
garbeam@76
|
11 /* static functions */
|
garbeam@50
|
12
|
garbeam@26
|
13 static void
|
garbeam@75
|
14 resizetitle(Client *c)
|
garbeam@26
|
15 {
|
garbeam@31
|
16 int i;
|
garbeam@31
|
17
|
arg@115
|
18 c->tw = 0;
|
arg@178
|
19 for(i = 0; i < ntags; i++)
|
garbeam@31
|
20 if(c->tags[i])
|
arg@173
|
21 c->tw += textw(tags[i]);
|
arg@115
|
22 c->tw += textw(c->name);
|
arg@115
|
23 if(c->tw > c->w)
|
arg@115
|
24 c->tw = c->w + 2;
|
arg@115
|
25 c->tx = c->x + c->w - c->tw + 2;
|
arg@115
|
26 c->ty = c->y;
|
arg@106
|
27 if(c->tags[tsel])
|
arg@115
|
28 XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
|
arg@106
|
29 else
|
arg@115
|
30 XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
arg@106
|
31
|
garbeam@26
|
32 }
|
garbeam@18
|
33
|
garbeam@76
|
34 static int
|
garbeam@76
|
35 xerrordummy(Display *dsply, XErrorEvent *ee)
|
garbeam@5
|
36 {
|
garbeam@76
|
37 return 0;
|
garbeam@5
|
38 }
|
garbeam@5
|
39
|
garbeam@76
|
40 /* extern functions */
|
garbeam@20
|
41
|
garbeam@20
|
42 void
|
garbeam@76
|
43 ban(Client *c)
|
garbeam@26
|
44 {
|
arg@115
|
45 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
arg@115
|
46 XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
garbeam@26
|
47 }
|
garbeam@26
|
48
|
garbeam@26
|
49 void
|
garbeam@13
|
50 focus(Client *c)
|
garbeam@13
|
51 {
|
garbeam@52
|
52 Client *old = sel;
|
garbeam@63
|
53 XEvent ev;
|
garbeam@52
|
54
|
garbeam@50
|
55 sel = c;
|
garbeam@52
|
56 if(old && old != c)
|
garbeam@74
|
57 drawtitle(old);
|
garbeam@74
|
58 drawtitle(c);
|
garbeam@26
|
59 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
garbeam@79
|
60 XSync(dpy, False);
|
arg@229
|
61 XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
arg@229
|
62 PropModeReplace, (unsigned char *)&c->win, 1);
|
garbeam@63
|
63 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
garbeam@13
|
64 }
|
garbeam@13
|
65
|
garbeam@13
|
66 void
|
garbeam@76
|
67 focusnext(Arg *arg)
|
garbeam@76
|
68 {
|
garbeam@76
|
69 Client *c;
|
garbeam@76
|
70
|
garbeam@76
|
71 if(!sel)
|
garbeam@76
|
72 return;
|
garbeam@76
|
73
|
arg@124
|
74 if(sel->ismax)
|
arg@124
|
75 togglemax(NULL);
|
arg@124
|
76
|
arg@142
|
77 if(!(c = getnext(sel->next)))
|
arg@142
|
78 c = getnext(clients);
|
garbeam@76
|
79 if(c) {
|
garbeam@76
|
80 higher(c);
|
garbeam@76
|
81 focus(c);
|
garbeam@76
|
82 }
|
garbeam@76
|
83 }
|
garbeam@76
|
84
|
garbeam@76
|
85 void
|
garbeam@76
|
86 focusprev(Arg *arg)
|
garbeam@76
|
87 {
|
garbeam@76
|
88 Client *c;
|
garbeam@76
|
89
|
garbeam@76
|
90 if(!sel)
|
garbeam@76
|
91 return;
|
garbeam@76
|
92
|
arg@124
|
93 if(sel->ismax)
|
arg@124
|
94 togglemax(NULL);
|
arg@124
|
95
|
arg@127
|
96 if(!(c = getprev(sel->prev))) {
|
arg@127
|
97 for(c = clients; c && c->next; c = c->next);
|
arg@127
|
98 c = getprev(c);
|
arg@127
|
99 }
|
arg@127
|
100 if(c) {
|
garbeam@76
|
101 higher(c);
|
garbeam@76
|
102 focus(c);
|
garbeam@76
|
103 }
|
garbeam@76
|
104 }
|
garbeam@76
|
105
|
garbeam@76
|
106 Client *
|
garbeam@76
|
107 getclient(Window w)
|
garbeam@76
|
108 {
|
garbeam@76
|
109 Client *c;
|
arg@123
|
110
|
garbeam@76
|
111 for(c = clients; c; c = c->next)
|
garbeam@76
|
112 if(c->win == w)
|
garbeam@76
|
113 return c;
|
garbeam@76
|
114 return NULL;
|
garbeam@76
|
115 }
|
garbeam@76
|
116
|
garbeam@76
|
117 Client *
|
garbeam@76
|
118 getctitle(Window w)
|
garbeam@76
|
119 {
|
garbeam@76
|
120 Client *c;
|
arg@123
|
121
|
garbeam@76
|
122 for(c = clients; c; c = c->next)
|
garbeam@76
|
123 if(c->title == w)
|
garbeam@76
|
124 return c;
|
garbeam@76
|
125 return NULL;
|
garbeam@76
|
126 }
|
garbeam@76
|
127
|
garbeam@76
|
128 void
|
garbeam@76
|
129 gravitate(Client *c, Bool invert)
|
garbeam@76
|
130 {
|
garbeam@76
|
131 int dx = 0, dy = 0;
|
garbeam@76
|
132
|
garbeam@76
|
133 switch(c->grav) {
|
arg@127
|
134 default:
|
arg@127
|
135 break;
|
garbeam@76
|
136 case StaticGravity:
|
garbeam@76
|
137 case NorthWestGravity:
|
garbeam@76
|
138 case NorthGravity:
|
garbeam@76
|
139 case NorthEastGravity:
|
garbeam@76
|
140 dy = c->border;
|
garbeam@76
|
141 break;
|
garbeam@76
|
142 case EastGravity:
|
garbeam@76
|
143 case CenterGravity:
|
garbeam@76
|
144 case WestGravity:
|
arg@115
|
145 dy = -(c->h / 2) + c->border;
|
garbeam@76
|
146 break;
|
garbeam@76
|
147 case SouthEastGravity:
|
garbeam@76
|
148 case SouthGravity:
|
garbeam@76
|
149 case SouthWestGravity:
|
arg@115
|
150 dy = -(c->h);
|
garbeam@76
|
151 break;
|
garbeam@76
|
152 }
|
garbeam@76
|
153
|
garbeam@76
|
154 switch (c->grav) {
|
arg@127
|
155 default:
|
arg@127
|
156 break;
|
garbeam@76
|
157 case StaticGravity:
|
garbeam@76
|
158 case NorthWestGravity:
|
garbeam@76
|
159 case WestGravity:
|
garbeam@76
|
160 case SouthWestGravity:
|
garbeam@76
|
161 dx = c->border;
|
garbeam@76
|
162 break;
|
garbeam@76
|
163 case NorthGravity:
|
garbeam@76
|
164 case CenterGravity:
|
garbeam@76
|
165 case SouthGravity:
|
arg@115
|
166 dx = -(c->w / 2) + c->border;
|
garbeam@76
|
167 break;
|
garbeam@76
|
168 case NorthEastGravity:
|
garbeam@76
|
169 case EastGravity:
|
garbeam@76
|
170 case SouthEastGravity:
|
arg@115
|
171 dx = -(c->w + c->border);
|
garbeam@76
|
172 break;
|
garbeam@76
|
173 }
|
garbeam@76
|
174
|
garbeam@76
|
175 if(invert) {
|
garbeam@76
|
176 dx = -dx;
|
garbeam@76
|
177 dy = -dy;
|
garbeam@76
|
178 }
|
arg@115
|
179 c->x += dx;
|
arg@115
|
180 c->y += dy;
|
garbeam@76
|
181 }
|
garbeam@76
|
182
|
garbeam@76
|
183 void
|
garbeam@76
|
184 higher(Client *c)
|
garbeam@76
|
185 {
|
garbeam@76
|
186 XRaiseWindow(dpy, c->win);
|
garbeam@76
|
187 XRaiseWindow(dpy, c->title);
|
garbeam@76
|
188 }
|
garbeam@76
|
189
|
garbeam@76
|
190 void
|
garbeam@76
|
191 killclient(Arg *arg)
|
garbeam@76
|
192 {
|
garbeam@76
|
193 if(!sel)
|
garbeam@76
|
194 return;
|
arg@157
|
195 if(sel->proto & PROTODELWIN)
|
garbeam@77
|
196 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
garbeam@76
|
197 else
|
garbeam@76
|
198 XKillClient(dpy, sel->win);
|
garbeam@76
|
199 }
|
garbeam@76
|
200
|
garbeam@76
|
201 void
|
garbeam@76
|
202 lower(Client *c)
|
garbeam@76
|
203 {
|
garbeam@76
|
204 XLowerWindow(dpy, c->title);
|
garbeam@76
|
205 XLowerWindow(dpy, c->win);
|
garbeam@76
|
206 }
|
garbeam@76
|
207
|
garbeam@76
|
208 void
|
garbeam@10
|
209 manage(Window w, XWindowAttributes *wa)
|
garbeam@5
|
210 {
|
garbeam@80
|
211 Client *c;
|
arg@123
|
212 Window trans;
|
garbeam@5
|
213 XSetWindowAttributes twa;
|
garbeam@5
|
214
|
garbeam@5
|
215 c = emallocz(sizeof(Client));
|
arg@178
|
216 c->tags = emallocz(ntags * sizeof(Bool));
|
garbeam@5
|
217 c->win = w;
|
arg@115
|
218 c->x = c->tx = wa->x;
|
arg@115
|
219 c->y = c->ty = wa->y;
|
arg@115
|
220 c->w = c->tw = wa->width;
|
arg@115
|
221 c->h = wa->height;
|
arg@115
|
222 c->th = bh;
|
arg@100
|
223
|
arg@164
|
224 c->border = 0;
|
arg@163
|
225 setsize(c);
|
arg@163
|
226
|
arg@163
|
227 if(c->h != sh && c->y < bh)
|
arg@115
|
228 c->y = c->ty = bh;
|
arg@104
|
229
|
garbeam@75
|
230 c->proto = getproto(c->win);
|
garbeam@26
|
231 XSelectInput(dpy, c->win,
|
arg@127
|
232 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
garbeam@53
|
233 XGetTransientForHint(dpy, c->win, &trans);
|
garbeam@5
|
234 twa.override_redirect = 1;
|
garbeam@5
|
235 twa.background_pixmap = ParentRelative;
|
arg@161
|
236 twa.event_mask = ExposureMask | EnterWindowMask;
|
garbeam@5
|
237
|
arg@115
|
238 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
garbeam@20
|
239 0, DefaultDepth(dpy, screen), CopyFromParent,
|
garbeam@5
|
240 DefaultVisual(dpy, screen),
|
garbeam@5
|
241 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
garbeam@31
|
242
|
arg@127
|
243 if(clients)
|
arg@127
|
244 clients->prev = c;
|
garbeam@80
|
245 c->next = clients;
|
garbeam@80
|
246 clients = c;
|
garbeam@49
|
247
|
arg@148
|
248 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
garbeam@19
|
249 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
250 XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
251 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
252 XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
arg@198
|
253 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
254 XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
255 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
256
|
arg@148
|
257 XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
|
garbeam@19
|
258 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
259 XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
260 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
261 XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
arg@198
|
262 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
263 XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
264 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
265
|
arg@148
|
266 XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
|
garbeam@18
|
267 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
268 XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
269 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
270 XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK,
|
arg@198
|
271 GrabModeAsync, GrabModeSync, None, None);
|
arg@198
|
272 XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK,
|
arg@198
|
273 GrabModeAsync, GrabModeSync, None, None);
|
garbeam@53
|
274
|
arg@163
|
275 settags(c);
|
garbeam@80
|
276 if(!c->isfloat)
|
arg@163
|
277 c->isfloat = trans
|
arg@163
|
278 || (c->maxw && c->minw &&
|
arg@164
|
279 c->maxw == c->minw && c->maxh == c->minh);
|
garbeam@95
|
280 settitle(c);
|
garbeam@46
|
281 arrange(NULL);
|
garbeam@95
|
282
|
garbeam@60
|
283 /* mapping the window now prevents flicker */
|
arg@142
|
284 XMapRaised(dpy, c->win);
|
arg@142
|
285 XMapRaised(dpy, c->title);
|
arg@142
|
286 if(c->tags[tsel])
|
garbeam@51
|
287 focus(c);
|
garbeam@94
|
288 }
|
garbeam@94
|
289
|
garbeam@94
|
290 void
|
arg@129
|
291 resize(Client *c, Bool sizehints, Corner sticky)
|
garbeam@18
|
292 {
|
arg@123
|
293 int bottom = c->y + c->h;
|
arg@123
|
294 int right = c->x + c->w;
|
arg@164
|
295 /*XConfigureEvent e;*/
|
arg@163
|
296 XWindowChanges wc;
|
garbeam@18
|
297
|
arg@129
|
298 if(sizehints) {
|
garbeam@52
|
299 if(c->incw)
|
arg@115
|
300 c->w -= (c->w - c->basew) % c->incw;
|
garbeam@52
|
301 if(c->inch)
|
arg@115
|
302 c->h -= (c->h - c->baseh) % c->inch;
|
arg@129
|
303 if(c->minw && c->w < c->minw)
|
arg@129
|
304 c->w = c->minw;
|
arg@129
|
305 if(c->minh && c->h < c->minh)
|
arg@129
|
306 c->h = c->minh;
|
arg@129
|
307 if(c->maxw && c->w > c->maxw)
|
arg@129
|
308 c->w = c->maxw;
|
arg@129
|
309 if(c->maxh && c->h > c->maxh)
|
arg@129
|
310 c->h = c->maxh;
|
garbeam@52
|
311 }
|
arg@163
|
312 if(c->x > right) /* might happen on restart */
|
arg@163
|
313 c->x = right - c->w;
|
arg@163
|
314 if(c->y > bottom)
|
arg@163
|
315 c->y = bottom - c->h;
|
arg@105
|
316 if(sticky == TopRight || sticky == BotRight)
|
arg@115
|
317 c->x = right - c->w;
|
arg@105
|
318 if(sticky == BotLeft || sticky == BotRight)
|
arg@115
|
319 c->y = bottom - c->h;
|
arg@106
|
320
|
garbeam@75
|
321 resizetitle(c);
|
arg@163
|
322 wc.x = c->x;
|
arg@163
|
323 wc.y = c->y;
|
arg@163
|
324 wc.width = c->w;
|
arg@163
|
325 wc.height = c->h;
|
arg@164
|
326 if(c->w == sw && c->h == sh)
|
arg@164
|
327 wc.border_width = 0;
|
arg@164
|
328 else
|
arg@164
|
329 wc.border_width = 1;
|
arg@164
|
330 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
garbeam@79
|
331 XSync(dpy, False);
|
garbeam@18
|
332 }
|
garbeam@18
|
333
|
garbeam@76
|
334 void
|
garbeam@76
|
335 setsize(Client *c)
|
garbeam@10
|
336 {
|
arg@123
|
337 long msize;
|
garbeam@76
|
338 XSizeHints size;
|
arg@123
|
339
|
garbeam@76
|
340 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
|
garbeam@76
|
341 size.flags = PSize;
|
garbeam@76
|
342 c->flags = size.flags;
|
garbeam@76
|
343 if(c->flags & PBaseSize) {
|
garbeam@76
|
344 c->basew = size.base_width;
|
garbeam@76
|
345 c->baseh = size.base_height;
|
garbeam@76
|
346 }
|
garbeam@76
|
347 else
|
garbeam@76
|
348 c->basew = c->baseh = 0;
|
garbeam@76
|
349 if(c->flags & PResizeInc) {
|
garbeam@76
|
350 c->incw = size.width_inc;
|
garbeam@76
|
351 c->inch = size.height_inc;
|
garbeam@76
|
352 }
|
garbeam@76
|
353 else
|
garbeam@76
|
354 c->incw = c->inch = 0;
|
garbeam@76
|
355 if(c->flags & PMaxSize) {
|
garbeam@76
|
356 c->maxw = size.max_width;
|
garbeam@76
|
357 c->maxh = size.max_height;
|
garbeam@76
|
358 }
|
garbeam@76
|
359 else
|
garbeam@76
|
360 c->maxw = c->maxh = 0;
|
garbeam@76
|
361 if(c->flags & PMinSize) {
|
garbeam@76
|
362 c->minw = size.min_width;
|
garbeam@76
|
363 c->minh = size.min_height;
|
garbeam@76
|
364 }
|
garbeam@76
|
365 else
|
garbeam@76
|
366 c->minw = c->minh = 0;
|
garbeam@76
|
367 if(c->flags & PWinGravity)
|
garbeam@76
|
368 c->grav = size.win_gravity;
|
garbeam@76
|
369 else
|
garbeam@76
|
370 c->grav = NorthWestGravity;
|
garbeam@76
|
371 }
|
garbeam@76
|
372
|
garbeam@76
|
373 void
|
garbeam@76
|
374 settitle(Client *c)
|
garbeam@76
|
375 {
|
arg@123
|
376 char **list = NULL;
|
arg@123
|
377 int n;
|
garbeam@76
|
378 XTextProperty name;
|
garbeam@76
|
379
|
garbeam@76
|
380 name.nitems = 0;
|
garbeam@76
|
381 c->name[0] = 0;
|
garbeam@77
|
382 XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
|
garbeam@76
|
383 if(!name.nitems)
|
garbeam@76
|
384 XGetWMName(dpy, c->win, &name);
|
garbeam@76
|
385 if(!name.nitems)
|
garbeam@76
|
386 return;
|
garbeam@76
|
387 if(name.encoding == XA_STRING)
|
garbeam@76
|
388 strncpy(c->name, (char *)name.value, sizeof(c->name));
|
garbeam@76
|
389 else {
|
garbeam@76
|
390 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
garbeam@76
|
391 && n > 0 && *list)
|
garbeam@76
|
392 {
|
garbeam@76
|
393 strncpy(c->name, *list, sizeof(c->name));
|
garbeam@76
|
394 XFreeStringList(list);
|
garbeam@76
|
395 }
|
garbeam@76
|
396 }
|
garbeam@76
|
397 XFree(name.value);
|
garbeam@76
|
398 resizetitle(c);
|
garbeam@10
|
399 }
|
garbeam@10
|
400
|
garbeam@10
|
401 void
|
arg@124
|
402 togglemax(Arg *arg)
|
arg@124
|
403 {
|
arg@124
|
404 int ox, oy, ow, oh;
|
arg@124
|
405 XEvent ev;
|
arg@124
|
406
|
arg@124
|
407 if(!sel)
|
arg@124
|
408 return;
|
arg@124
|
409
|
arg@124
|
410 if((sel->ismax = !sel->ismax)) {
|
arg@124
|
411 ox = sel->x;
|
arg@124
|
412 oy = sel->y;
|
arg@124
|
413 ow = sel->w;
|
arg@124
|
414 oh = sel->h;
|
arg@124
|
415 sel->x = sx;
|
arg@124
|
416 sel->y = sy + bh;
|
arg@164
|
417 sel->w = sw - 2;
|
arg@164
|
418 sel->h = sh - 2 - bh;
|
arg@124
|
419
|
arg@124
|
420 higher(sel);
|
arg@124
|
421 resize(sel, False, TopLeft);
|
arg@124
|
422
|
arg@124
|
423 sel->x = ox;
|
arg@124
|
424 sel->y = oy;
|
arg@124
|
425 sel->w = ow;
|
arg@124
|
426 sel->h = oh;
|
arg@124
|
427 }
|
arg@124
|
428 else
|
arg@124
|
429 resize(sel, False, TopLeft);
|
arg@124
|
430 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
arg@124
|
431 }
|
arg@124
|
432
|
arg@124
|
433 void
|
garbeam@10
|
434 unmanage(Client *c)
|
garbeam@10
|
435 {
|
garbeam@10
|
436 XGrabServer(dpy);
|
garbeam@75
|
437 XSetErrorHandler(xerrordummy);
|
garbeam@10
|
438
|
garbeam@18
|
439 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
garbeam@10
|
440 XDestroyWindow(dpy, c->title);
|
garbeam@10
|
441
|
arg@127
|
442 if(c->prev)
|
arg@127
|
443 c->prev->next = c->next;
|
arg@127
|
444 if(c->next)
|
arg@127
|
445 c->next->prev = c->prev;
|
arg@151
|
446 if(c == clients)
|
arg@151
|
447 clients = c->next;
|
arg@127
|
448 if(sel == c) {
|
arg@142
|
449 sel = getnext(c->next);
|
arg@127
|
450 if(!sel)
|
arg@127
|
451 sel = getprev(c->prev);
|
arg@127
|
452 if(!sel)
|
arg@127
|
453 sel = clients;
|
arg@127
|
454 }
|
arg@178
|
455 free(c->tags);
|
garbeam@10
|
456 free(c);
|
garbeam@10
|
457
|
garbeam@79
|
458 XSync(dpy, False);
|
garbeam@74
|
459 XSetErrorHandler(xerror);
|
garbeam@10
|
460 XUngrabServer(dpy);
|
garbeam@46
|
461 arrange(NULL);
|
garbeam@50
|
462 if(sel)
|
garbeam@50
|
463 focus(sel);
|
arg@229
|
464 else
|
arg@229
|
465 XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32,
|
arg@229
|
466 PropModeReplace, (unsigned char *)NULL, 1);
|
garbeam@10
|
467 }
|
garbeam@10
|
468
|
garbeam@75
|
469 void
|
garbeam@75
|
470 zoom(Arg *arg)
|
garbeam@75
|
471 {
|
arg@151
|
472 Client *c;
|
garbeam@75
|
473
|
arg@200
|
474 if(!sel || (arrange != dotile) || sel->isfloat)
|
garbeam@75
|
475 return;
|
garbeam@75
|
476
|
arg@202
|
477 if(sel == getnext(clients)) {
|
arg@142
|
478 if((c = getnext(sel->next)))
|
garbeam@75
|
479 sel = c;
|
arg@202
|
480 else
|
arg@202
|
481 return;
|
garbeam@75
|
482 }
|
garbeam@75
|
483
|
arg@130
|
484 /* pop */
|
arg@130
|
485 if(sel->prev)
|
arg@130
|
486 sel->prev->next = sel->next;
|
arg@130
|
487 if(sel->next)
|
arg@130
|
488 sel->next->prev = sel->prev;
|
arg@130
|
489 sel->prev = NULL;
|
arg@130
|
490 if(clients)
|
arg@130
|
491 clients->prev = sel;
|
arg@130
|
492 sel->next = clients;
|
arg@130
|
493 clients = sel;
|
arg@130
|
494 arrange(NULL);
|
garbeam@75
|
495 focus(sel);
|
garbeam@75
|
496 }
|