magentic and screen bound grow/shrink

This commit is contained in:
Michael Weber 2012-07-06 00:49:56 +02:00
parent 95484ae032
commit 9b6808dc5c

View File

@ -160,38 +160,48 @@ kbfunc_moveresize(struct client_ctx *cc, union arg *arg)
if (ox < 0) nx = 0; if (ox < 0) nx = 0;
else if (ox < (sw - ow - bw) / 2) nx = (sw - ow - bw) / 2; else if (ox < (sw - ow - bw) / 2) nx = (sw - ow - bw) / 2;
else nx = sw - ow - bw; else nx = sw - ow - bw;
} else if (flags & CWM_GROW) { } else if (flags & ( CWM_GROW | CWM_SHRINK)) {
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) { if (flags & CWM_GROW ) {
} else if (ow + bw < sw / 3) { if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
nw = sw / 3 - bw; } else if (ow + bw < sw / 3) {
nh = sh / 3 - bw; nw = sw / 3 - bw;
} else if (ow + bw < sw / 2) { nh = sh / 3 - bw;
nw = sw / 2 - bw; } else if (ow + bw < sw / 2) {
nh = sh / 2 - bw; nw = sw / 2 - bw;
} else if (ow + bw < sw * 2 / 3) { nh = sh / 2 - bw;
nw = sw * 2 / 3 - bw; } else if (ow + bw < sw * 2 / 3) {
nh = sh * 2 / 3 - bw; nw = sw * 2 / 3 - bw;
nh = sh * 2 / 3 - bw;
} else {
client_maximize(cc);
goto end;
}
} else { } else {
client_maximize(cc); if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
goto end; client_maximize(cc);
} goto end;
} else if (flags & CWM_SHRINK) { } else if (ow + bw > sw * 2 / 3) {
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) { nw = sw * 2 / 3 - bw;
client_maximize(cc); nh = sh * 2 / 3 - bw;
goto end; } else if (ow + bw> sw / 2) {
} else if (ow + bw > sw * 2 / 3) { nw = sw / 2 - bw;
nw = sw * 2 / 3 - bw; nh = sh / 2 - bw;
nh = sh * 2 / 3 - bw; } else if (ow + bw > sw / 3) {
} else if (ow + bw> sw / 2) { nw = sw / 3 - bw;
nw = sw / 2 - bw; nh = sh / 3 - bw;
nh = sh / 2 - bw; }
} else if (ow + bw > sw / 3) {
nw = sw / 3 - bw;
nh = sh / 3 - bw;
} }
nx += (ow - nw)/2;
ny += (oh - nh)/2;
if (abs(ox) < Conf.snapdist) nx = 0;
else if (abs(sw - bw - ox - ow) < Conf.snapdist) nx = sw - bw - nw;
if (abs(oy) < Conf.snapdist) ny = 0;
else if (abs(sh - bw - oy - oh) < Conf.snapdist) ny = sh - nh - bw;
if (nx < 0) nx = 0;
else if (nx + nw + bw > sw) nx = sw - nw - bw;
if (ny < 0) ny = 0;
else if (ny + nh + bw > sh) ny = sh - nh - bw;
} }
nx += (ow - nw)/2;
ny += (oh - nh)/2;
client_ptrsave(cc); client_ptrsave(cc);
client_resize(cc); client_resize(cc);
cc->ptr.x += (nw - ow)/2; cc->ptr.x += (nw - ow)/2;