Skip to content
Closed
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
30 changes: 23 additions & 7 deletions libs/FScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ monitor_check_primary(void)
struct monitor *m;

m = RB_MIN(monitors, &monitor_q);
m->flags |= MONITOR_PRIMARY;
if (m != NULL)
m->flags |= MONITOR_PRIMARY;
}
}

Expand Down Expand Up @@ -562,9 +563,21 @@ scan_screens(Display *dpy)
}

rrm = XRRGetMonitors(dpy, root, true, &n);
if (n <= 0 && (!randr_initialised && monitor_get_count() == 0)) {
fvwm_debug(__func__, "get monitors failed\n");
exit(101);
if (n <= 0) {
if (!randr_initialised && monitor_get_count() == 0) {
fvwm_debug(__func__, "get monitors failed\n");
exit(101);
}
/* Transient empty topology (e.g. a monitor has been
* disabled but not yet re-enabled, as happens when a
* laptop lid is reopened). Retain the existing monitor
* set and wait for the next RandR event.
*/
fvwm_debug(__func__,
"no monitors reported; retaining current set\n");
if (rrm != NULL)
XRRFreeMonitors(rrm);
return;
}

/*
Expand Down Expand Up @@ -891,10 +904,13 @@ FindScreenOfXY(int x, int y)
}
}

/* Shouldn't happen. */
/* Shouldn't happen. If it does (e.g. all monitors transiently
* disabled), degrade gracefully rather than killing the WM.
*/
if (m_min == NULL) {
fvwm_debug(__func__, "Couldn't find any monitor");
exit(106);
fvwm_debug(__func__,
"Couldn't find any monitor; using global");
return (monitor_get_global());
}
return (m_min);
}
Expand Down
Loading