summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-07-20 15:07:35 +0200
committerarg@10ksloc.org <unknown>2006-07-20 15:07:35 +0200
commit4688ad181da14be36e034918580ec0ce5968ffdb (patch)
treee919b8e6e89400a8b5dac01fa611090f139d5b5f
parentcleaned up code (diff)
downloaddwm-4688ad181da14be36e034918580ec0ce5968ffdb.tar.gz
dwm-4688ad181da14be36e034918580ec0ce5968ffdb.zip
made status bar drawing more robust, implemented togglemax and togglemode, works quite well
-rw-r--r--client.c53
-rw-r--r--draw.c13
-rw-r--r--dwm.h4
-rw-r--r--event.c11
-rw-r--r--tag.c11
5 files changed, 59 insertions, 33 deletions
diff --git a/client.c b/client.c
index 889daa5..1bdebd2 100644
--- a/client.c
+++ b/client.c
@@ -70,6 +70,9 @@ focusnext(Arg *arg)
70 if(!sel) 70 if(!sel)
71 return; 71 return;
72 72
73 if(sel->ismax)
74 togglemax(NULL);
75
73 if(!(c = getnext(sel->next, tsel))) 76 if(!(c = getnext(sel->next, tsel)))
74 c = getnext(clients, tsel); 77 c = getnext(clients, tsel);
75 if(c) { 78 if(c) {
@@ -87,6 +90,9 @@ focusprev(Arg *arg)
87 if(!sel) 90 if(!sel)
88 return; 91 return;
89 92
93 if(sel->ismax)
94 togglemax(NULL);
95
90 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { 96 if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
91 higher(c); 97 higher(c);
92 focus(c); 98 focus(c);
@@ -234,8 +240,6 @@ manage(Window w, XWindowAttributes *wa)
234 c->next = clients; 240 c->next = clients;
235 clients = c; 241 clients = c;
236 242
237 XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
238 GrabModeAsync, GrabModeSync, None, None);
239 XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask, 243 XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
240 GrabModeAsync, GrabModeSync, None, None); 244 GrabModeAsync, GrabModeSync, None, None);
241 XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask, 245 XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
@@ -264,19 +268,6 @@ manage(Window w, XWindowAttributes *wa)
264} 268}
265 269
266void 270void
267maximize(Arg *arg)
268{
269 if(!sel)
270 return;
271 sel->x = sx;
272 sel->y = sy + bh;
273 sel->w = sw - 2 * sel->border;
274 sel->h = sh - 2 * sel->border - bh;
275 higher(sel);
276 resize(sel, False, TopLeft);
277}
278
279void
280pop(Client *c) 271pop(Client *c)
281{ 272{
282 Client **l; 273 Client **l;
@@ -405,6 +396,38 @@ settitle(Client *c)
405} 396}
406 397
407void 398void
399togglemax(Arg *arg)
400{
401 int ox, oy, ow, oh;
402 XEvent ev;
403
404 if(!sel)
405 return;
406
407 if((sel->ismax = !sel->ismax)) {
408 ox = sel->x;
409 oy = sel->y;
410 ow = sel->w;
411 oh = sel->h;
412 sel->x = sx;
413 sel->y = sy + bh;
414 sel->w = sw - 2 * sel->border;
415 sel->h = sh - 2 * sel->border - bh;
416
417 higher(sel);
418 resize(sel, False, TopLeft);
419
420 sel->x = ox;
421 sel->y = oy;
422 sel->w = ow;
423 sel->h = oh;
424 }
425 else
426 resize(sel, False, TopLeft);
427 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
428}
429
430void
408unmanage(Client *c) 431unmanage(Client *c)
409{ 432{
410 Client **l; 433 Client **l;
diff --git a/draw.c b/draw.c
index b5d8bd2..0c920e5 100644
--- a/draw.c
+++ b/draw.c
@@ -107,7 +107,7 @@ drawall()
107void 107void
108drawstatus() 108drawstatus()
109{ 109{
110 int i; 110 int i, x;
111 Bool istile = arrange == dotile; 111 Bool istile = arrange == dotile;
112 112
113 dc.x = dc.y = 0; 113 dc.x = dc.y = 0;
@@ -123,15 +123,14 @@ drawstatus()
123 else 123 else
124 drawtext(tags[i], (i != tsel), True); 124 drawtext(tags[i], (i != tsel), True);
125 } 125 }
126 if(sel) { 126 x = dc.x + dc.w;
127 dc.x += dc.w;
128 dc.w = textw(sel->name);
129 drawtext(sel->name, istile, True);
130 }
131 dc.w = textw(stext); 127 dc.w = textw(stext);
132 dc.x = bx + bw - dc.w; 128 dc.x = bx + bw - dc.w;
133 drawtext(stext, !istile, False); 129 drawtext(stext, !istile, False);
134 130 if(sel && ((dc.w = dc.x - x) >= bh)) {
131 dc.x = x;
132 drawtext(sel->name, istile, True);
133 }
135 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); 134 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
136 XSync(dpy, False); 135 XSync(dpy, False);
137} 136}
diff --git a/dwm.h b/dwm.h
index a410f4e..1529d17 100644
--- a/dwm.h
+++ b/dwm.h
@@ -74,6 +74,7 @@ struct Client {
74 unsigned int border; 74 unsigned int border;
75 long flags; 75 long flags;
76 Bool isfloat; 76 Bool isfloat;
77 Bool ismax;
77 Client *next; 78 Client *next;
78 Client *revert; 79 Client *revert;
79 Window win; 80 Window win;
@@ -104,11 +105,11 @@ extern void higher(Client *c);
104extern void killclient(Arg *arg); 105extern void killclient(Arg *arg);
105extern void lower(Client *c); 106extern void lower(Client *c);
106extern void manage(Window w, XWindowAttributes *wa); 107extern void manage(Window w, XWindowAttributes *wa);
107extern void maximize(Arg *arg);
108extern void pop(Client *c); 108extern void pop(Client *c);
109extern void resize(Client *c, Bool inc, Corner sticky); 109extern void resize(Client *c, Bool inc, Corner sticky);
110extern void setsize(Client *c); 110extern void setsize(Client *c);
111extern void settitle(Client *c); 111extern void settitle(Client *c);
112extern void togglemax(Arg *arg);
112extern void unmanage(Client *c); 113extern void unmanage(Client *c);
113extern void zoom(Arg *arg); 114extern void zoom(Arg *arg);
114 115
@@ -137,6 +138,7 @@ extern Client *getnext(Client *c, unsigned int t);
137extern void heretag(Arg *arg); 138extern void heretag(Arg *arg);
138extern void replacetag(Arg *arg); 139extern void replacetag(Arg *arg);
139extern void settags(Client *c); 140extern void settags(Client *c);
141extern void togglemode(Arg *arg);
140extern void view(Arg *arg); 142extern void view(Arg *arg);
141 143
142/* util.c */ 144/* util.c */
diff --git a/event.c b/event.c
index 2736903..5d7c8a7 100644
--- a/event.c
+++ b/event.c
@@ -40,8 +40,8 @@ static Key key[] = {
40 { MODKEY, XK_3, view, { .i = Twork } }, 40 { MODKEY, XK_3, view, { .i = Twork } },
41 { MODKEY, XK_j, focusnext, { 0 } }, 41 { MODKEY, XK_j, focusnext, { 0 } },
42 { MODKEY, XK_k, focusprev, { 0 } }, 42 { MODKEY, XK_k, focusprev, { 0 } },
43 { MODKEY, XK_m, maximize, { 0 } }, 43 { MODKEY, XK_m, togglemax, { 0 } },
44 { MODKEY, XK_space, dotile, { 0 } }, 44 { MODKEY, XK_space, togglemode, { 0 } },
45 { MODKEY, XK_Return, zoom, { 0 } }, 45 { MODKEY, XK_Return, zoom, { 0 } },
46 { ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } }, 46 { ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
47 { ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } }, 47 { ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
@@ -55,7 +55,6 @@ static Key key[] = {
55 { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, 55 { MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
56 { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, 56 { MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } },
57 { MODKEY|ShiftMask, XK_q, quit, { 0 } }, 57 { MODKEY|ShiftMask, XK_q, quit, { 0 } },
58 { MODKEY|ShiftMask, XK_space, dofloat, { 0 } },
59 { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, 58 { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },
60 { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, 59 { MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } },
61}; 60};
@@ -170,11 +169,7 @@ buttonpress(XEvent *e)
170 default: 169 default:
171 break; 170 break;
172 case Button1: 171 case Button1:
173 if(arrange == dotile && !c->isfloat) { 172 if(arrange == dofloat || c->isfloat) {
174 if((ev->state & ControlMask) && (ev->button == Button1))
175 zoom(NULL);
176 }
177 else {
178 higher(c); 173 higher(c);
179 movemouse(c); 174 movemouse(c);
180 } 175 }
diff --git a/tag.c b/tag.c
index 186a5ae..d6c349b 100644
--- a/tag.c
+++ b/tag.c
@@ -51,8 +51,8 @@ dofloat(Arg *arg)
51{ 51{
52 Client *c; 52 Client *c;
53 53
54 arrange = dofloat;
55 for(c = clients; c; c = c->next) { 54 for(c = clients; c; c = c->next) {
55 c->ismax = False;
56 if(c->tags[tsel]) { 56 if(c->tags[tsel]) {
57 resize(c, True, TopLeft); 57 resize(c, True, TopLeft);
58 } 58 }
@@ -75,7 +75,6 @@ dotile(Arg *arg)
75 Client *c; 75 Client *c;
76 76
77 w = sw - mw; 77 w = sw - mw;
78 arrange = dotile;
79 for(n = 0, c = clients; c; c = c->next) 78 for(n = 0, c = clients; c; c = c->next)
80 if(c->tags[tsel] && !c->isfloat) 79 if(c->tags[tsel] && !c->isfloat)
81 n++; 80 n++;
@@ -86,6 +85,7 @@ dotile(Arg *arg)
86 h = sh - bh; 85 h = sh - bh;
87 86
88 for(i = 0, c = clients; c; c = c->next) { 87 for(i = 0, c = clients; c; c = c->next) {
88 c->ismax = False;
89 if(c->tags[tsel]) { 89 if(c->tags[tsel]) {
90 if(c->isfloat) { 90 if(c->isfloat) {
91 higher(c); 91 higher(c);
@@ -213,6 +213,13 @@ settags(Client *c)
213} 213}
214 214
215void 215void
216togglemode(Arg *arg)
217{
218 arrange = arrange == dofloat ? dotile : dofloat;
219 arrange(NULL);
220}
221
222void
216view(Arg *arg) 223view(Arg *arg)
217{ 224{
218 tsel = arg->i; 225 tsel = arg->i;