implemented the maximization as I described on the mailinglist, this feels better to me. d800ec05
arg@mmvi · 2006-09-22 07:37 7 file(s) · +25 −50
client.c +4 −37
89 89
	if(!sel)
90 90
		sel = c;
91 91
	else if(sel != c) {
92 -
		if(maximized)
93 -
			togglemax(NULL);
94 92
		old = sel;
95 93
		sel = c;
96 94
		if(old) {
208 206
	c->w = c->tw = wa->width;
209 207
	c->h = wa->height;
210 208
	c->th = bh;
209 +
	c->rx = sx;
210 +
	c->ry = bh;
211 +
	c->rw = sw;
212 +
	c->rh = sh - bh;
211 213
212 214
	c->border = 0;
213 215
	updatesize(c);
367 369
	}
368 370
	XFree(name.value);
369 371
	resizetitle(c);
370 -
}
371 -
372 -
void
373 -
togglemax(Arg *arg) {
374 -
	int ox, oy, ow, oh;
375 -
	Client *c;
376 -
	XEvent ev;
377 -
378 -
	if(!sel)
379 -
		return;
380 -
381 -
	if((maximized = !maximized)) {
382 -
		ox = sel->x;
383 -
		oy = sel->y;
384 -
		ow = sel->w;
385 -
		oh = sel->h;
386 -
		sel->x = sx;
387 -
		sel->y = sy + bh;
388 -
		sel->w = sw - 2;
389 -
		sel->h = sh - 2 - bh;
390 -
391 -
		restack();
392 -
		for(c = getnext(clients); c; c = getnext(c->next))
393 -
			if(c != sel)
394 -
				ban(c);
395 -
		resize(sel, arrange == dofloat, TopLeft);
396 -
397 -
		sel->x = ox;
398 -
		sel->y = oy;
399 -
		sel->w = ow;
400 -
		sel->h = oh;
401 -
	}
402 -
	else
403 -
		arrange(NULL);
404 -
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
405 372
}
406 373
407 374
void
config.arg.h +0 −1
33 33
	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
34 34
	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
35 35
	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
36 -
	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
37 36
	{ MODKEY,			XK_g,		resizecol,	{ .i = 20 } }, \
38 37
	{ MODKEY,			XK_s,		resizecol,	{ .i = -20 } }, \
39 38
	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
config.default.h +0 −1
28 28
	{ MODKEY,			XK_Tab,		focusnext,	{ 0 } }, \
29 29
	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	{ 0 } }, \
30 30
	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
31 -
	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
32 31
	{ MODKEY,			XK_g,		resizecol,	{ .i = 20 } }, \
33 32
	{ MODKEY,			XK_s,		resizecol,	{ .i = -20 } }, \
34 33
	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
dwm.h +2 −2
78 78
	int proto;
79 79
	int x, y, w, h;
80 80
	int tx, ty, tw, th; /* title window geometry */
81 +
	int rx, ry, rw, rh; /* revert geometry */
81 82
	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
82 83
	int grav;
83 84
	long flags; 
99 100
extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
100 101
extern void (*arrange)(Arg *);			/* arrange function, indicates mode  */
101 102
extern Atom wmatom[WMLast], netatom[NetLast];
102 -
extern Bool running, issel, maximized, *seltag;	/* seltag is array of Bool */
103 +
extern Bool running, issel, *seltag;		/* seltag is array of Bool */
103 104
extern Client *clients, *sel, *stack;		/* global cleint list and stack */
104 105
extern Cursor cursor[CurLast];
105 106
extern DC dc;					/* global draw context */
117 118
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
118 119
extern void updatesize(Client *c);			/* update the size structs of c */
119 120
extern void updatetitle(Client *c);		/* update the name of c */
120 -
extern void togglemax(Arg *arg);		/* (un)maximize c */
121 121
extern void unmanage(Client *c);		/* destroy c */
122 122
123 123
/* draw.c */
event.c +2 −2
130 130
	}
131 131
	else if((c = getclient(ev->window))) {
132 132
		focus(c);
133 -
		if(maximized || CLEANMASK(ev->state) != MODKEY)
133 +
		if(CLEANMASK(ev->state) != MODKEY)
134 134
			return;
135 135
		if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
136 136
			restack(c);
170 170
	XWindowChanges wc;
171 171
172 172
	if((c = getclient(ev->window))) {
173 -
		if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) {
173 +
		if((c == sel) && !c->isfloat && (arrange != dofloat)) {
174 174
			synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
175 175
			XSync(dpy, False);
176 176
			return;
main.c +0 −1
24 24
Atom wmatom[WMLast], netatom[NetLast];
25 25
Bool running = True;
26 26
Bool issel = True;
27 -
Bool maximized = False;
28 27
Client *clients = NULL;
29 28
Client *sel = NULL;
30 29
Client *stack = NULL;
view.c +17 −6
61 61
dofloat(Arg *arg) {
62 62
	Client *c;
63 63
64 -
	maximized = False;
65 -
66 64
	for(c = clients; c; c = c->next) {
67 65
		if(isvisible(c)) {
68 66
			resize(c, True, TopLeft);
81 79
dotile(Arg *arg) {
82 80
	int h, i, n, w;
83 81
	Client *c;
84 -
85 -
	maximized = False;
86 82
87 83
	w = sw - mw;
88 84
	for(n = 0, c = clients; c; c = c->next)
190 186
	for(n = 0, c = clients; c; c = c->next)
191 187
		if(isvisible(c) && !c->isfloat)
192 188
			n++;
193 -
	if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
189 +
	if(!sel || sel->isfloat || n < 2 || (arrange != dotile))
194 190
		return;
195 191
196 192
	if(sel == getnext(clients)) {
273 269
274 270
void
275 271
zoom(Arg *arg) {
272 +
	int tmp;
276 273
	unsigned int n;
277 274
	Client *c;
275 +
	XEvent ev;
276 +
277 +
	if(!sel)
278 +
		return;
279 +
280 +
	if(sel->isfloat || (arrange == dofloat)) {
281 +
		tmp = sel->x; sel->x = sel->rx; sel->rx = tmp;
282 +
		tmp = sel->y; sel->y = sel->ry; sel->ry = tmp;
283 +
		tmp = sel->w; sel->w = sel->rw; sel->rw = tmp;
284 +
		tmp = sel->h; sel->h = sel->rh; sel->rh = tmp;
285 +
		resize(sel, True, TopLeft);
286 +
		while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
287 +
		return;
288 +
	}
278 289
279 290
	for(n = 0, c = clients; c; c = c->next)
280 291
		if(isvisible(c) && !c->isfloat)
281 292
			n++;
282 -
	if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
293 +
	if(n < 2 || (arrange != dotile))
283 294
		return;
284 295
285 296
	if((c = sel) == nexttiled(clients))