Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SnapAttraction snap to edges of all monitors. #521

Merged
merged 2 commits into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 60 additions & 117 deletions fvwm/move_resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,7 @@ static void DoSnapAttract(
int score_x;
int score_y;
int scr_w, scr_h;
int mon_w, mon_h, mon_x, mon_y;
struct monitor *m;

nxl = -99999;
Expand All @@ -1994,11 +1995,6 @@ static void DoSnapAttract(
}
}

m = fw->m;

if (m == NULL)
m = monitor_get_current();

scr_w = monitor_get_all_widths();
scr_h = monitor_get_all_heights();

Expand Down Expand Up @@ -2080,86 +2076,51 @@ static void DoSnapAttract(
continue;
}
/* snap horizontally */
if (
other.y + other.height > *py &&
other.y < *py + self.height)
if (other.y + other.height > *py &&
other.y < *py + self.height)
{
if (*px + self.width >= other.x &&
*px + self.width <
other.x + fw->snap_attraction.proximity)
{
update_pos(
&score_x, &nxl, *px,
other.x - self.width);
}
if (*px + self.width >=
other.x - fw->snap_attraction.proximity &&
*px + self.width < other.x)
{
update_pos(
&score_x, &nxl, *px,
other.x - self.width);
}
if (*px <= other.x + other.width &&
*px > other.x + other.width -
if (*px + self.width >= other.x -
fw->snap_attraction.proximity &&
*px + self.width <= other.x +
fw->snap_attraction.proximity)
{
update_pos(
&score_x, &nxl, *px,
other.x + other.width);
update_pos(&score_x, &nxl, *px,
other.x - self.width);
}
if (*px <= other.x + other.width +
fw->snap_attraction.proximity &&
*px > other.x + other.width)
*px >= other.x + other.width -
fw->snap_attraction.proximity)
{
update_pos(
&score_x, &nxl, *px,
update_pos(&score_x, &nxl, *px,
other.x + other.width);
}
}
/* snap vertically */
if (
other.x + other.width > *px &&
other.x < *px + self.width)
if (other.x + other.width > *px &&
other.x < *px + self.width)
{
if (*py + self.height >= other.y &&
*py + self.height < other.y +
if (*py + self.height >= other.y -
fw->snap_attraction.proximity &&
*py + self.height <= other.y +
fw->snap_attraction.proximity)
{
update_pos(
&score_y, &nyt, *py,
other.y - self.height);
}
if (*py + self.height >=
other.y - fw->snap_attraction.proximity &&
*py + self.height < other.y)
{
update_pos(
&score_y, &nyt, *py,
update_pos(&score_y, &nyt, *py,
other.y - self.height);
}
if (*py <=
other.y + other.height &&
*py > other.y + other.height -
fw->snap_attraction.proximity)
{
update_pos(
&score_y, &nyt, *py,
other.y + other.height);
}
if (*py <= other.y + other.height +
fw->snap_attraction.proximity &&
*py > other.y + other.height)
*py >= other.y + other.height -
fw->snap_attraction.proximity)
{
update_pos(
&score_y, &nyt, *py,
update_pos(&score_y, &nyt, *py,
other.y + other.height);
}
}
} /* for */
} /* snap to other windows */

/* snap to screen egdes */
/* snap to monitor edges */
if (fw->snap_attraction.proximity > 0 && (
( fw->snap_attraction.mode & SNAP_SCREEN && (
fw->snap_attraction.mode & SNAP_SAME ||
Expand All @@ -2173,68 +2134,50 @@ static void DoSnapAttract(
fw->snap_attraction.mode & SNAP_SCREEN_ICONS ) ||
fw->snap_attraction.mode & SNAP_SCREEN_ALL ))
{
/* vertically */
if (!(scr_w < (*px) ||
(*px + self.width) < 0))
/* Loop over each monitor */
TAILQ_FOREACH(m, &monitor_q, entry)
{
if (*py + self.height >=
scr_h &&
*py + self.height <
scr_h + fw->snap_attraction.proximity)
{
update_pos(
&score_y, &nyt, *py,
scr_h - self.height);
}
if (*py + self.height >=
scr_h - fw->snap_attraction.proximity &&
*py + self.height < scr_h)
{
update_pos(
&score_y, &nyt, *py,
scr_h - self.height);
}
if ((*py <= 0)&&(*py > - fw->snap_attraction.proximity))
{
update_pos(&score_y, &nyt, *py, 0);
}
if ((*py <= fw->snap_attraction.proximity)&&(*py > 0))
{
update_pos(&score_y, &nyt, *py, 0);
}
} /* vertically */
/* horizontally */
if (!(scr_h < (*py) ||
(*py + self.height) < 0))
{
if (*px + self.width >= scr_w &&
*px + self.width <
scr_w + fw->snap_attraction.proximity)
{
update_pos(
&score_x, &nxl, *px,
scr_w - self.width);
}
if (*px + self.width >=
scr_w - fw->snap_attraction.proximity &&
*px + self.width < scr_w)
{
update_pos(
&score_x, &nxl, *px,
scr_w - self.width);
}
if ((*px <= 0) &&
(*px > - fw->snap_attraction.proximity))
mon_x = m->si->x;
mon_y = m->si->y;
mon_w = m->si->w;
mon_h = m->si->h;

/* vertically */
if (!(*px + self.width < mon_x || *px > mon_x + mon_w))
{
update_pos(&score_x, &nxl, *px, 0);
if (*py + self.height >=
mon_h + mon_y - fw->snap_attraction.proximity &&
*py + self.height <=
mon_h + mon_y + fw->snap_attraction.proximity)
{
update_pos(&score_y, &nyt, *py,
mon_h + mon_y - self.height);
}
if (*py <= mon_y + fw->snap_attraction.proximity &&
*py > mon_y - fw->snap_attraction.proximity)
{
update_pos(&score_y, &nyt, *py, mon_y);
}
}
if ((*px <= fw->snap_attraction.proximity) &&
(*px > 0))
/* horizontally */
if (!(*py + self.height < mon_y || *py > mon_y + mon_h))
{
update_pos(&score_x, &nxl, *px, 0);
if (*px + self.width >=
mon_w + mon_x - fw->snap_attraction.proximity &&
*px + self.width <=
mon_w + mon_x + fw->snap_attraction.proximity)
{
update_pos(&score_x, &nxl, *px,
mon_w + mon_x - self.width);
}
if ((*px <= mon_x + fw->snap_attraction.proximity) &&
(*px >= mon_x - fw->snap_attraction.proximity))
{
update_pos(&score_x, &nxl, *px, mon_x);
}
}
} /* horizontally */
} /* snap to screen edges */
} /* monitor loop */
} /* snap to monitor edges */

if (nxl != -99999)
{
Expand Down