mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
re-work client_placecalc()
- make sure new clients sit inside the current screen - respect 'gap' placement on new clients ok oga@
This commit is contained in:
parent
9037043088
commit
4377b5ac3f
72
client.c
72
client.c
@ -656,64 +656,48 @@ void
|
|||||||
client_placecalc(struct client_ctx *cc)
|
client_placecalc(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
int yslack, xslack;
|
int yslack, xslack, xmouse, ymouse;
|
||||||
int x, y, height, width, mousex, mousey;
|
|
||||||
|
|
||||||
y = cc->geom.y;
|
|
||||||
x = cc->geom.x;
|
|
||||||
|
|
||||||
height = cc->geom.height;
|
|
||||||
width = cc->geom.width;
|
|
||||||
|
|
||||||
yslack = sc->ymax - cc->geom.height - cc->bwidth;
|
yslack = sc->ymax - cc->geom.height - cc->bwidth;
|
||||||
xslack = sc->xmax - cc->geom.width - cc->bwidth;
|
xslack = sc->xmax - cc->geom.width - cc->bwidth;
|
||||||
|
|
||||||
xu_ptr_getpos(sc->rootwin, &mousex, &mousey);
|
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
|
||||||
|
|
||||||
mousex = MAX(mousex, cc->bwidth) - cc->geom.width/2;
|
xmouse = MAX(xmouse, cc->bwidth) - cc->geom.width/2;
|
||||||
mousey = MAX(mousey, cc->bwidth) - cc->geom.height/2;
|
ymouse = MAX(ymouse, cc->bwidth) - cc->geom.height/2;
|
||||||
|
|
||||||
mousex = MAX(mousex, (int)cc->bwidth);
|
xmouse = MAX(xmouse, (int)cc->bwidth);
|
||||||
mousey = MAX(mousey, (int)cc->bwidth);
|
ymouse = MAX(ymouse, (int)cc->bwidth);
|
||||||
|
|
||||||
if (cc->size->flags & USPosition) {
|
if (cc->size->flags & USPosition) {
|
||||||
if (cc->size->x > 0)
|
if (cc->size->x >= 0)
|
||||||
x = cc->size->x;
|
cc->geom.x = MAX(MIN(cc->size->x, xslack), cc->bwidth);
|
||||||
if (x < cc->bwidth)
|
else
|
||||||
x = cc->bwidth;
|
cc->geom.x = cc->bwidth;
|
||||||
else if (x > xslack)
|
if (cc->size->y >= 0)
|
||||||
x = xslack;
|
cc->geom.y = MAX(MIN(cc->size->y, yslack), cc->bwidth);
|
||||||
if (cc->size->y > 0)
|
else
|
||||||
y = cc->size->y;
|
cc->geom.y = cc->bwidth;
|
||||||
if (y < cc->bwidth)
|
|
||||||
y = cc->bwidth;
|
|
||||||
else if (y > yslack)
|
|
||||||
y = yslack;
|
|
||||||
} else {
|
} else {
|
||||||
if (yslack < 0) {
|
if (xslack >= 0) {
|
||||||
y = cc->bwidth;
|
cc->geom.x = MAX(MIN(xmouse, xslack),
|
||||||
height = sc->ymax;
|
Conf.gap_left + cc->bwidth);
|
||||||
|
if (cc->geom.x > (xslack - Conf.gap_right))
|
||||||
|
cc->geom.x -= Conf.gap_right;
|
||||||
} else {
|
} else {
|
||||||
if (y == 0 || y > yslack)
|
cc->geom.x = cc->bwidth + Conf.gap_left;
|
||||||
y = MIN(mousey, yslack);
|
cc->geom.width = sc->xmax - cc->bwidth - Conf.gap_left;
|
||||||
height = cc->geom.height;
|
|
||||||
}
|
}
|
||||||
|
if (yslack >= 0) {
|
||||||
if (xslack < 0) {
|
cc->geom.y = MAX(MIN(ymouse, yslack),
|
||||||
x = cc->bwidth;
|
Conf.gap_top + cc->bwidth);
|
||||||
width = sc->xmax;
|
if (cc->geom.y > (yslack - Conf.gap_bottom))
|
||||||
|
cc->geom.y -= Conf.gap_bottom;
|
||||||
} else {
|
} else {
|
||||||
if (x == 0 || x > xslack)
|
cc->geom.y = cc->bwidth + Conf.gap_top;
|
||||||
x = MIN(mousex, xslack);
|
cc->geom.height = sc->ymax - cc->bwidth - Conf.gap_top;
|
||||||
width = cc->geom.width;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc->geom.y = y;
|
|
||||||
cc->geom.x = x;
|
|
||||||
|
|
||||||
cc->geom.height = height;
|
|
||||||
cc->geom.width = width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user