Diffusion KWin 2b8f4b21d1a7

[x11] Send a valid timestamp in TakeFocus messages

Authored by Alain Knaff <kde@kde.lka.org.lu> on May 22 2020, 12:56 PM.

Description

[x11] Send a valid timestamp in TakeFocus messages

Kwin sends out undated WM_TAKE_FOCUS client messages. Gtk based
applications such as Firefox react to these by handing focus to one of
their subwindows using XSetInputFocus(), and pass on the null time field
that they received in the client message to XSetInputFocus().

If for whatever reason the application (firefox) is slow to process the
event, it might issue that XSetInputFocus() message at a time when it
has already lost focus to the next application. This results in Firefox
stealing back the focus from the next application. Normally, such an
occurrence would not happen, as the server could tell by the time field
that the message is stale.

Until 2016 (e73e331f35b9da4bbb99c80c5c1eedd2ae99422b) kwin *used* to
send a valid timestamp, but this got deliberately broken to appease some
Java Applications which were "extremely picky" and would refuse focus.

This was based on the assumption that no other toolkit used the
timestamp from take focus events which is now proven to be false.

ICCCM document states:

Windows with the atom WM_TAKE_FOCUS in their WM_PROTOCOLS property may
receive a ClientMessage event from the window manager (as described in
section 4.2.8) with WM_TAKE_FOCUS in its data[0] field and a valid
timestamp (i.e. not CurrentTime ) in its data[1] field."

BUG: 421068