Skip to content

Commit

Permalink
FvwmEvent: flip prev_focused monitor
Browse files Browse the repository at this point in the history
When handling focus between screens (which is predicated on windows
receiving focus, rather than the root window), toggle the appropriate
monitors so that the previous focused monitor is referenced correctly.

While here, improve the matching of the previous monitor.

Fixes #604
  • Loading branch information
ThomasAdam committed Sep 19, 2022
1 parent 12ad8d9 commit bc3ab24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fvwm/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -2582,11 +2582,13 @@ void HandleFocusIn(const evh_args_t *ea)
pfm = monitor_resolve_name(prev_focused_monitor);

if (fw != NULL && fw->m != pfm) {
pfm->is_prev = true;
fw->m->is_prev = false;
BroadcastName(MX_MONITOR_FOCUS, -1, -1, -1,
fw->m->si->name /* Name of the monitor. */
);

/* Toggle the state of the previous monitor. */
pfm->is_prev = false;
fw->m->is_prev = true;
if (pfm->virtual_scr.CurrentDesk !=
fw->m->virtual_scr.CurrentDesk)
EWMH_SetCurrentDesktop(fw->m);
Expand Down
6 changes: 6 additions & 0 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ struct monitor *
monitor_get_prev(void)
{
struct monitor *m, *mret = NULL;
struct monitor *this = monitor_get_current();

TAILQ_FOREACH(m, &monitor_q, entry) {
if (m == this)
continue;
if (m->is_prev) {
mret = m;
break;
Expand Down Expand Up @@ -537,6 +540,7 @@ void FScreenInit(Display *dpy)
m->Desktops->next = NULL;
m->Desktops->desk = 0;
m->flags |= (MONITOR_NEW|MONITOR_ENABLED);
m->is_prev = false;
monitor_scan_edges(m);
}

Expand Down Expand Up @@ -572,6 +576,7 @@ monitor_dump_state(struct monitor *m)
"\tDisabled:\t%s\n"
"\tIs Primary:\t%s\n"
"\tIs Current:\t%s\n"
"\tIs Previous:\t%s\n"
"\tOutput:\t%d\n"
"\tCoords:\t{x: %d, y: %d, w: %d, h: %d}\n"
"\tVirtScr: {\n"
Expand All @@ -586,6 +591,7 @@ monitor_dump_state(struct monitor *m)
(m2->flags & MONITOR_DISABLED) ? "true" : "false",
(m2->flags & MONITOR_PRIMARY) ? "yes" : "no",
(mcur && m2 == mcur) ? "yes" : "no",
m2->is_prev ? "yes" : "no",
(int)m2->si->rr_output,
m2->si->x, m2->si->y, m2->si->w, m2->si->h,
m2->virtual_scr.VxMax, m2->virtual_scr.VyMax,
Expand Down

0 comments on commit bc3ab24

Please sign in to comment.