let you resize aspect ratio windows in north and south directions, and make them resist properly when resizing
This commit is contained in:
parent
019e803559
commit
f0e82075a1
2 changed files with 68 additions and 13 deletions
|
@ -374,12 +374,47 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
|
||||||
ObDirection dir)
|
ObDirection dir)
|
||||||
{
|
{
|
||||||
gint resist, x = 0, y = 0, lw, lh, ow, oh, nw, nh;
|
gint resist, x = 0, y = 0, lw, lh, ow, oh, nw, nh;
|
||||||
|
gint trydw, trydh;
|
||||||
|
|
||||||
ow = cur_w;
|
ow = cur_w;
|
||||||
oh = cur_h;
|
oh = cur_h;
|
||||||
nw = ow + *dw;
|
nw = ow + *dw;
|
||||||
nh = oh + *dh;
|
nh = oh + *dh;
|
||||||
|
|
||||||
|
if (moveresize_client->max_ratio || moveresize_client->min_ratio) {
|
||||||
|
switch (dir) {
|
||||||
|
case OB_DIRECTION_NORTH:
|
||||||
|
case OB_DIRECTION_SOUTH:
|
||||||
|
/* resize the width based on the height */
|
||||||
|
if (moveresize_client->min_ratio) {
|
||||||
|
if (nh * moveresize_client->min_ratio > nw)
|
||||||
|
nw = (gint)(nh * moveresize_client->min_ratio);
|
||||||
|
}
|
||||||
|
if (moveresize_client->max_ratio) {
|
||||||
|
if (nh * moveresize_client->max_ratio < nw)
|
||||||
|
nw = (gint)(nh * moveresize_client->max_ratio);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* resize the height based on the width */
|
||||||
|
if (moveresize_client->min_ratio) {
|
||||||
|
if (nh * moveresize_client->min_ratio > nw)
|
||||||
|
nh = (gint)(nw / moveresize_client->min_ratio);
|
||||||
|
}
|
||||||
|
if (moveresize_client->max_ratio) {
|
||||||
|
if (nh * moveresize_client->max_ratio < nw)
|
||||||
|
nh = (gint)(nw / moveresize_client->max_ratio);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* see its actual size (apply aspect ratios) */
|
||||||
|
client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
|
||||||
|
trydw = nw - ow;
|
||||||
|
trydh = nh - oh;
|
||||||
|
g_print("trydw %d trydh %d\n", trydw, trydh);
|
||||||
|
|
||||||
/* resist_size_* needs the frame size */
|
/* resist_size_* needs the frame size */
|
||||||
nw += moveresize_client->frame->size.left +
|
nw += moveresize_client->frame->size.left +
|
||||||
moveresize_client->frame->size.right;
|
moveresize_client->frame->size.right;
|
||||||
|
@ -400,7 +435,31 @@ static void calc_resize(gboolean keyboard, gint keydist, gint *dw, gint *dh,
|
||||||
*dw = nw - ow;
|
*dw = nw - ow;
|
||||||
*dh = nh - oh;
|
*dh = nh - oh;
|
||||||
|
|
||||||
/* make sure it's a valid size */
|
/* take aspect ratios into account for resistance */
|
||||||
|
if (*dh != trydh) { /* got resisted */
|
||||||
|
/* resize the width based on the height */
|
||||||
|
if (moveresize_client->min_ratio) {
|
||||||
|
if (nh * moveresize_client->min_ratio > nw)
|
||||||
|
nw = (gint)(nh * moveresize_client->min_ratio);
|
||||||
|
}
|
||||||
|
if (moveresize_client->max_ratio) {
|
||||||
|
if (nh * moveresize_client->max_ratio < nw)
|
||||||
|
nw = (gint)(nh * moveresize_client->max_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*dw != trydw) { /* got resisted */
|
||||||
|
/* resize the height based on the width */
|
||||||
|
if (moveresize_client->min_ratio) {
|
||||||
|
if (nh * moveresize_client->min_ratio > nw)
|
||||||
|
nh = (gint)(nw / moveresize_client->min_ratio);
|
||||||
|
}
|
||||||
|
if (moveresize_client->max_ratio) {
|
||||||
|
if (nh * moveresize_client->max_ratio < nw)
|
||||||
|
nh = (gint)(nw / moveresize_client->max_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make sure it's all valid */
|
||||||
client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
|
client_try_configure(moveresize_client, &x, &y, &nw, &nh, &lw, &lh, TRUE);
|
||||||
|
|
||||||
*dw = nw - ow;
|
*dw = nw - ow;
|
||||||
|
|
|
@ -234,6 +234,8 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
case OB_DIRECTION_EAST:
|
case OB_DIRECTION_EAST:
|
||||||
case OB_DIRECTION_NORTHEAST:
|
case OB_DIRECTION_NORTHEAST:
|
||||||
case OB_DIRECTION_SOUTHEAST:
|
case OB_DIRECTION_SOUTHEAST:
|
||||||
|
case OB_DIRECTION_NORTH:
|
||||||
|
case OB_DIRECTION_SOUTH:
|
||||||
dlt = l;
|
dlt = l;
|
||||||
drb = r + *w - c->frame->area.width;
|
drb = r + *w - c->frame->area.width;
|
||||||
if (r < tl && drb >= tl &&
|
if (r < tl && drb >= tl &&
|
||||||
|
@ -249,9 +251,6 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
dlt > tr - resist)
|
dlt > tr - resist)
|
||||||
*w = r - tr, snapx = target;
|
*w = r - tr, snapx = target;
|
||||||
break;
|
break;
|
||||||
case OB_DIRECTION_NORTH:
|
|
||||||
case OB_DIRECTION_SOUTH:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,6 +262,8 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
case OB_DIRECTION_SOUTH:
|
case OB_DIRECTION_SOUTH:
|
||||||
case OB_DIRECTION_SOUTHWEST:
|
case OB_DIRECTION_SOUTHWEST:
|
||||||
case OB_DIRECTION_SOUTHEAST:
|
case OB_DIRECTION_SOUTHEAST:
|
||||||
|
case OB_DIRECTION_EAST:
|
||||||
|
case OB_DIRECTION_WEST:
|
||||||
dlt = t;
|
dlt = t;
|
||||||
drb = b + *h - c->frame->area.height;
|
drb = b + *h - c->frame->area.height;
|
||||||
if (b < tt && drb >= tt &&
|
if (b < tt && drb >= tt &&
|
||||||
|
@ -278,9 +279,6 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
dlt > tb - resist)
|
dlt > tb - resist)
|
||||||
*h = b - tb, snapy = target;
|
*h = b - tb, snapy = target;
|
||||||
break;
|
break;
|
||||||
case OB_DIRECTION_EAST:
|
|
||||||
case OB_DIRECTION_WEST:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,6 +338,8 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
case OB_DIRECTION_EAST:
|
case OB_DIRECTION_EAST:
|
||||||
case OB_DIRECTION_NORTHEAST:
|
case OB_DIRECTION_NORTHEAST:
|
||||||
case OB_DIRECTION_SOUTHEAST:
|
case OB_DIRECTION_SOUTHEAST:
|
||||||
|
case OB_DIRECTION_NORTH:
|
||||||
|
case OB_DIRECTION_SOUTH:
|
||||||
dlt = l;
|
dlt = l;
|
||||||
drb = r + *w - c->frame->area.width;
|
drb = r + *w - c->frame->area.width;
|
||||||
if (r <= ar && drb > ar && drb <= ar + resist)
|
if (r <= ar && drb > ar && drb <= ar + resist)
|
||||||
|
@ -357,9 +357,6 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
else if (l >= pl && dlt < pl && dlt >= pl - resist)
|
else if (l >= pl && dlt < pl && dlt >= pl - resist)
|
||||||
*w = r - pl + 1;
|
*w = r - pl + 1;
|
||||||
break;
|
break;
|
||||||
case OB_DIRECTION_NORTH:
|
|
||||||
case OB_DIRECTION_SOUTH:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vertical snapping */
|
/* vertical snapping */
|
||||||
|
@ -367,6 +364,8 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
case OB_DIRECTION_SOUTH:
|
case OB_DIRECTION_SOUTH:
|
||||||
case OB_DIRECTION_SOUTHWEST:
|
case OB_DIRECTION_SOUTHWEST:
|
||||||
case OB_DIRECTION_SOUTHEAST:
|
case OB_DIRECTION_SOUTHEAST:
|
||||||
|
case OB_DIRECTION_WEST:
|
||||||
|
case OB_DIRECTION_EAST:
|
||||||
dlt = t;
|
dlt = t;
|
||||||
drb = b + *h - c->frame->area.height;
|
drb = b + *h - c->frame->area.height;
|
||||||
if (b <= ab && drb > ab && drb <= ab + resist)
|
if (b <= ab && drb > ab && drb <= ab + resist)
|
||||||
|
@ -384,9 +383,6 @@ void resist_size_monitors(ObClient *c, gint resist, gint *w, gint *h,
|
||||||
else if (t >= pt && dlt < pt && dlt >= pt - resist)
|
else if (t >= pt && dlt < pt && dlt >= pt - resist)
|
||||||
*h = b - pt + 1;
|
*h = b - pt + 1;
|
||||||
break;
|
break;
|
||||||
case OB_DIRECTION_WEST:
|
|
||||||
case OB_DIRECTION_EAST:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(area);
|
g_free(area);
|
||||||
|
|
Loading…
Reference in a new issue