summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-13 21:42:17 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-13 21:42:17 +0200
commit66da15324eef4f85c6dda13eba80430dc4cc97bb (patch)
treeb2ecd808ad31e5237cabebdc7d80fc6a4edaf1f4
parentfixed several things, nearly feature complete (diff)
downloaddwm-66da15324eef4f85c6dda13eba80430dc4cc97bb.tar.gz
dwm-66da15324eef4f85c6dda13eba80430dc4cc97bb.zip
added mini stuff
Diffstat (limited to '')
-rw-r--r--client.c51
-rw-r--r--dev.c48
-rw-r--r--dwm.h9
-rw-r--r--event.c7
4 files changed, 69 insertions, 46 deletions
diff --git a/client.c b/client.c
index 6d7bd92..3fb2318 100644
--- a/client.c
+++ b/client.c
@@ -11,10 +11,11 @@
11 11
12#include "dwm.h" 12#include "dwm.h"
13 13
14static void (*arrange)(Arg *) = tiling; 14void (*arrange)(Arg *) = tiling;
15 15
16static Rule rule[] = { 16static Rule rule[] = {
17 { "Firefox-bin", "Gecko", { [Twww] = "www" } }, 17 /* class instance tags floating */
18 { "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
18}; 19};
19 20
20static Client * 21static Client *
@@ -64,27 +65,27 @@ view(Arg *arg)
64} 65}
65 66
66void 67void
67tag(Arg *arg) 68tappend(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);
86} 75}
87 76
77void
78ttrunc(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);
87}
88
88static void 89static void
89ban_client(Client *c) 90ban_client(Client *c)
90{ 91{
@@ -122,13 +123,18 @@ tiling(Arg *arg)
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;
@@ -330,14 +336,13 @@ init_tags(Client *c)
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 }
@@ -357,6 +362,7 @@ 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;
@@ -370,7 +376,7 @@ manage(Window w, XWindowAttributes *wa)
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;
@@ -396,6 +402,11 @@ manage(Window w, XWindowAttributes *wa)
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);
diff --git a/dev.c b/dev.c
index 5e338b3..4c6e45f 100644
--- a/dev.c
+++ b/dev.c
@@ -20,27 +20,33 @@ const char *browse[] = { "firefox", NULL };
20const char *xlock[] = { "xlock", NULL }; 20const char *xlock[] = { "xlock", NULL };
21 21
22static Key key[] = { 22static Key key[] = {
23 { Mod1Mask, XK_Return, spawn, { .argv = term } }, 23 /* modifier key function arguments */
24 { Mod1Mask, XK_w, spawn, { .argv = browse } }, 24 { Mod1Mask, XK_Return, zoom, { 0 } },
25 { Mod1Mask, XK_l, spawn, { .argv = xlock } }, 25 { Mod1Mask, XK_k, prevc, { 0 } },
26 { Mod1Mask, XK_k, prevc, { 0 } }, 26 { Mod1Mask, XK_j, nextc, { 0 } },
27 { Mod1Mask, XK_j, nextc, { 0 } }, 27 { Mod1Mask, XK_m, max, { 0 } },
28 { Mod1Mask, XK_m, max, { 0 } }, 28 { Mod1Mask, XK_0, view, { .i = Tscratch } },
29 { Mod1Mask, XK_0, view, { .i = Tscratch } }, 29 { Mod1Mask, XK_1, view, { .i = Tdev } },
30 { Mod1Mask, XK_1, view, { .i = Tdev } }, 30 { Mod1Mask, XK_2, view, { .i = Tirc } },
31 { Mod1Mask, XK_2, view, { .i = Tirc } }, 31 { Mod1Mask, XK_3, view, { .i = Twww } },
32 { Mod1Mask, XK_3, view, { .i = Twww } }, 32 { Mod1Mask, XK_4, view, { .i = Twork } },
33 { Mod1Mask, XK_4, view, { .i = Twork } }, 33 { Mod1Mask, XK_space, tiling, { 0 } },
34 { Mod1Mask, XK_space, tiling, { 0 } }, 34 { Mod1Mask|ShiftMask, XK_space, floating, { 0 } },
35 { Mod1Mask | ShiftMask, XK_Return, zoom, { 0 } }, 35 { Mod1Mask|ShiftMask, XK_0, ttrunc, { .i = Tscratch } },
36 { Mod1Mask | ShiftMask, XK_space, floating, { 0 } }, 36 { Mod1Mask|ShiftMask, XK_1, ttrunc, { .i = Tdev } },
37 { Mod1Mask | ShiftMask, XK_0, tag, { .i = Tscratch } }, 37 { Mod1Mask|ShiftMask, XK_2, ttrunc, { .i = Tirc } },
38 { Mod1Mask | ShiftMask, XK_1, tag, { .i = Tdev } }, 38 { Mod1Mask|ShiftMask, XK_3, ttrunc, { .i = Twww } },
39 { Mod1Mask | ShiftMask, XK_2, tag, { .i = Tirc } }, 39 { Mod1Mask|ShiftMask, XK_4, ttrunc, { .i = Twork } },
40 { Mod1Mask | ShiftMask, XK_3, tag, { .i = Twww } }, 40 { Mod1Mask|ShiftMask, XK_c, ckill, { 0 } },
41 { Mod1Mask | ShiftMask, XK_4, tag, { .i = Twork } }, 41 { Mod1Mask|ShiftMask, XK_q, quit, { 0 } },
42 { Mod1Mask | ShiftMask, XK_c, ckill, { 0 } }, 42 { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } },
43 { Mod1Mask | ShiftMask, XK_q, quit, { 0 } }, 43 { Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } },
44 { Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } },
45 { ControlMask, XK_0, tappend, { .i = Tscratch } },
46 { ControlMask, XK_1, tappend, { .i = Tdev } },
47 { ControlMask, XK_2, tappend, { .i = Tirc } },
48 { ControlMask, XK_3, tappend, { .i = Twww } },
49 { ControlMask, XK_4, tappend, { .i = Twork } },
44}; 50};
45 51
46/********** CUSTOMIZE **********/ 52/********** CUSTOMIZE **********/
diff --git a/dwm.h b/dwm.h
index 8af63f0..ee15949 100644
--- a/dwm.h
+++ b/dwm.h
@@ -66,8 +66,8 @@ struct Client {
66 int grav; 66 int grav;
67 unsigned int border; 67 unsigned int border;
68 long flags; 68 long flags;
69 Bool floating;
69 Window win; 70 Window win;
70 Window trans;
71 Window title; 71 Window title;
72 Client *next; 72 Client *next;
73 Client *revert; 73 Client *revert;
@@ -77,6 +77,7 @@ struct Rule {
77 const char *class; 77 const char *class;
78 const char *instance; 78 const char *instance;
79 char *tags[TLast]; 79 char *tags[TLast];
80 Bool floating;
80}; 81};
81 82
82struct Key { 83struct Key {
@@ -91,7 +92,8 @@ extern Window root;
91extern Atom wm_atom[WMLast], net_atom[NetLast]; 92extern Atom wm_atom[WMLast], net_atom[NetLast];
92extern Cursor cursor[CurLast]; 93extern Cursor cursor[CurLast];
93extern Bool running, issel; 94extern Bool running, issel;
94extern void (*handler[LASTEvent]) (XEvent *); 95extern void (*handler[LASTEvent])(XEvent *);
96extern void (*arrange)(Arg *);
95 97
96extern int tsel, screen, sx, sy, sw, sh, mw, th; 98extern int tsel, screen, sx, sy, sw, sh, mw, th;
97extern char *tags[TLast]; 99extern char *tags[TLast];
@@ -117,7 +119,8 @@ extern void prevc(Arg *arg);
117extern void max(Arg *arg); 119extern void max(Arg *arg);
118extern void floating(Arg *arg); 120extern void floating(Arg *arg);
119extern void tiling(Arg *arg); 121extern void tiling(Arg *arg);
120extern void tag(Arg *arg); 122extern void ttrunc(Arg *arg);
123extern void tappend(Arg *arg);
121extern void view(Arg *arg); 124extern void view(Arg *arg);
122extern void zoom(Arg *arg); 125extern void zoom(Arg *arg);
123extern void gravitate(Client *c, Bool invert); 126extern void gravitate(Client *c, Bool invert);
diff --git a/event.c b/event.c
index 937bee2..e85e11f 100644
--- a/event.c
+++ b/event.c
@@ -89,6 +89,7 @@ configurerequest(XEvent *e)
89 if(ev->value_mask & CWBorderWidth) 89 if(ev->value_mask & CWBorderWidth)
90 c->border = ev->border_width; 90 c->border = ev->border_width;
91 gravitate(c, False); 91 gravitate(c, False);
92 resize(c, True);
92 } 93 }
93 94
94 wc.x = ev->x; 95 wc.x = ev->x;
@@ -179,6 +180,7 @@ static void
179propertynotify(XEvent *e) 180propertynotify(XEvent *e)
180{ 181{
181 XPropertyEvent *ev = &e->xproperty; 182 XPropertyEvent *ev = &e->xproperty;
183 Window trans;
182 Client *c; 184 Client *c;
183 185
184 if(ev->state == PropertyDelete) 186 if(ev->state == PropertyDelete)
@@ -192,9 +194,10 @@ propertynotify(XEvent *e)
192 switch (ev->atom) { 194 switch (ev->atom) {
193 default: break; 195 default: break;
194 case XA_WM_TRANSIENT_FOR: 196 case XA_WM_TRANSIENT_FOR:
195 XGetTransientForHint(dpy, c->win, &c->trans); 197 XGetTransientForHint(dpy, c->win, &trans);
198 if(!c->floating && (c->floating = (trans != 0)))
199 arrange(NULL);
196 break; 200 break;
197 update_size(c);
198 case XA_WM_NORMAL_HINTS: 201 case XA_WM_NORMAL_HINTS:
199 update_size(c); 202 update_size(c);
200 break; 203 break;