9 changed files with 374 additions and 377 deletions
@ -1,54 +0,0 @@ |
|||
/*
|
|||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> |
|||
* See LICENSE file for license details. |
|||
*/ |
|||
|
|||
#include "dwm.h" |
|||
|
|||
void |
|||
barclick(XButtonPressedEvent *e) |
|||
{ |
|||
int x = 0; |
|||
Arg a; |
|||
for(a.i = 0; a.i < TLast; a.i++) { |
|||
x += textw(tags[a.i]) + dc.font.height; |
|||
if(e->x < x) { |
|||
view(&a); |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void |
|||
draw_bar() |
|||
{ |
|||
int i, modw; |
|||
char *mode = arrange == tiling ? "#" : "~"; |
|||
|
|||
dc.x = dc.y = 0; |
|||
dc.w = bw; |
|||
drawtext(NULL, False, False); |
|||
|
|||
modw = textw(mode) + dc.font.height; |
|||
dc.w = 0; |
|||
for(i = 0; i < TLast; i++) { |
|||
dc.x += dc.w; |
|||
dc.w = textw(tags[i]) + dc.font.height; |
|||
drawtext(tags[i], i == tsel, True); |
|||
} |
|||
if(sel) { |
|||
dc.x += dc.w; |
|||
dc.w = textw(sel->name) + dc.font.height; |
|||
drawtext(sel->name, True, True); |
|||
} |
|||
dc.w = textw(stext) + dc.font.height; |
|||
dc.x = bx + bw - dc.w - modw; |
|||
drawtext(stext, False, False); |
|||
|
|||
dc.x = bx + bw - modw; |
|||
dc.w = modw; |
|||
drawtext(mode, True, True); |
|||
|
|||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); |
|||
XFlush(dpy); |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
/*
|
|||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> |
|||
* See LICENSE file for license details. |
|||
*/ |
|||
|
|||
#include "dwm.h" |
|||
|
|||
void (*arrange)(Arg *) = tiling; |
|||
|
|||
void |
|||
view(Arg *arg) |
|||
{ |
|||
Client *c; |
|||
|
|||
tsel = arg->i; |
|||
arrange(NULL); |
|||
|
|||
for(c = clients; c; c = next(c->next)) |
|||
draw_client(c); |
|||
draw_bar(); |
|||
} |
|||
|
|||
void |
|||
floating(Arg *arg) |
|||
{ |
|||
Client *c; |
|||
|
|||
arrange = floating; |
|||
for(c = clients; c; c = c->next) { |
|||
if(c->tags[tsel]) |
|||
resize(c, True); |
|||
else |
|||
ban_client(c); |
|||
} |
|||
if(sel && !sel->tags[tsel]) { |
|||
if((sel = next(clients))) { |
|||
craise(sel); |
|||
focus(sel); |
|||
} |
|||
} |
|||
draw_bar(); |
|||
} |
|||
|
|||
void |
|||
tiling(Arg *arg) |
|||
{ |
|||
Client *c; |
|||
int n, i, w, h; |
|||
|
|||
w = sw - mw; |
|||
arrange = tiling; |
|||
for(n = 0, c = clients; c; c = c->next) |
|||
if(c->tags[tsel] && !c->floating) |
|||
n++; |
|||
|
|||
if(n > 1) |
|||
h = (sh - bh) / (n - 1); |
|||
else |
|||
h = sh - bh; |
|||
|
|||
for(i = 0, c = clients; c; c = c->next) { |
|||
if(c->tags[tsel]) { |
|||
if(c->floating) { |
|||
craise(c); |
|||
resize(c, True); |
|||
continue; |
|||
} |
|||
if(n == 1) { |
|||
c->x = sx; |
|||
c->y = sy + bh; |
|||
c->w = sw - 2 * c->border; |
|||
c->h = sh - 2 * c->border - bh; |
|||
} |
|||
else if(i == 0) { |
|||
c->x = sx; |
|||
c->y = sy + bh; |
|||
c->w = mw - 2 * c->border; |
|||
c->h = sh - 2 * c->border - bh; |
|||
} |
|||
else { |
|||
c->x = sx + mw; |
|||
c->y = sy + (i - 1) * h + bh; |
|||
c->w = w - 2 * c->border; |
|||
c->h = h - 2 * c->border; |
|||
} |
|||
resize(c, False); |
|||
i++; |
|||
} |
|||
else |
|||
ban_client(c); |
|||
} |
|||
if(!sel || (sel && !sel->tags[tsel])) { |
|||
if((sel = next(clients))) { |
|||
craise(sel); |
|||
focus(sel); |
|||
} |
|||
} |
|||
draw_bar(); |
|||
} |
|||
|
|||
Loading…
Reference in new issue