made status bar drawing more robust, implemented togglemax and togglemode, works quite well

This commit is contained in:
arg@10ksloc.org 2006-07-20 15:07:35 +02:00
parent dc5d967ee6
commit 4688ad181d
5 changed files with 59 additions and 33 deletions

View File

@ -70,6 +70,9 @@ focusnext(Arg *arg)
if(!sel)
return;
if(sel->ismax)
togglemax(NULL);
if(!(c = getnext(sel->next, tsel)))
c = getnext(clients, tsel);
if(c) {
@ -87,6 +90,9 @@ focusprev(Arg *arg)
if(!sel)
return;
if(sel->ismax)
togglemax(NULL);
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
higher(c);
focus(c);
@ -234,8 +240,6 @@ manage(Window w, XWindowAttributes *wa)
c->next = clients;
clients = c;
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
@ -263,19 +267,6 @@ manage(Window w, XWindowAttributes *wa)
}
}
void
maximize(Arg *arg)
{
if(!sel)
return;
sel->x = sx;
sel->y = sy + bh;
sel->w = sw - 2 * sel->border;
sel->h = sh - 2 * sel->border - bh;
higher(sel);
resize(sel, False, TopLeft);
}
void
pop(Client *c)
{
@ -404,6 +395,38 @@ settitle(Client *c)
resizetitle(c);
}
void
togglemax(Arg *arg)
{
int ox, oy, ow, oh;
XEvent ev;
if(!sel)
return;
if((sel->ismax = !sel->ismax)) {
ox = sel->x;
oy = sel->y;
ow = sel->w;
oh = sel->h;
sel->x = sx;
sel->y = sy + bh;
sel->w = sw - 2 * sel->border;
sel->h = sh - 2 * sel->border - bh;
higher(sel);
resize(sel, False, TopLeft);
sel->x = ox;
sel->y = oy;
sel->w = ow;
sel->h = oh;
}
else
resize(sel, False, TopLeft);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
unmanage(Client *c)
{

13
draw.c
View File

@ -107,7 +107,7 @@ drawall()
void
drawstatus()
{
int i;
int i, x;
Bool istile = arrange == dotile;
dc.x = dc.y = 0;
@ -123,15 +123,14 @@ drawstatus()
else
drawtext(tags[i], (i != tsel), True);
}
if(sel) {
dc.x += dc.w;
dc.w = textw(sel->name);
drawtext(sel->name, istile, True);
}
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = bx + bw - dc.w;
drawtext(stext, !istile, False);
if(sel && ((dc.w = dc.x - x) >= bh)) {
dc.x = x;
drawtext(sel->name, istile, True);
}
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
XSync(dpy, False);
}

4
dwm.h
View File

@ -74,6 +74,7 @@ struct Client {
unsigned int border;
long flags;
Bool isfloat;
Bool ismax;
Client *next;
Client *revert;
Window win;
@ -104,11 +105,11 @@ extern void higher(Client *c);
extern void killclient(Arg *arg);
extern void lower(Client *c);
extern void manage(Window w, XWindowAttributes *wa);
extern void maximize(Arg *arg);
extern void pop(Client *c);
extern void resize(Client *c, Bool inc, Corner sticky);
extern void setsize(Client *c);
extern void settitle(Client *c);
extern void togglemax(Arg *arg);
extern void unmanage(Client *c);
extern void zoom(Arg *arg);
@ -137,6 +138,7 @@ extern Client *getnext(Client *c, unsigned int t);
extern void heretag(Arg *arg);
extern void replacetag(Arg *arg);
extern void settags(Client *c);
extern void togglemode(Arg *arg);
extern void view(Arg *arg);
/* util.c */

11
event.c
View File

@ -40,8 +40,8 @@ static Key key[] = {
{ MODKEY, XK_3, view, { .i = Twork } },
{ MODKEY, XK_j, focusnext, { 0 } },
{ MODKEY, XK_k, focusprev, { 0 } },
{ MODKEY, XK_m, maximize, { 0 } },
{ MODKEY, XK_space, dotile, { 0 } },
{ MODKEY, XK_m, togglemax, { 0 } },
{ MODKEY, XK_space, togglemode, { 0 } },
{ MODKEY, XK_Return, zoom, { 0 } },
{ ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
{ ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
@ -55,7 +55,6 @@ static Key key[] = {
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
{ MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } },
{ MODKEY|ShiftMask, XK_q, quit, { 0 } },
{ MODKEY|ShiftMask, XK_space, dofloat, { 0 } },
{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } },
};
@ -170,11 +169,7 @@ buttonpress(XEvent *e)
default:
break;
case Button1:
if(arrange == dotile && !c->isfloat) {
if((ev->state & ControlMask) && (ev->button == Button1))
zoom(NULL);
}
else {
if(arrange == dofloat || c->isfloat) {
higher(c);
movemouse(c);
}

11
tag.c
View File

@ -51,8 +51,8 @@ dofloat(Arg *arg)
{
Client *c;
arrange = dofloat;
for(c = clients; c; c = c->next) {
c->ismax = False;
if(c->tags[tsel]) {
resize(c, True, TopLeft);
}
@ -75,7 +75,6 @@ dotile(Arg *arg)
Client *c;
w = sw - mw;
arrange = dotile;
for(n = 0, c = clients; c; c = c->next)
if(c->tags[tsel] && !c->isfloat)
n++;
@ -86,6 +85,7 @@ dotile(Arg *arg)
h = sh - bh;
for(i = 0, c = clients; c; c = c->next) {
c->ismax = False;
if(c->tags[tsel]) {
if(c->isfloat) {
higher(c);
@ -212,6 +212,13 @@ settags(Client *c)
c->tags[tsel] = tags[tsel];
}
void
togglemode(Arg *arg)
{
arrange = arrange == dofloat ? dotile : dofloat;
arrange(NULL);
}
void
view(Arg *arg)
{