• Rémi Bernon's avatar
    winex11.drv: Retry last ClipCursor when grab is released. · 92177b0b
    Rémi Bernon authored
    As we ignore these NotifyGrab / NotifyUngrab w.r.t focus decisions,
    some applications are unaware of mouse grabs being lost and sometimes
    cursor clipping is lost. We have to keep the last clip rectangle and
    restore it when grab is released.
    
    This has been squashed with the foreground window check from
    Zhiyi Zhang <zzhang@codeweavers.com> to fix an issue that happens when
    switching from a fullscreen window - because there's some additional
    focus events involved - but in general, if the window that is getting
    focus cannot be activated:
    
    When FocusIn/NotifyWhileGrabbed is received, SetForegroundWindow is not
    called if the window cannot be activated. When the FocusIn/NotifyUngrab
    event arrives for the same window, we have to check the foreground
    window before restoring cursor clipping rectangle.
    
    For reference, the event sequence when pressing Alt-Tab - for WMs that
    grab the keyboard - is the following:
    
    1. FocusOut/NotifyGrab, when WM grabs the keyboard.
    2. FocusOut/NotifyWhileGrabbed, while WM switches windows, this calls
       SetForegroundWindow(GetDesktopWindow()).
    
    The event sequence for normal windows ends here, but for fullscreen
    windows, there may be these additional events:
    
    3. FocusIn/NotifyWhileGrabbed, which may not change Wine foreground
       window if it cannot be activated.
    4. FocusIn/NotifyUnGrab, when WM releases the keyboard while switching
       windows, this is ignored but it should not retry to grab the cursor,
       because window is not foreground.
    5. FocusOut/NotifyNormal, when WM finishes switching the windows.
    Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com>
    Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com>
    Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
    92177b0b
x11drv.h 32.2 KB