http://bugs.winehq.org/show_bug.cgi?id=59653 Bug ID: 59653 Summary: winex11.drv: FocusOut sends WM_CANCELMODE during active mouse grab, breaking drag operations Product: Wine Version: 11.6 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winex11.drv Assignee: wine-bugs@list.winehq.org Reporter: lldmakhbfcrmqyluns@nesopf.com Distribution: --- When a Wine application performs a drag operation (which involves an active mouse capture via SetCapture), and the user switches focus with Alt+Tab, XWayland sends a FocusOut event to the Wine window. Currently, Wine's focus_out() handler in dlls/winex11.drv/event.c unconditionally sends a WM_CANCELMODE message to the window losing focus. This forces any well-behaved Win32 application to call ReleaseCapture() and abort the modal drag operation. This behavior is incorrect. On native Windows, an active mouse capture survives keyboard focus changes. WM_CANCELMODE should not be sent in this state. This issue is specific to the winex11.drv backend and is prominently observed on XWayland. The native winewayland.drv does not suffer from this issue, as it handles input grabs differently. The successful drag-and-drop in native Wayland mode (with the ole32 fix applied) further proves that this is an X11-specific event handling bug. Steps to Reproduce: Implement patch from bug #59652 to enable drag and drop. Run Wine under an XWayland session. Start two applications (e.g., a file manager and a text editor). In the source application, begin a drag operation by holding the left mouse button. While still holding the mouse button, press Alt+Tab to switch focus to the other application. Actual Results: The drag operation is silently cancelled. Expected Results: The drag operation should continue, allowing the user to complete the drop in the other window. Patch: The following patch modifies focus_out() to check for an active mouse grab (grab_hwnd) before sending WM_CANCELMODE. This aligns Wine's behavior with native Windows and fixes the bug. diff --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -2019,7 +2019,15 @@ set_focus( thread_data, NULL, NULL ); if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE)) - send_message( hwnd, WM_CANCELMODE, 0, 0 ); + { + if (x11drv_thread_data()->grab_hwnd) + { + TRACE("Skipping WM_CANCELMODE, mouse is grabbed by %p.\\n", x11drv_thread_data()->grab_hwnd); + } + else + send_message( hwnd, WM_CANCELMODE, 0, 0 ); + } if (X11DRV_GetKeyboardLayout(0) != get_thread_input_hkl(0)) X11DRV_ActivateKeyboardLayout( get_thread_input_hkl(0), 0 ); -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.