From 27fd3caea6a89444bfe4f19dd5a2233793c591c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 22 Mar 2023 14:24:56 +0100 Subject: [PATCH] Use last event time when calling XSetInputFocus This fixes a race condition when WM_TAKE_FOCUS message is sent to client windows, with the last event time as time parameter. The client might react to the WM_TAKE_FOCUS message with a XSetInputFocus call, and is expected to pass the message time as time parameter. As fvwm concurrently calls XSetInputFocus with CurrentTime, it causes a race condition and sometimes the X server gives focus to fvwm window, stealing the focus from the client window. --- fvwm/focus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fvwm/focus.c b/fvwm/focus.c index f7ff8650f..8f992100a 100644 --- a/fvwm/focus.c +++ b/fvwm/focus.c @@ -79,7 +79,7 @@ static FvwmWindow *ScreenFocus = NULL; void _focus_set(Window w, FvwmWindow *fw) { Scr.focus_in_requested_window = fw; - XSetInputFocus(dpy, w, RevertToParent, CurrentTime); + XSetInputFocus(dpy, w, RevertToParent, fev_get_evtime()); return; } @@ -87,7 +87,7 @@ void _focus_set(Window w, FvwmWindow *fw) void _focus_reset(void) { Scr.focus_in_requested_window = NULL; - XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, fev_get_evtime()); return; }