From 618227d751fae716a5872edd1c23e9c953761921 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 8 Mar 2021 13:52:29 +0100 Subject: [PATCH] Fix xf_Pointer_SetPosition with smart-sizing --- client/X11/xf_event.c | 31 +++++++++++++++++++++++++++++++ client/X11/xf_event.h | 1 + client/X11/xf_graphics.c | 5 ++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 3419970f4..0d78be2ed 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -266,6 +266,37 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event) return TRUE; } +void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y) +{ + rdpSettings* settings; + INT64 tx, ty; + + if (!xfc || !xfc->context.settings || !y || !x) + return; + + settings = xfc->context.settings; + tx = *x; + ty = *y; + if (!xfc->remote_app) + { +#ifdef WITH_XRENDER + + if (xf_picture_transform_required(xfc)) + { + double xScalingFactor = xfc->scaledWidth / (double)settings->DesktopWidth; + double yScalingFactor = xfc->scaledHeight / (double)settings->DesktopHeight; + tx = ((tx + xfc->offset_x) * xScalingFactor); + ty = ((ty + xfc->offset_y) * yScalingFactor); + } + +#endif + } + + CLAMP_COORDINATES(tx, ty); + *x = tx; + *y = ty; +} + void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) { rdpSettings* settings; diff --git a/client/X11/xf_event.h b/client/X11/xf_event.h index 185c83c7c..2269d3eea 100644 --- a/client/X11/xf_event.h +++ b/client/X11/xf_event.h @@ -33,6 +33,7 @@ void xf_event_SendClientEvent(xfContext* xfc, xfWindow* window, Atom atom, unsig ...); void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y); +void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y); BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app); BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button, Window window, BOOL app); diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 4607601a7..bd5f57678 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -37,6 +37,7 @@ #include "xf_graphics.h" #include "xf_gdi.h" +#include "xf_event.h" #include #define TAG CLIENT_TAG("x11") @@ -531,6 +532,8 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) if (xfc->remote_app && !xfc->focused) return TRUE; + xf_adjust_coordinates_to_screen(xfc, &x, &y); + xf_lock_x11(xfc); rc = XGetWindowAttributes(xfc->display, handle, ¤t); @@ -551,7 +554,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) rc = XWarpPointer(xfc->display, None, handle, 0, 0, 0, 0, x, y); if (rc == 0) - WLog_WARN(TAG, "xf_Pointer_SetPosition: XWrapPointer==%d", rc); + WLog_WARN(TAG, "xf_Pointer_SetPosition: XWarpPointer==%d", rc); tmp.event_mask = current.your_event_mask; rc = XChangeWindowAttributes(xfc->display, handle, CWEventMask, &tmp); if (rc == 0)