-- v3: win32u: Use per-monitor DPI window_from_point in process_mouse_message. win32u: Parameterize window_from_point dpi. win32u: Restore DPI awareness context in process_mouse_message.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/message.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index d1f49ca3ed9..8e1b0d7bbae 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2404,12 +2404,12 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H static MSG clk_msg;
POINT pt; - UINT message; + UINT message, context; INT hittest; EVENTMSG event; GUITHREADINFO info; MOUSEHOOKSTRUCTEX hook; - BOOL eat_msg; + BOOL eat_msg = TRUE; WPARAM wparam;
/* find the window to dispatch this mouse message to */ @@ -2443,7 +2443,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H }
msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt ); - set_thread_dpi_awareness_context( get_window_dpi_awareness_context( msg->hwnd )); + context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( msg->hwnd ) );
/* FIXME: is this really the right place for this hook? */ event.message = msg->message; @@ -2453,7 +2453,7 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H event.paramH = msg->pt.y; call_hooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event, sizeof(event) );
- if (!check_hwnd_filter( msg, hwnd_filter )) return FALSE; + if (!check_hwnd_filter( msg, hwnd_filter )) goto done;
pt = msg->pt; message = msg->message; @@ -2508,13 +2508,13 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H } } } - if (message < first || message > last) return FALSE; + if (message < first || message > last) goto done; /* update static double click conditions */ if (update) clk_msg = *msg; } else { - if (message < first || message > last) return FALSE; + if (message < first || message > last) goto done; } msg->wParam = wparam;
@@ -2534,26 +2534,26 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H hook.mouseData = msg->wParam; accept_hardware_message( hw_id ); call_hooks( WH_CBT, HCBT_CLICKSKIPPED, message, (LPARAM)&hook, sizeof(hook) ); - return FALSE; + goto done; }
if ((hittest == HTERROR) || (hittest == HTNOWHERE)) { send_message( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, MAKELONG( hittest, msg->message )); accept_hardware_message( hw_id ); - return FALSE; + goto done; }
if (remove) accept_hardware_message( hw_id );
+ eat_msg = FALSE; + if (!remove || info.hwndCapture) { msg->message = message; - return TRUE; + goto done; }
- eat_msg = FALSE; - if (msg->message == WM_LBUTTONDOWN || msg->message == WM_RBUTTONDOWN || msg->message == WM_MBUTTONDOWN || @@ -2604,6 +2604,9 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H send_message( msg->hwnd, WM_SETCURSOR, (WPARAM)msg->hwnd, MAKELONG( hittest, msg->message ));
msg->message = message; + +done: + set_thread_dpi_awareness_context( context ); return !eat_msg; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/input.c | 4 ++-- dlls/win32u/message.c | 5 +++-- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/window.c | 13 ++++++------- 4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 5b25086cb6f..0d9fe0f1d38 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -1607,7 +1607,7 @@ void update_mouse_tracking_info( HWND hwnd ) TRACE( "hwnd %p\n", hwnd );
get_cursor_pos( &pos ); - hwnd = window_from_point( hwnd, pos, &hittest ); + hwnd = window_from_point( hwnd, pos, &hittest, get_thread_dpi() );
TRACE( "point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest );
@@ -1703,7 +1703,7 @@ BOOL WINAPI NtUserTrackMouseEvent( TRACKMOUSEEVENT *info ) NtUserSystemParametersInfo( SPI_GETMOUSEHOVERTIME, 0, &hover_time, 0 );
get_cursor_pos( &pos ); - hwnd = window_from_point( info->hwndTrack, pos, &hittest ); + hwnd = window_from_point( info->hwndTrack, pos, &hittest, get_thread_dpi() ); TRACE( "point %s hwnd %p hittest %d\n", wine_dbgstr_point(&pos), hwnd, hittest );
if (info->dwFlags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_NONCLIENT)) diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 8e1b0d7bbae..537a48ffd7b 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2424,15 +2424,16 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H else { HWND orig = msg->hwnd; + UINT dpi = get_thread_dpi();
- msg->hwnd = window_from_point( msg->hwnd, msg->pt, &hittest ); + msg->hwnd = window_from_point( msg->hwnd, msg->pt, &hittest, dpi ); if (!msg->hwnd) /* As a heuristic, try the next window if it's the owner of orig */ { HWND next = get_window_relative( orig, GW_HWNDNEXT );
if (next && get_window_relative( orig, GW_OWNER ) == next && is_current_thread_window( next )) - msg->hwnd = window_from_point( next, msg->pt, &hittest ); + msg->hwnd = window_from_point( next, msg->pt, &hittest, dpi ); } }
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 96517ef081a..8e33370ee48 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -252,7 +252,7 @@ extern BOOL set_window_pos( WINDOWPOS *winpos, int parent_x, int parent_y ); extern ULONG set_window_style( HWND hwnd, ULONG set_bits, ULONG clear_bits ); extern BOOL show_owned_popups( HWND owner, BOOL show ); extern void update_window_state( HWND hwnd ); -extern HWND window_from_point( HWND hwnd, POINT pt, INT *hittest ); +extern HWND window_from_point( HWND hwnd, POINT pt, INT *hittest, UINT dpi ); extern HWND get_shell_window(void); extern HWND get_progman_window(void); extern HWND set_progman_window( HWND hwnd ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 8ca49afcd87..ce6a820bf11 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -2198,7 +2198,7 @@ done: * Point is in screen coordinates. * Returned list must be freed by caller. */ -static HWND *list_children_from_point( HWND hwnd, POINT pt ) +static HWND *list_children_from_point( HWND hwnd, POINT pt, UINT dpi ) { int i, size = 128; HWND *list; @@ -2214,7 +2214,7 @@ static HWND *list_children_from_point( HWND hwnd, POINT pt ) req->parent = wine_server_user_handle( hwnd ); req->x = pt.x; req->y = pt.y; - req->dpi = get_thread_dpi(); + req->dpi = dpi; wine_server_set_reply( req, list, (size-1) * sizeof(user_handle_t) ); if (!wine_server_call( req )) count = reply->count; } @@ -2239,19 +2239,18 @@ static HWND *list_children_from_point( HWND hwnd, POINT pt ) * * Find the window and hittest for a given point. */ -HWND window_from_point( HWND hwnd, POINT pt, INT *hittest ) +HWND window_from_point( HWND hwnd, POINT pt, INT *hittest, UINT dpi ) { int i, res; HWND ret, *list; POINT win_pt; - int dpi;
if (!hwnd) hwnd = get_desktop_window(); - if (!(dpi = get_thread_dpi())) dpi = get_win_monitor_dpi( hwnd ); + if (!dpi) dpi = get_win_monitor_dpi( hwnd );
*hittest = HTNOWHERE;
- if (!(list = list_children_from_point( hwnd, pt ))) return 0; + if (!(list = list_children_from_point( hwnd, pt, dpi ))) return 0;
/* now determine the hittest */
@@ -2293,7 +2292,7 @@ HWND WINAPI NtUserWindowFromPoint( LONG x, LONG y ) { POINT pt = { .x = x, .y = y }; INT hittest; - return window_from_point( 0, pt, &hittest ); + return window_from_point( 0, pt, &hittest, get_thread_dpi() ); }
/*******************************************************************
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/message.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index 537a48ffd7b..1d5383c4f58 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -2424,16 +2424,15 @@ static BOOL process_mouse_message( MSG *msg, UINT hw_id, ULONG_PTR extra_info, H else { HWND orig = msg->hwnd; - UINT dpi = get_thread_dpi();
- msg->hwnd = window_from_point( msg->hwnd, msg->pt, &hittest, dpi ); + msg->hwnd = window_from_point( msg->hwnd, msg->pt, &hittest, 0 /* per-monitor DPI */ ); if (!msg->hwnd) /* As a heuristic, try the next window if it's the owner of orig */ { HWND next = get_window_relative( orig, GW_HWNDNEXT );
if (next && get_window_relative( orig, GW_OWNER ) == next && is_current_thread_window( next )) - msg->hwnd = window_from_point( next, msg->pt, &hittest, dpi ); + msg->hwnd = window_from_point( next, msg->pt, &hittest, 0 /* per-monitor DPI */ ); } }
Should be better now.