When using WM_TAKE_FOCUS, the foreground window will only receive the FocusOut message after we have called XSetInputFocus. As we are waiting for the cursor to be released, we have to tell it to release its grab so we can try to grab it ourselves.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winex11.drv/event.c | 2 ++ dlls/winex11.drv/window.c | 3 +++ dlls/winex11.drv/x11drv.h | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 426ac785082..a02f697a77d 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -617,6 +617,8 @@ static void set_focus( XEvent *event, HWND hwnd, Time time )
if (!try_grab_pointer( event->xany.display )) { + /* ask the foreground window to release its grab before trying to get ours */ + SendMessageW( GetForegroundWindow(), WM_X11DRV_RELEASE_CURSOR, 0, 0 ); XSendEvent( event->xany.display, event->xany.window, False, 0, event ); return; } diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 4e01eb201c9..c3db32c85cb 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2739,6 +2739,9 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) return 0; case WM_X11DRV_CLIP_CURSOR: return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp ); + case WM_X11DRV_RELEASE_CURSOR: + ungrab_clipping_window(); + return 0; default: FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp ); return 0; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9b70f53d382..a0c8cfda025 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -533,7 +533,8 @@ enum x11drv_window_messages WM_X11DRV_SET_WIN_REGION, WM_X11DRV_RESIZE_DESKTOP, WM_X11DRV_SET_CURSOR, - WM_X11DRV_CLIP_CURSOR + WM_X11DRV_CLIP_CURSOR, + WM_X11DRV_RELEASE_CURSOR };
/* _NET_WM_STATE properties that we keep track of */