[PATCH 0/5] MR11245: winex11: Get rid of x11drv_thread_data()->grab_hwnd.
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/window.c | 5 +++++ dlls/winemac.drv/window.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 7c17b32787e..69fe3b24f33 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5264,6 +5264,8 @@ LRESULT destroy_window( HWND hwnd ) send_message( hwnd, WM_NCDESTROY, 0, 0 ); + if (hwnd == get_capture()) user_driver->pSetCapture( NULL, 0 ); + if (toplevel && toplevel != hwnd) update_window_state( toplevel ); /* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */ @@ -5403,6 +5405,7 @@ void destroy_thread_windows(void) struct window_surface *surface; struct destroy_entry *next; } *entry, *free_list = NULL; + HWND capture = get_capture(); struct list drawables = LIST_INIT(drawables); HANDLE handle = 0; WND *win; @@ -5452,6 +5455,8 @@ void destroy_thread_windows(void) free_list = entry->next; TRACE( "destroying %p\n", entry ); + if (entry->handle == capture) user_driver->pSetCapture( NULL, 0 ); + detach_client_surfaces( entry->handle ); user_driver->pDestroyWindow( entry->handle ); if (entry->current_drawable) opengl_drawable_release( entry->current_drawable ); diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 4ed488cd760..e3491f4abd0 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1279,7 +1279,6 @@ void macdrv_DestroyWindow(HWND hwnd) if (!(data = get_win_data(hwnd))) return; - if (hwnd == get_capture()) macdrv_SetCapture(0, 0); if (data->drag_event) NtSetEvent(data->drag_event, NULL); destroy_cocoa_window(data); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11245
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/driver.c | 2 +- dlls/win32u/input.c | 2 +- dlls/win32u/window.c | 6 +++--- dlls/wineandroid.drv/android.h | 2 +- dlls/wineandroid.drv/window.c | 2 +- dlls/winemac.drv/macdrv.h | 3 +-- dlls/winemac.drv/mouse.c | 7 +++---- dlls/winemac.drv/window.c | 2 +- dlls/winex11.drv/window.c | 10 ++++++---- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index cfe0650648b..27259fd8506 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -809,7 +809,7 @@ static BOOL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update ) hdc, rect.left - dx, rect.top - dy, SRCCOPY, 0, 0 ); } -static void nulldrv_SetCapture( HWND hwnd, UINT flags ) +static void nulldrv_SetCapture( HWND hwnd, UINT flags, HWND previous ) { } diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 048950345b3..ce7d0d4de58 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -1920,7 +1920,7 @@ BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) if (ret) { - user_driver->pSetCapture( hwnd, gui_flags ); + user_driver->pSetCapture( NtUserGetAncestor( hwnd, GA_ROOT ), gui_flags, NtUserGetAncestor( previous, GA_ROOT ) ); if (previous) NtUserNotifyWinEvent( EVENT_SYSTEM_CAPTUREEND, previous, OBJID_WINDOW, 0 ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 69fe3b24f33..f4dc335c5cf 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5264,7 +5264,7 @@ LRESULT destroy_window( HWND hwnd ) send_message( hwnd, WM_NCDESTROY, 0, 0 ); - if (hwnd == get_capture()) user_driver->pSetCapture( NULL, 0 ); + if (hwnd == get_capture()) user_driver->pSetCapture( NULL, 0, toplevel ); if (toplevel && toplevel != hwnd) update_window_state( toplevel ); @@ -5405,7 +5405,7 @@ void destroy_thread_windows(void) struct window_surface *surface; struct destroy_entry *next; } *entry, *free_list = NULL; - HWND capture = get_capture(); + HWND capture = get_capture(), toplevel = NtUserGetAncestor( capture, GA_ROOT ); struct list drawables = LIST_INIT(drawables); HANDLE handle = 0; WND *win; @@ -5455,7 +5455,7 @@ void destroy_thread_windows(void) free_list = entry->next; TRACE( "destroying %p\n", entry ); - if (entry->handle == capture) user_driver->pSetCapture( NULL, 0 ); + if (entry->handle == capture) user_driver->pSetCapture( NULL, 0, toplevel ); detach_client_surfaces( entry->handle ); user_driver->pDestroyWindow( entry->handle ); diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index c63e7b1fd79..1d3df21d10f 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -111,7 +111,7 @@ extern void ANDROID_DestroyWindow( HWND hwnd ); extern BOOL ANDROID_ProcessEvents( DWORD mask ); extern LRESULT ANDROID_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ); extern void ANDROID_SetParent( HWND hwnd, HWND parent, HWND old_parent ); -extern void ANDROID_SetCapture( HWND hwnd, UINT flags ); +extern void ANDROID_SetCapture( HWND hwnd, UINT flags, HWND previous ); extern UINT ANDROID_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp ); extern LRESULT ANDROID_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ); extern BOOL ANDROID_WindowPosChanging( HWND hwnd, UINT swp_flags, BOOL shaped, const struct window_rects *rects ); diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index db9294ee0d1..3cc971558ff 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -1110,7 +1110,7 @@ void ANDROID_SetParent( HWND hwnd, HWND parent, HWND old_parent ) /*********************************************************************** * ANDROID_SetCapture */ -void ANDROID_SetCapture( HWND hwnd, UINT flags ) +void ANDROID_SetCapture( HWND hwnd, UINT flags, HWND previous ) { if (!(flags & (GUI_INMOVESIZE | GUI_INMENUMODE))) return; ioctl_set_capture( hwnd ); diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 0aef8cdd60f..aeeadae122e 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -156,7 +156,7 @@ extern void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hin const struct window_rects *new_rects, struct window_surface *surface); extern void macdrv_DestroyCursorIcon(HCURSOR cursor); extern BOOL macdrv_GetCursorPos(LPPOINT pos); -extern void macdrv_SetCapture(HWND hwnd, UINT flags); +extern void macdrv_SetCapture(HWND hwnd, UINT flags, HWND previous); extern void macdrv_SetCursor(HWND hwnd, HCURSOR cursor); extern BOOL macdrv_SetCursorPos(INT x, INT y); extern BOOL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey); @@ -238,7 +238,6 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern void macdrv_mouse_moved(HWND hwnd, const macdrv_event *event); extern void macdrv_mouse_scroll(HWND hwnd, const macdrv_event *event); extern void macdrv_release_capture(HWND hwnd, const macdrv_event *event); -extern void macdrv_SetCapture(HWND hwnd, UINT flags); extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data); extern void macdrv_keyboard_changed(const macdrv_event *event); diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c index ee876d5355c..19674b2d099 100644 --- a/dlls/winemac.drv/mouse.c +++ b/dlls/winemac.drv/mouse.c @@ -702,13 +702,12 @@ BOOL macdrv_GetCursorPos(LPPOINT pos) /*********************************************************************** * SetCapture (MACDRV.@) */ - void macdrv_SetCapture(HWND hwnd, UINT flags) + void macdrv_SetCapture(HWND hwnd, UINT flags, HWND previous) { struct macdrv_thread_data *thread_data = macdrv_thread_data(); - HWND top = NtUserGetAncestor(hwnd, GA_ROOT); - macdrv_window cocoa_window = macdrv_get_cocoa_window(top, FALSE); + macdrv_window cocoa_window = macdrv_get_cocoa_window(hwnd, FALSE); - TRACE("hwnd %p top %p/%p flags 0x%08x\n", hwnd, top, cocoa_window, flags); + TRACE("hwnd %p/%p flags 0x%08x previous %p\n", hwnd, cocoa_window, flags, previous); if (!thread_data) return; diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index e3491f4abd0..61f14ad496b 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -825,7 +825,7 @@ static BOOL set_capture_window_for_move(HWND hwnd) if (ret) { - macdrv_SetCapture(hwnd, GUI_INMOVESIZE); + macdrv_SetCapture(NtUserGetAncestor(hwnd, GA_ROOT), GUI_INMOVESIZE, NtUserGetAncestor(previous, GA_ROOT)); if (previous && previous != hwnd) send_message(previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd); diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index c3d3312581d..e8129868e85 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -3108,16 +3108,18 @@ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update ) /*********************************************************************** * SetCapture (X11DRV.@) */ -void X11DRV_SetCapture( HWND hwnd, UINT flags ) +void X11DRV_SetCapture( HWND hwnd, UINT flags, HWND previous ) { struct x11drv_thread_data *thread_data = x11drv_thread_data(); struct x11drv_win_data *data; + TRACE( "hwnd %p, flags %#x, previous %p\n", hwnd, flags, previous ); + if (!(flags & (GUI_INMOVESIZE | GUI_INMENUMODE))) return; if (hwnd) { - if (!(data = get_win_data( NtUserGetAncestor( hwnd, GA_ROOT )))) return; + if (!(data = get_win_data( hwnd ))) return; if (data->whole_window) { XGrabPointer( data->display, data->whole_window, False, @@ -3128,9 +3130,9 @@ void X11DRV_SetCapture( HWND hwnd, UINT flags ) } release_win_data( data ); } - else /* release capture */ + else if (previous) /* release capture */ { - if (!(data = get_win_data( thread_data->grab_hwnd ))) return; + if (!(data = get_win_data( previous ))) return; XUngrabPointer( data->display, CurrentTime ); XFlush( data->display ); thread_data->grab_hwnd = NULL; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 56d6c814aad..bbe52108aa5 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -233,7 +233,7 @@ extern void X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect, const RECT *top_rect, DWORD flags ); extern void X11DRV_ReleaseDC( HWND hwnd, HDC hdc ); extern BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update ); -extern void X11DRV_SetCapture( HWND hwnd, UINT flags ); +extern void X11DRV_SetCapture( HWND hwnd, UINT flags, HWND previous ); extern void X11DRV_SetDesktopWindow( HWND hwnd ); extern void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index fa1f7232505..630e035a589 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -218,7 +218,7 @@ struct gdi_dc_funcs }; /* increment this when you change the DC function table */ -#define WINE_GDI_DRIVER_VERSION 109 +#define WINE_GDI_DRIVER_VERSION 110 #define GDI_PRIORITY_NULL_DRV 0 /* null driver */ #define GDI_PRIORITY_FONT_DRV 100 /* any font driver */ @@ -404,7 +404,7 @@ struct user_driver_funcs BOOL (*pProcessEvents)(DWORD); void (*pReleaseDC)(HWND,HDC); BOOL (*pScrollDC)(HDC,INT,INT,HRGN); - void (*pSetCapture)(HWND,UINT); + void (*pSetCapture)(HWND,UINT,HWND); void (*pSetDesktopWindow)(HWND); void (*pActivateWindow)(HWND,HWND); void (*pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11245
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winex11.drv/mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index f66ba639937..0ea08b3d50e 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -1604,7 +1604,7 @@ BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *xev ) input.mi.time = EVENT_x11_time_to_win32_time( event->time ); input.mi.dwExtraInfo = 0; - if (!hwnd && is_old_motion_event( event->serial )) + if (is_old_motion_event( event->serial )) { TRACE( "pos %d,%d old serial %lu, ignoring\n", event->x, event->y, event->serial ); return FALSE; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11245
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winex11.drv/mouse.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index 0ea08b3d50e..fd90219b9dc 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -535,24 +535,14 @@ static void map_event_coords( HWND hwnd, Window window, Window event_root, int x */ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPUT *input ) { - struct x11drv_win_data *data; - - input->type = INPUT_MOUSE; - - if (!hwnd) - { - struct x11drv_thread_data *thread_data = x11drv_thread_data(); - if (!thread_data->clipping_cursor || thread_data->clip_window != window) return; - NtUserSendHardwareInput( hwnd, 0, input, 0 ); - return; - } + struct x11drv_thread_data *thread_data = x11drv_thread_data(); - if (!(data = get_win_data( hwnd ))) return; - release_win_data( data ); + /* ignore clipping window input when not clipping or wrong clipping window */ + if (!hwnd && (!thread_data->clipping_cursor || thread_data->clip_window != window)) return; /* update the wine server Z-order */ - if (hwnd != x11drv_thread_data()->grab_hwnd && + if (hwnd && hwnd != x11drv_thread_data()->grab_hwnd && /* ignore event if a button is pressed, since the mouse is then grabbed too */ !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask))) { @@ -567,6 +557,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU SERVER_END_REQ; } + input->type = INPUT_MOUSE; NtUserSendHardwareInput( hwnd, 0, input, 0 ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11245
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/winex11.drv/mouse.c | 4 ++-- dlls/winex11.drv/window.c | 3 --- dlls/winex11.drv/x11drv.h | 8 +++++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c index fd90219b9dc..5a4d52d9f5c 100644 --- a/dlls/winex11.drv/mouse.c +++ b/dlls/winex11.drv/mouse.c @@ -542,7 +542,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU /* update the wine server Z-order */ - if (hwnd && hwnd != x11drv_thread_data()->grab_hwnd && + if (hwnd && hwnd != NtUserGetAncestor( get_capture_window(), GA_ROOT ) && /* ignore event if a button is pressed, since the mouse is then grabbed too */ !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask))) { @@ -1618,7 +1618,7 @@ BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *xev ) x11drv_thread_data()->keymapnotify_hwnd = hwnd; - if (hwnd == x11drv_thread_data()->grab_hwnd) return FALSE; + if (hwnd == NtUserGetAncestor( get_capture_window(), GA_ROOT )) return FALSE; /* simulate a mouse motion event */ input.mi.dx = event->x; diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index e8129868e85..3b964baadef 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -3110,7 +3110,6 @@ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update ) */ void X11DRV_SetCapture( HWND hwnd, UINT flags, HWND previous ) { - struct x11drv_thread_data *thread_data = x11drv_thread_data(); struct x11drv_win_data *data; TRACE( "hwnd %p, flags %#x, previous %p\n", hwnd, flags, previous ); @@ -3126,7 +3125,6 @@ void X11DRV_SetCapture( HWND hwnd, UINT flags, HWND previous ) PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime ); XFlush( data->display ); - thread_data->grab_hwnd = data->hwnd; } release_win_data( data ); } @@ -3135,7 +3133,6 @@ void X11DRV_SetCapture( HWND hwnd, UINT flags, HWND previous ) if (!(data = get_win_data( previous ))) return; XUngrabPointer( data->display, CurrentTime ); XFlush( data->display ); - thread_data->grab_hwnd = NULL; release_win_data( data ); } } diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index bbe52108aa5..73d778259e5 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -415,7 +415,6 @@ struct x11drv_thread_data { Display *display; XEvent *current_event; /* event currently being processed */ - HWND grab_hwnd; /* window that currently grabs the mouse */ HWND last_focus; /* last window that had focus */ HWND keymapnotify_hwnd; /* window that should receive modifier release events */ XIM xim; /* input method */ @@ -990,6 +989,13 @@ static inline HWND get_active_window(void) return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0; } +static inline HWND get_capture_window(void) +{ + GUITHREADINFO info; + info.cbSize = sizeof(info); + return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndCapture : 0; +} + static inline BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) { dst->left = max( src1->left, src2->left ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11245
participants (2)
-
Rémi Bernon -
Rémi Bernon (@rbernon)