Skip to content

Commit

Permalink
Move shuffle, ensure window inside working area.
Browse files Browse the repository at this point in the history
  When move shuffle moves to a new monitor, ensure that the
  window is inside the working area of the new monitor. Currently
  only the direction the window moves is honored. This now checks
  the directions perpendicular to the movement direction as well.
  If a window is too big to fit, the top/left of the window will
  always be in the working area (so the window's bottom and/or left
  end could be outside of the working area).
  • Loading branch information
somiaj committed Nov 15, 2022
1 parent 024d379 commit 7b95f54
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions fvwm/move_resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ static void move_to_next_monitor(
{
position page;
struct monitor *m;
int x1, x2, y1, y2; /* Working area bounds */
int found_m = 0, check_vert = 0, check_hor = 0;

get_page_offset_check_visible(&page.x, &page.y, fw);
win_r->x -= page.x;
Expand All @@ -298,6 +300,8 @@ static void move_to_next_monitor(
win_r->x < m->si->x + m->si->w &&
win_r->x + win_r->width > m->si->x)
{
found_m = 1;
check_hor = 1;
win_r->y = m->si->y + m->si->h - win_r->height;
if (ewmh)
win_r->y -= m->ewmhc.BaseStrut.bottom;
Expand All @@ -306,6 +310,8 @@ static void move_to_next_monitor(
fw->m->si->w && win_r->y < m->si->y + m->si->h &&
win_r->y + win_r->height > m->si->y)
{
found_m = 1;
check_vert = 1;
win_r->x = m->si->x;
if (ewmh)
win_r->x += m->ewmhc.BaseStrut.left;
Expand All @@ -314,6 +320,8 @@ static void move_to_next_monitor(
fw->m->si->h && win_r->x < m->si->x + m->si->w &&
win_r->x + win_r->width > m->si->x)
{
found_m = 1;
check_hor = 1;
win_r->y = m->si->y;
if (ewmh)
win_r->y += m->ewmhc.BaseStrut.top;
Expand All @@ -322,10 +330,38 @@ static void move_to_next_monitor(
win_r->y < m->si->y + m->si->h &&
win_r->y + win_r->height > m->si->y)
{
found_m = 1;
check_vert = 1;
win_r->x = m->si->x + m->si->w - win_r->width;
if (ewmh)
win_r->x -= m->ewmhc.BaseStrut.right;
}
if (found_m) {
x1 = m->si->x;
y1 = m->si->y;
x2 = x1 + m->si->w;
y2 = y1 + m->si->h;
if (ewmh) {
x1 += m->ewmhc.BaseStrut.left;
y1 += m->ewmhc.BaseStrut.top;
x2 -= m->ewmhc.BaseStrut.right;
y2 -= m->ewmhc.BaseStrut.bottom;
}
break;
}
}
if (check_vert) {
if (win_r->y < y1) {
win_r->y = y1;
} else if (win_r->y + win_r->height > y2) {
win_r->y = y2 - win_r->height;
}
} else if (check_hor) {
if (win_r->x < x1) {
win_r->x = x1;
} else if (win_r->x + win_r->width > x2) {
win_r->x = x2 - win_r->width;
}
}
win_r->x += page.x;
win_r->y += page.y;
Expand Down

0 comments on commit 7b95f54

Please sign in to comment.