Mercurial > aewl
comparison client.c @ 53:529901e6a227
added mini stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 21:42:17 +0200 |
parents | d18f6dd0cf23 |
children | a64602deac83 |
comparison
equal
deleted
inserted
replaced
52:d18f6dd0cf23 | 53:529901e6a227 |
---|---|
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xutil.h> | 10 #include <X11/Xutil.h> |
11 | 11 |
12 #include "dwm.h" | 12 #include "dwm.h" |
13 | 13 |
14 static void (*arrange)(Arg *) = tiling; | 14 void (*arrange)(Arg *) = tiling; |
15 | 15 |
16 static Rule rule[] = { | 16 static Rule rule[] = { |
17 { "Firefox-bin", "Gecko", { [Twww] = "www" } }, | 17 /* class instance tags floating */ |
18 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, | |
18 }; | 19 }; |
19 | 20 |
20 static Client * | 21 static Client * |
21 next(Client *c) | 22 next(Client *c) |
22 { | 23 { |
62 tsel = arg->i; | 63 tsel = arg->i; |
63 arrange(NULL); | 64 arrange(NULL); |
64 } | 65 } |
65 | 66 |
66 void | 67 void |
67 tag(Arg *arg) | 68 tappend(Arg *arg) |
68 { | 69 { |
69 int i, n; | |
70 if(!sel) | 70 if(!sel) |
71 return; | 71 return; |
72 | 72 |
73 if(arg->i == tsel) { | 73 sel->tags[arg->i] = tags[arg->i]; |
74 for(n = i = 0; i < TLast; i++) | |
75 if(sel->tags[i]) | |
76 n++; | |
77 if(n < 2) | |
78 return; | |
79 } | |
80 | |
81 if(sel->tags[arg->i]) | |
82 sel->tags[arg->i] = NULL; /* toggle tag */ | |
83 else | |
84 sel->tags[arg->i] = tags[arg->i]; | |
85 arrange(NULL); | 74 arrange(NULL); |
75 } | |
76 | |
77 void | |
78 ttrunc(Arg *arg) | |
79 { | |
80 int i; | |
81 if(!sel) | |
82 return; | |
83 | |
84 for(i = 0; i < TLast; i++) | |
85 sel->tags[i] = NULL; | |
86 tappend(arg); | |
86 } | 87 } |
87 | 88 |
88 static void | 89 static void |
89 ban_client(Client *c) | 90 ban_client(Client *c) |
90 { | 91 { |
120 int n, i, w, h; | 121 int n, i, w, h; |
121 | 122 |
122 w = sw - mw; | 123 w = sw - mw; |
123 arrange = tiling; | 124 arrange = tiling; |
124 for(n = 0, c = clients; c; c = c->next) | 125 for(n = 0, c = clients; c; c = c->next) |
125 if(c->tags[tsel]) | 126 if(c->tags[tsel] && !c->floating) |
126 n++; | 127 n++; |
127 | 128 |
128 h = (n > 1) ? sh / (n - 1) : sh; | 129 h = (n > 1) ? sh / (n - 1) : sh; |
129 | 130 |
130 for(i = 0, c = clients; c; c = c->next) { | 131 for(i = 0, c = clients; c; c = c->next) { |
131 if(c->tags[tsel]) { | 132 if(c->tags[tsel]) { |
133 if(c->floating) { | |
134 craise(c); | |
135 resize(c, True); | |
136 continue; | |
137 } | |
132 if(n == 1) { | 138 if(n == 1) { |
133 c->x = sx; | 139 c->x = sx; |
134 c->y = sy; | 140 c->y = sy; |
135 c->w = sw - 2 * c->border; | 141 c->w = sw - 2 * c->border; |
136 c->h = sh - 2 * c->border; | 142 c->h = sh - 2 * c->border; |
328 return; | 334 return; |
329 } | 335 } |
330 | 336 |
331 if(XGetClassHint(dpy, c->win, &ch)) { | 337 if(XGetClassHint(dpy, c->win, &ch)) { |
332 if(ch.res_class && ch.res_name) { | 338 if(ch.res_class && ch.res_name) { |
333 fprintf(stderr, "%s:%s\n", ch.res_class, ch.res_name); | |
334 for(i = 0; i < len; i++) | 339 for(i = 0; i < len; i++) |
335 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) | 340 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) |
336 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) | 341 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) |
337 { | 342 { |
338 fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name); | |
339 for(j = 0; j < TLast; j++) | 343 for(j = 0; j < TLast; j++) |
340 c->tags[j] = rule[i].tags[j]; | 344 c->tags[j] = rule[i].tags[j]; |
345 c->floating = rule[i].floating; | |
341 matched = True; | 346 matched = True; |
342 break; | 347 break; |
343 } | 348 } |
344 } | 349 } |
345 if(ch.res_class) | 350 if(ch.res_class) |
355 void | 360 void |
356 manage(Window w, XWindowAttributes *wa) | 361 manage(Window w, XWindowAttributes *wa) |
357 { | 362 { |
358 Client *c, **l; | 363 Client *c, **l; |
359 XSetWindowAttributes twa; | 364 XSetWindowAttributes twa; |
365 Window trans; | |
360 | 366 |
361 c = emallocz(sizeof(Client)); | 367 c = emallocz(sizeof(Client)); |
362 c->win = w; | 368 c->win = w; |
363 c->tx = c->x = wa->x; | 369 c->tx = c->x = wa->x; |
364 c->ty = c->y = wa->y; | 370 c->ty = c->y = wa->y; |
368 c->border = 1; | 374 c->border = 1; |
369 c->proto = win_proto(c->win); | 375 c->proto = win_proto(c->win); |
370 update_size(c); | 376 update_size(c); |
371 XSelectInput(dpy, c->win, | 377 XSelectInput(dpy, c->win, |
372 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 378 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
373 XGetTransientForHint(dpy, c->win, &c->trans); | 379 XGetTransientForHint(dpy, c->win, &trans); |
374 twa.override_redirect = 1; | 380 twa.override_redirect = 1; |
375 twa.background_pixmap = ParentRelative; | 381 twa.background_pixmap = ParentRelative; |
376 twa.event_mask = ExposureMask; | 382 twa.event_mask = ExposureMask; |
377 | 383 |
378 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, | 384 c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, |
394 GrabModeAsync, GrabModeSync, None, None); | 400 GrabModeAsync, GrabModeSync, None, None); |
395 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, | 401 XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, |
396 GrabModeAsync, GrabModeSync, None, None); | 402 GrabModeAsync, GrabModeSync, None, None); |
397 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, | 403 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
398 GrabModeAsync, GrabModeSync, None, None); | 404 GrabModeAsync, GrabModeSync, None, None); |
405 | |
406 if(!c->floating) | |
407 c->floating = trans | |
408 || ((c->maxw == c->minw) && (c->maxh == c->minh)); | |
409 | |
399 arrange(NULL); | 410 arrange(NULL); |
400 if(c->tags[tsel]) | 411 if(c->tags[tsel]) |
401 focus(c); | 412 focus(c); |
402 else | 413 else |
403 ban_client(c); | 414 ban_client(c); |