resist screen physical edges as well as strut edges
This commit is contained in:
parent
c4fcfc07e1
commit
92c8e947c9
1 changed files with 80 additions and 44 deletions
122
openbox/resist.c
122
openbox/resist.c
|
@ -109,10 +109,11 @@ void resist_move_windows(ObClient *c, gint *x, gint *y)
|
||||||
|
|
||||||
void resist_move_monitors(ObClient *c, gint *x, gint *y)
|
void resist_move_monitors(ObClient *c, gint *x, gint *y)
|
||||||
{
|
{
|
||||||
Rect *area;
|
Rect *area, *parea;
|
||||||
guint i;
|
guint i;
|
||||||
gint l, t, r, b; /* requested edges */
|
gint l, t, r, b; /* requested edges */
|
||||||
gint al, at, ar, ab; /* screen area edges */
|
gint al, at, ar, ab; /* screen area edges */
|
||||||
|
gint pl, pt, pr, pb; /* physical screen area edges */
|
||||||
gint cl, ct, cr, cb; /* current edges */
|
gint cl, ct, cr, cb; /* current edges */
|
||||||
gint w, h; /* current size */
|
gint w, h; /* current size */
|
||||||
|
|
||||||
|
@ -132,23 +133,37 @@ void resist_move_monitors(ObClient *c, gint *x, gint *y)
|
||||||
if (config_resist_edge) {
|
if (config_resist_edge) {
|
||||||
for (i = 0; i < screen_num_monitors; ++i) {
|
for (i = 0; i < screen_num_monitors; ++i) {
|
||||||
area = screen_area_monitor(c->desktop, i);
|
area = screen_area_monitor(c->desktop, i);
|
||||||
|
parea = screen_physical_area_monitor(i);
|
||||||
|
|
||||||
if (!RECT_INTERSECTS_RECT(*area, c->frame->area))
|
if (!RECT_INTERSECTS_RECT(*parea, c->frame->area))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
al = RECT_LEFT(*area);
|
al = RECT_LEFT(*area);
|
||||||
at = RECT_TOP(*area);
|
at = RECT_TOP(*area);
|
||||||
ar = RECT_RIGHT(*area);
|
ar = RECT_RIGHT(*area);
|
||||||
ab = RECT_BOTTOM(*area);
|
ab = RECT_BOTTOM(*area);
|
||||||
|
pl = RECT_LEFT(*parea);
|
||||||
|
pt = RECT_TOP(*parea);
|
||||||
|
pr = RECT_RIGHT(*parea);
|
||||||
|
pb = RECT_BOTTOM(*parea);
|
||||||
|
|
||||||
if (cl >= al && l < al && l >= al - config_resist_edge)
|
if (cl >= al && l < al && l >= al - config_resist_edge)
|
||||||
*x = al;
|
*x = al;
|
||||||
else if (cr <= ar && r > ar && r <= ar + config_resist_edge)
|
else if (cr <= ar && r > ar && r <= ar + config_resist_edge)
|
||||||
*x = ar - w + 1;
|
*x = ar - w + 1;
|
||||||
|
else if (cl >= pl && l < pl && l >= pl - config_resist_edge)
|
||||||
|
*x = pl;
|
||||||
|
else if (cr <= pr && r > pr && r <= pr + config_resist_edge)
|
||||||
|
*x = pr - w + 1;
|
||||||
|
|
||||||
if (ct >= at && t < at && t >= at - config_resist_edge)
|
if (ct >= at && t < at && t >= at - config_resist_edge)
|
||||||
*y = at;
|
*y = at;
|
||||||
else if (cb <= ab && b > ab && b < ab + config_resist_edge)
|
else if (cb <= ab && b > ab && b < ab + config_resist_edge)
|
||||||
*y = ab - h + 1;
|
*y = ab - h + 1;
|
||||||
|
else if (ct >= pt && t < pt && t >= pt - config_resist_edge)
|
||||||
|
*y = pt;
|
||||||
|
else if (cb <= pb && b > pb && b < pb + config_resist_edge)
|
||||||
|
*y = pb - h + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,9 +258,11 @@ void resist_size_monitors(ObClient *c, gint *w, gint *h, ObCorner corn)
|
||||||
{
|
{
|
||||||
gint l, t, r, b; /* my left, top, right and bottom sides */
|
gint l, t, r, b; /* my left, top, right and bottom sides */
|
||||||
gint dlt, drb; /* my destination left/top and right/bottom sides */
|
gint dlt, drb; /* my destination left/top and right/bottom sides */
|
||||||
Rect *area;
|
Rect *area, *parea;
|
||||||
gint al, at, ar, ab; /* screen boundaries */
|
gint al, at, ar, ab; /* screen boundaries */
|
||||||
|
gint pl, pt, pr, pb; /* physical screen boundaries */
|
||||||
gint incw, inch;
|
gint incw, inch;
|
||||||
|
guint i;
|
||||||
|
|
||||||
l = RECT_LEFT(c->frame->area);
|
l = RECT_LEFT(c->frame->area);
|
||||||
r = RECT_RIGHT(c->frame->area);
|
r = RECT_RIGHT(c->frame->area);
|
||||||
|
@ -255,48 +272,67 @@ void resist_size_monitors(ObClient *c, gint *w, gint *h, ObCorner corn)
|
||||||
incw = c->size_inc.width;
|
incw = c->size_inc.width;
|
||||||
inch = c->size_inc.height;
|
inch = c->size_inc.height;
|
||||||
|
|
||||||
/* get the screen boundaries */
|
for (i = 0; i < screen_num_monitors; ++i) {
|
||||||
area = screen_area(c->desktop);
|
area = screen_area_monitor(c->desktop, i);
|
||||||
al = RECT_LEFT(*area);
|
parea = screen_physical_area_monitor(i);
|
||||||
at = RECT_TOP(*area);
|
|
||||||
ar = RECT_RIGHT(*area);
|
|
||||||
ab = RECT_BOTTOM(*area);
|
|
||||||
|
|
||||||
if (config_resist_edge) {
|
if (!RECT_INTERSECTS_RECT(*parea, c->frame->area))
|
||||||
/* horizontal snapping */
|
continue;
|
||||||
switch (corn) {
|
|
||||||
case OB_CORNER_TOPLEFT:
|
|
||||||
case OB_CORNER_BOTTOMLEFT:
|
|
||||||
dlt = l;
|
|
||||||
drb = r + *w - c->frame->area.width;
|
|
||||||
if (r <= ar && drb > ar && drb <= ar + config_resist_edge)
|
|
||||||
*w = ar - l + 1;
|
|
||||||
break;
|
|
||||||
case OB_CORNER_TOPRIGHT:
|
|
||||||
case OB_CORNER_BOTTOMRIGHT:
|
|
||||||
dlt = l - *w + c->frame->area.width;
|
|
||||||
drb = r;
|
|
||||||
if (l >= al && dlt < al && dlt >= al - config_resist_edge)
|
|
||||||
*w = r - al + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vertical snapping */
|
/* get the screen boundaries */
|
||||||
switch (corn) {
|
al = RECT_LEFT(*area);
|
||||||
case OB_CORNER_TOPLEFT:
|
at = RECT_TOP(*area);
|
||||||
case OB_CORNER_TOPRIGHT:
|
ar = RECT_RIGHT(*area);
|
||||||
dlt = t;
|
ab = RECT_BOTTOM(*area);
|
||||||
drb = b + *h - c->frame->area.height;
|
pl = RECT_LEFT(*parea);
|
||||||
if (b <= ab && drb > ab && drb <= ab + config_resist_edge)
|
pt = RECT_TOP(*parea);
|
||||||
*h = ab - t + 1;
|
pr = RECT_RIGHT(*parea);
|
||||||
break;
|
pb = RECT_BOTTOM(*parea);
|
||||||
case OB_CORNER_BOTTOMLEFT:
|
|
||||||
case OB_CORNER_BOTTOMRIGHT:
|
if (config_resist_edge) {
|
||||||
dlt = t - *h + c->frame->area.height;
|
/* horizontal snapping */
|
||||||
drb = b;
|
switch (corn) {
|
||||||
if (t >= at && dlt < at && dlt >= at - config_resist_edge)
|
case OB_CORNER_TOPLEFT:
|
||||||
*h = b - at + 1;
|
case OB_CORNER_BOTTOMLEFT:
|
||||||
break;
|
dlt = l;
|
||||||
|
drb = r + *w - c->frame->area.width;
|
||||||
|
if (r <= ar && drb > ar && drb <= ar + config_resist_edge)
|
||||||
|
*w = ar - l + 1;
|
||||||
|
else if (r <= pr && drb > pr && drb <= pr + config_resist_edge)
|
||||||
|
*w = pr - l + 1;
|
||||||
|
break;
|
||||||
|
case OB_CORNER_TOPRIGHT:
|
||||||
|
case OB_CORNER_BOTTOMRIGHT:
|
||||||
|
dlt = l - *w + c->frame->area.width;
|
||||||
|
drb = r;
|
||||||
|
if (l >= al && dlt < al && dlt >= al - config_resist_edge)
|
||||||
|
*w = r - al + 1;
|
||||||
|
else if (l >= pl && dlt < pl && dlt >= pl - config_resist_edge)
|
||||||
|
*w = r - pl + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vertical snapping */
|
||||||
|
switch (corn) {
|
||||||
|
case OB_CORNER_TOPLEFT:
|
||||||
|
case OB_CORNER_TOPRIGHT:
|
||||||
|
dlt = t;
|
||||||
|
drb = b + *h - c->frame->area.height;
|
||||||
|
if (b <= ab && drb > ab && drb <= ab + config_resist_edge)
|
||||||
|
*h = ab - t + 1;
|
||||||
|
else if (b <= pb && drb > pb && drb <= pb + config_resist_edge)
|
||||||
|
*h = pb - t + 1;
|
||||||
|
break;
|
||||||
|
case OB_CORNER_BOTTOMLEFT:
|
||||||
|
case OB_CORNER_BOTTOMRIGHT:
|
||||||
|
dlt = t - *h + c->frame->area.height;
|
||||||
|
drb = b;
|
||||||
|
if (t >= at && dlt < at && dlt >= at - config_resist_edge)
|
||||||
|
*h = b - at + 1;
|
||||||
|
else if (t >= pt && dlt < pt && dlt >= pt - config_resist_edge)
|
||||||
|
*h = b - pt + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue