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

GotoDesk: avoid over-eager matching #695

Merged
merged 3 commits into from
Sep 19, 2022
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
53 changes: 49 additions & 4 deletions fvwm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,11 @@ static void move_viewport_delta(
{
TAILQ_FOREACH(mloop, &monitor_q, entry)
{
if (is_tracking_shared) {
if ((!m->virtual_scr.is_swapping ||
!mloop->virtual_scr.is_swapping) && mloop != m)
continue;
}
BroadcastPacket(
M_NEW_PAGE, 8,
(long)mloop->virtual_scr.Vx,
Expand Down Expand Up @@ -1662,6 +1667,8 @@ void MoveViewport(struct monitor *m, int newx, int newy, Bool grab)
void goto_desk(int desk, struct monitor *m)
{
struct monitor *m2 = NULL;
bool has_run_globally = false;

/* RBW - the unmapping operations are now removed to their own
* functions so they can also be used by the new GoToDeskAndPage
* command. */
Expand Down Expand Up @@ -1706,24 +1713,54 @@ void goto_desk(int desk, struct monitor *m)
}

TAILQ_FOREACH(m2, &monitor_q, entry) {
/* In global mode, only do this once. */
if (monitor_mode == MONITOR_TRACKING_G &&
has_run_globally)
break;

if (is_tracking_shared && m == m2) {
BroadcastPacket(M_NEW_DESK, 2,
(long)m2->virtual_scr.CurrentDesk,
(long)m2->si->rr_output);

goto done;
}

/* If we're swapping a desktop between monitors for
* shared mode, only do this when the is_swapping flag
* is true, otherwise events would be raised for a
* new_desk for monitors/desks which have not changed.
*/
if (m != m2 && !m2->virtual_scr.is_swapping)
continue;
if (is_tracking_shared) {
if ((!m->virtual_scr.is_swapping ||
!m2->virtual_scr.is_swapping) && m2 != m)
continue;

BroadcastPacket(M_NEW_DESK, 2,
(long)m2->virtual_scr.CurrentDesk,
(long)m2->si->rr_output);

goto done;
}
if (m != m2) {
m2->Desktops = m->Desktops;
if (!is_tracking_shared) {
m2->virtual_scr.CurrentDesk =
m->virtual_scr.CurrentDesk;
}
}

BroadcastPacket(M_NEW_DESK, 2, (long)m2->virtual_scr.CurrentDesk,
BroadcastPacket(M_NEW_DESK, 2,
(long)m2->virtual_scr.CurrentDesk,
(long)m2->si->rr_output);

if (monitor_mode == MONITOR_TRACKING_G &&
!has_run_globally) {
has_run_globally = true;
goto done;
}
}
done:

/* FIXME: domivogt (22-Apr-2000): Fake a 'restack' for sticky
* window upon desk change. This is a workaround for a
* problem in FvwmPager: The pager has a separate 'root'
Expand Down Expand Up @@ -2594,6 +2631,13 @@ void CMD_GotoDeskAndPage(F_CMD_ARGS)
goto_desk(m->virtual_scr.CurrentDesk, m);
focus_grab_buttons_all();

/* If we're sharing desks between monitors, don't send further
* NEW_DESK packets, as we've already handled this in the call
* to goto_desk above.
*/
if (is_tracking_shared)
goto done;

BroadcastPacket(M_NEW_DESK, 2, (long)m->virtual_scr.CurrentDesk,
(long)m->si->rr_output);
/* FIXME: domivogt (22-Apr-2000): Fake a 'restack' for sticky
Expand All @@ -2612,6 +2656,7 @@ void CMD_GotoDeskAndPage(F_CMD_ARGS)
BroadcastPacket(M_NEW_DESK, 2, (long)m->virtual_scr.CurrentDesk,
(long)m->si->rr_output);
}
done:
BroadcastMonitorList(NULL);
EWMH_SetCurrentDesktop(m);

Expand Down