From 52b29efcd72f71dee7b176083cfb011b5f7ee400 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Wed, 21 Feb 2024 17:59:50 +0000 Subject: [PATCH] RandR: avoid segfault with one screen When two monitors go to one monitor (undocking a laptop with one external display, for example), don't set the previous monitor if it's the same as the current monitor. Fixes #947 --- fvwm/events.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fvwm/events.c b/fvwm/events.c index b5d9eafe5..1e498a7d8 100644 --- a/fvwm/events.c +++ b/fvwm/events.c @@ -2295,6 +2295,12 @@ void HandleEnterNotify(const evh_args_t *ea) pfm = monitor_resolve_name(prev_focused_monitor); this_m = monitor_get_current(); + /* Don't toggle the previous monitor if there isn't one, or + * the two monitors are the same. + */ + if ((pfm == NULL) || (pfm == this_m)) + return; + /* Send MX_MONITOR_FOCUS event. */ toggle_prev_monitor_state(this_m, pfm, NULL);