From: Rémi Bernon rbernon@codeweavers.com
This is now properly handled in win32u and all the drivers are now working with physical DPI coordinates directly.
Note that there's still an additional mapping from Wine (window) to Wayland (surface) coordinates, that is handled by coords_from_window and coords_to_window. --- dlls/winewayland.drv/wayland_pointer.c | 46 ++------------------------ dlls/winewayland.drv/window.c | 2 +- 2 files changed, 3 insertions(+), 45 deletions(-)
diff --git a/dlls/winewayland.drv/wayland_pointer.c b/dlls/winewayland.drv/wayland_pointer.c index 1d8acaeabd2..355fc3b486f 100644 --- a/dlls/winewayland.drv/wayland_pointer.c +++ b/dlls/winewayland.drv/wayland_pointer.c @@ -74,9 +74,6 @@ static void pointer_handle_motion_internal(wl_fixed_t sx, wl_fixed_t sy)
pthread_mutex_unlock(&surface->mutex);
- /* Hardware input events are in physical coordinates. */ - if (!NtUserLogicalToPerMonitorDPIPhysicalPoint(hwnd, &screen)) return; - input.type = INPUT_MOUSE; input.mi.dx = screen.x; input.mi.dy = screen.y; @@ -249,22 +246,19 @@ static const struct wl_pointer_listener pointer_listener = };
static void relative_pointer_v1_relative_motion(void *data, - struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1, + struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1, uint32_t utime_hi, uint32_t utime_lo, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) { INPUT input = {0}; HWND hwnd; - POINT screen, origin; + POINT screen; struct wayland_surface *surface; - RECT window_rect;
if (!(hwnd = wayland_pointer_get_focused_hwnd())) return; if (!(surface = wayland_surface_lock_hwnd(hwnd))) return;
- window_rect = surface->window.rect; - wayland_surface_coords_to_window(surface, wl_fixed_to_double(dx), wl_fixed_to_double(dy), @@ -272,42 +266,6 @@ static void relative_pointer_v1_relative_motion(void *data,
pthread_mutex_unlock(&surface->mutex);
- /* We clip the relative motion within the window rectangle so that - * the NtUserLogicalToPerMonitorDPIPhysicalPoint calls later succeed. - * TODO: Avoid clipping by using a more versatile dpi mapping function. */ - if (screen.x >= 0) - { - origin.x = window_rect.left; - screen.x += origin.x; - if (screen.x >= window_rect.right) screen.x = window_rect.right - 1; - } - else - { - origin.x = window_rect.right; - screen.x += origin.x; - if (screen.x < window_rect.left) screen.x = window_rect.left; - } - - if (screen.y >= 0) - { - origin.y = window_rect.top; - screen.y += origin.y; - if (screen.y >= window_rect.bottom) screen.y = window_rect.bottom - 1; - } - else - { - origin.y = window_rect.bottom; - screen.y += origin.y; - if (screen.y < window_rect.top) screen.y = window_rect.top; - } - - /* Transform the relative motion from window coordinates to physical - * coordinates required for the input event. */ - if (!NtUserLogicalToPerMonitorDPIPhysicalPoint(hwnd, &screen)) return; - if (!NtUserLogicalToPerMonitorDPIPhysicalPoint(hwnd, &origin)) return; - screen.x -= origin.x; - screen.y -= origin.y; - input.type = INPUT_MOUSE; input.mi.dx = screen.x; input.mi.dy = screen.y; diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 73a8de37f77..a6285ab592c 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -184,7 +184,7 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, }
conf->state = window_state; - conf->scale = NtUserGetDpiForWindow(data->hwnd) / 96.0; + conf->scale = get_win_monitor_dpi(data->hwnd) / 96.0; conf->visible = (style & WS_VISIBLE) == WS_VISIBLE; conf->managed = data->managed; }