Skip to content
  • Alain Knaff's avatar
    [x11] Send a valid timestamp in TakeFocus messages · e9c68f36
    Alain Knaff authored and David Edmundson's avatar David Edmundson committed
    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 (e73e331f) 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
    e9c68f36