Skip to content

Commit

Permalink
Use last event time when calling XSetInputFocus
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
rbernon authored and ThomasAdam committed Dec 9, 2024
1 parent efef84c commit 27fd3ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fvwm/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ 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;
}

void _focus_reset(void)
{
Scr.focus_in_requested_window = NULL;
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, fev_get_evtime());

return;
}
Expand Down

0 comments on commit 27fd3ca

Please sign in to comment.