summaryrefslogtreecommitdiff
path: root/patch/maximize.c
blob: c89dbda19d3472eab1ab7cab17bc37a2ce98999c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
void
maximize(int x, int y, int w, int h)
{
	XEvent ev;

	if (!selmon->sel || selmon->sel->isfixed)
		return;
	XRaiseWindow(dpy, selmon->sel->win);
	if (!selmon->sel->ismax) {
		if (!selmon->lt[selmon->sellt]->arrange || selmon->sel->isfloating)
			selmon->sel->wasfloating = True;
		else {
			togglefloating(NULL);
			selmon->sel->wasfloating = False;
		}
		selmon->sel->oldx = selmon->sel->x;
		selmon->sel->oldy = selmon->sel->y;
		selmon->sel->oldw = selmon->sel->w;
		selmon->sel->oldh = selmon->sel->h;
		resize(selmon->sel, x, y, w, h, True);
		selmon->sel->ismax = True;
	}
	else {
		resize(selmon->sel, selmon->sel->oldx, selmon->sel->oldy, selmon->sel->oldw, selmon->sel->oldh, True);
		if (!selmon->sel->wasfloating)
			togglefloating(NULL);
		selmon->sel->ismax = False;
	}
	drawbar(selmon);
	while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}

#if SETBORDERPX_PATCH
void
togglemax(const Arg *arg)
{
	maximize(selmon->wx, selmon->wy, selmon->ww - 2 * selmon->borderpx, selmon->wh - 2 * selmon->borderpx);
}

void
toggleverticalmax(const Arg *arg)
{
	maximize(selmon->sel->x, selmon->wy, selmon->sel->w, selmon->wh - 2 * selmon->borderpx);
}

void
togglehorizontalmax(const Arg *arg)
{
	maximize(selmon->wx, selmon->sel->y, selmon->ww - 2 * selmon->borderpx, selmon->sel->h);
}
#else
void
togglemax(const Arg *arg)
{
	maximize(selmon->wx, selmon->wy, selmon->ww - 2 * borderpx, selmon->wh - 2 * borderpx);
}

void
toggleverticalmax(const Arg *arg)
{
	maximize(selmon->sel->x, selmon->wy, selmon->sel->w, selmon->wh - 2 * borderpx);
}

void
togglehorizontalmax(const Arg *arg)
{
	maximize(selmon->wx, selmon->sel->y, selmon->ww - 2 * borderpx, selmon->sel->h);
}
#endif // SETBORDERPX_PATCH