• Vlad Zahorodnii's avatar
    Clear should_get_focus in Workspace::focusToNull() · e6c77a1d
    Vlad Zahorodnii authored
    On X11, there are four input models. With some input models, it's okay
    if the window manager calls XSetInputFocus(), with others, the wm has to
    ask the client to make a XSetInputFocus() request.
    
    If kwin wants a client to take input focus, kwin will add the client
    to the should_get_focus list, which contains all the windows that
    are about to get input focus. Clients are popped from the list upon
    receiving FOCUS_IN events.
    
    A client will be added to the should_get_focus list even if kwin thinks
    that the client already has input focus because communication between
    the wm and xorg is async, anything can happen with input focus in meanwhile.
    
    On the other hand, the wm may sometimes focus the null window if no
    window should contain the input focus. The issue is that the
    should_get_focus list is not cleaned up in that case, which can lead to
    Workspace::mostRecentlyActivatedClient() returning wrong client and
    possibly other async related issues.
    
    We don't have such madness on Wayland as the compositor is in charge of
    handling input focus.
    
    This change makes Workspace::focusToNull() clear the should_get_focus,
    which is reasonable. We need to deactivate "in-flight" focus requests.
    
    This also fixes the bug where fullscreen Wayland windows don't go above
    docks and panels due to Workspace::mostRecentlyActivatedClient() returning
    bad client.
    
    BUG: 439405
    BUG: 395919
    e6c77a1d