Skip to content

Commit

Permalink
GotoDesk: avoid over-eager matching
Browse files Browse the repository at this point in the history
When looping round GotoDesk and associated commands (GotoDeskAndPage,
etc.), ensure the matching for which desk and monitor to apply the
request to, doesn't loop on the same value, essentially causing multiple
requests happen.

In the case of DesktopConfiguration shared/global, this would happen per
monitor when it shouldn't.

Fixes #655
  • Loading branch information
ThomasAdam committed Sep 17, 2022
1 parent ad9356b commit 679cbcf
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions fvwm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,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 +1708,46 @@ 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 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) {
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

0 comments on commit 679cbcf

Please sign in to comment.