1
0

implemented the maximization as I described on the mailinglist, this feels better to me.

This commit is contained in:
arg@mmvi 2006-09-22 07:37:56 +02:00
parent bda53ac6ad
commit d800ec05ff
7 changed files with 25 additions and 50 deletions

View File

@ -89,8 +89,6 @@ focus(Client *c) {
if(!sel) if(!sel)
sel = c; sel = c;
else if(sel != c) { else if(sel != c) {
if(maximized)
togglemax(NULL);
old = sel; old = sel;
sel = c; sel = c;
if(old) { if(old) {
@ -208,6 +206,10 @@ manage(Window w, XWindowAttributes *wa) {
c->w = c->tw = wa->width; c->w = c->tw = wa->width;
c->h = wa->height; c->h = wa->height;
c->th = bh; c->th = bh;
c->rx = sx;
c->ry = bh;
c->rw = sw;
c->rh = sh - bh;
c->border = 0; c->border = 0;
updatesize(c); updatesize(c);
@ -369,41 +371,6 @@ updatetitle(Client *c) {
resizetitle(c); resizetitle(c);
} }
void
togglemax(Arg *arg) {
int ox, oy, ow, oh;
Client *c;
XEvent ev;
if(!sel)
return;
if((maximized = !maximized)) {
ox = sel->x;
oy = sel->y;
ow = sel->w;
oh = sel->h;
sel->x = sx;
sel->y = sy + bh;
sel->w = sw - 2;
sel->h = sh - 2 - bh;
restack();
for(c = getnext(clients); c; c = getnext(c->next))
if(c != sel)
ban(c);
resize(sel, arrange == dofloat, TopLeft);
sel->x = ox;
sel->y = oy;
sel->w = ow;
sel->h = oh;
}
else
arrange(NULL);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void void
unmanage(Client *c) { unmanage(Client *c) {
Client *nc; Client *nc;

View File

@ -33,7 +33,6 @@ static Key key[] = { \
{ MODKEY, XK_j, focusnext, { 0 } }, \ { MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \ { MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_m, togglemax, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \ { MODKEY, XK_g, resizecol, { .i = 20 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \ { MODKEY, XK_s, resizecol, { .i = -20 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \

View File

@ -28,7 +28,6 @@ static Key key[] = { \
{ MODKEY, XK_Tab, focusnext, { 0 } }, \ { MODKEY, XK_Tab, focusnext, { 0 } }, \
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \ { MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \ { MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_m, togglemax, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \ { MODKEY, XK_g, resizecol, { .i = 20 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \ { MODKEY, XK_s, resizecol, { .i = -20 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \

4
dwm.h
View File

@ -78,6 +78,7 @@ struct Client {
int proto; int proto;
int x, y, w, h; int x, y, w, h;
int tx, ty, tw, th; /* title window geometry */ int tx, ty, tw, th; /* title window geometry */
int rx, ry, rw, rh; /* revert geometry */
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int grav; int grav;
long flags; long flags;
@ -99,7 +100,7 @@ extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern void (*arrange)(Arg *); /* arrange function, indicates mode */ extern void (*arrange)(Arg *); /* arrange function, indicates mode */
extern Atom wmatom[WMLast], netatom[NetLast]; extern Atom wmatom[WMLast], netatom[NetLast];
extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */ extern Bool running, issel, *seltag; /* seltag is array of Bool */
extern Client *clients, *sel, *stack; /* global cleint list and stack */ extern Client *clients, *sel, *stack; /* global cleint list and stack */
extern Cursor cursor[CurLast]; extern Cursor cursor[CurLast];
extern DC dc; /* global draw context */ extern DC dc; /* global draw context */
@ -117,7 +118,6 @@ extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/ extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
extern void updatesize(Client *c); /* update the size structs of c */ extern void updatesize(Client *c); /* update the size structs of c */
extern void updatetitle(Client *c); /* update the name of c */ extern void updatetitle(Client *c); /* update the name of c */
extern void togglemax(Arg *arg); /* (un)maximize c */
extern void unmanage(Client *c); /* destroy c */ extern void unmanage(Client *c); /* destroy c */
/* draw.c */ /* draw.c */

View File

@ -130,7 +130,7 @@ buttonpress(XEvent *e) {
} }
else if((c = getclient(ev->window))) { else if((c = getclient(ev->window))) {
focus(c); focus(c);
if(maximized || CLEANMASK(ev->state) != MODKEY) if(CLEANMASK(ev->state) != MODKEY)
return; return;
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) { if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
restack(c); restack(c);
@ -170,7 +170,7 @@ configurerequest(XEvent *e) {
XWindowChanges wc; XWindowChanges wc;
if((c = getclient(ev->window))) { if((c = getclient(ev->window))) {
if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) { if((c == sel) && !c->isfloat && (arrange != dofloat)) {
synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width); synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
XSync(dpy, False); XSync(dpy, False);
return; return;

1
main.c
View File

@ -24,7 +24,6 @@ unsigned int ntags, numlockmask;
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool running = True; Bool running = True;
Bool issel = True; Bool issel = True;
Bool maximized = False;
Client *clients = NULL; Client *clients = NULL;
Client *sel = NULL; Client *sel = NULL;
Client *stack = NULL; Client *stack = NULL;

23
view.c
View File

@ -61,8 +61,6 @@ void
dofloat(Arg *arg) { dofloat(Arg *arg) {
Client *c; Client *c;
maximized = False;
for(c = clients; c; c = c->next) { for(c = clients; c; c = c->next) {
if(isvisible(c)) { if(isvisible(c)) {
resize(c, True, TopLeft); resize(c, True, TopLeft);
@ -82,8 +80,6 @@ dotile(Arg *arg) {
int h, i, n, w; int h, i, n, w;
Client *c; Client *c;
maximized = False;
w = sw - mw; w = sw - mw;
for(n = 0, c = clients; c; c = c->next) for(n = 0, c = clients; c; c = c->next)
if(isvisible(c) && !c->isfloat) if(isvisible(c) && !c->isfloat)
@ -190,7 +186,7 @@ resizecol(Arg *arg) {
for(n = 0, c = clients; c; c = c->next) for(n = 0, c = clients; c; c = c->next)
if(isvisible(c) && !c->isfloat) if(isvisible(c) && !c->isfloat)
n++; n++;
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized) if(!sel || sel->isfloat || n < 2 || (arrange != dotile))
return; return;
if(sel == getnext(clients)) { if(sel == getnext(clients)) {
@ -273,13 +269,28 @@ viewall(Arg *arg) {
void void
zoom(Arg *arg) { zoom(Arg *arg) {
int tmp;
unsigned int n; unsigned int n;
Client *c; Client *c;
XEvent ev;
if(!sel)
return;
if(sel->isfloat || (arrange == dofloat)) {
tmp = sel->x; sel->x = sel->rx; sel->rx = tmp;
tmp = sel->y; sel->y = sel->ry; sel->ry = tmp;
tmp = sel->w; sel->w = sel->rw; sel->rw = tmp;
tmp = sel->h; sel->h = sel->rh; sel->rh = tmp;
resize(sel, True, TopLeft);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
return;
}
for(n = 0, c = clients; c; c = c->next) for(n = 0, c = clients; c; c = c->next)
if(isvisible(c) && !c->isfloat) if(isvisible(c) && !c->isfloat)
n++; n++;
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized) if(n < 2 || (arrange != dotile))
return; return;
if((c = sel) == nexttiled(clients)) if((c = sel) == nexttiled(clients))