From e535601d270b876c00f516e572446488c2c79044 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 4 Jul 2022 12:13:20 +0200 Subject: [PATCH] Updated pointer debug log messages (cherry picked from commit 73251193c2b13fd132ee5e6f2fd343bc33ed42fb) --- client/X11/xf_event.c | 3 ++ client/X11/xf_graphics.c | 75 ++++++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index f026dbb63..bdcdcb5da 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -672,6 +672,9 @@ static BOOL xf_event_ConfigureNotify(xfContext* xfc, const XConfigureEvent* even rdpSettings* settings; settings = xfc->context.settings; + WLog_DBG(TAG, "%s: x=%" PRId32 ", y=%" PRId32 ", w=%" PRId32 ", h=%" PRId32, __func__, event->x, + event->y, event->width, event->height); + if (!app) { if (!xfc->window) diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 10c1be9ef..86b2def82 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -30,6 +30,9 @@ #include #endif +#include +#include + #include #include @@ -258,6 +261,9 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, const rdpPo xTargetSize = pointer->width * xscale; yTargetSize = pointer->height * yscale; + WLog_DBG(TAG, "%s: scaled: %" PRIu32 "x%" PRIu32 ", desktop: %" PRIu32 "x%" PRIu32, __func__, + xfc->scaledWidth, xfc->savedHeight, settings->DesktopWidth, settings->DesktopHeight); + for (int i = 0; i < xpointer->nCursors; i++) { if (xpointer->cursorWidths[i] == xTargetSize && xpointer->cursorHeights[i] == yTargetSize) @@ -311,21 +317,26 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, const rdpPo { xf_unlock_x11(xfc); return FALSE; - } + } - const double xs = fabs(fabs(xscale) - 1.0); - const double ys = fabs(fabs(yscale) - 1.0); - if ((xs > DBL_EPSILON) || (ys > DBL_EPSILON)) - { - if (!freerdp_image_scale((BYTE*)ci.pixels, CursorFormat, 0, 0, 0, ci.width, - ci.height, (BYTE*)xpointer->cursorPixels, CursorFormat, 0, - 0, 0, pointer->width, pointer->height)) - { - _aligned_free(ci.pixels); - xf_unlock_x11(xfc); - return FALSE; - } - } + const double xs = fabs(fabs(xscale) - 1.0); + const double ys = fabs(fabs(yscale) - 1.0); + WLog_DBG(TAG, + "%s: cursorIndex %" PRId32 " scaling pointer %" PRIu32 "x%" PRIu32 " --> %" PRIu32 + "x%" PRIu32 " [%lfx%lf]", + __func__, cursorIndex, pointer->width, pointer->height, ci.width, ci.height, + xscale, yscale); + if ((xs > DBL_EPSILON) || (ys > DBL_EPSILON)) + { + if (!freerdp_image_scale((BYTE*)ci.pixels, CursorFormat, 0, 0, 0, ci.width, ci.height, + (BYTE*)xpointer->cursorPixels, CursorFormat, 0, 0, 0, + pointer->width, pointer->height)) + { + _aligned_free(ci.pixels); + xf_unlock_x11(xfc); + return FALSE; + } + } else { ci.pixels = xpointer->cursorPixels; @@ -340,6 +351,10 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, const rdpPo xf_unlock_x11(xfc); } + else + { + WLog_DBG(TAG, "%s: using cached cursor %" PRId32, __func__, cursorIndex); + } cursor[0] = xpointer->cursors[cursorIndex]; #endif @@ -383,11 +398,12 @@ BOOL xf_pointer_update_scale(xfContext* xfc) if (!pointer) return TRUE; - return xf_Pointer_Set(&xfc->common.context, &xfc->pointer->pointer); + return xf_Pointer_Set(&xfc->context, &xfc->pointer->pointer); } static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) { + BOOL rc = FALSE; #ifdef WITH_XCURSOR UINT32 CursorFormat; size_t size; @@ -395,7 +411,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) xfPointer* xpointer = (xfPointer*)pointer; if (!context || !pointer || !context->gdi) - return FALSE; + goto fail; if (!xfc->invert) CursorFormat = (!xfc->big_endian) ? PIXEL_FORMAT_RGBA32 : PIXEL_FORMAT_ABGR32; @@ -408,7 +424,7 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) size = pointer->height * pointer->width * GetBytesPerPixel(CursorFormat) * 1ULL; if (!(xpointer->cursorPixels = (XcursorPixel*)_aligned_malloc(size, 16))) - return FALSE; + goto fail; if (!freerdp_image_copy_from_pointer_data( (BYTE*)xpointer->cursorPixels, CursorFormat, 0, 0, 0, pointer->width, pointer->height, @@ -418,13 +434,18 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) _aligned_free(xpointer->cursorPixels); return FALSE; } + rc = TRUE; #endif - return TRUE; +fail: + WLog_DBG(TAG, "%s: %ld", __func__, rc ? pointer : -1); + return rc; } static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) { + WLog_DBG(TAG, "%s: %p", __func__, pointer); + #ifdef WITH_XCURSOR xfContext* xfc = (xfContext*)context; xfPointer* xpointer = (xfPointer*)pointer; @@ -450,6 +471,8 @@ static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer) { + WLog_DBG(TAG, "%s: %p", __func__, pointer); + #ifdef WITH_XCURSOR xfContext* xfc = (xfContext*)context; Window handle = xf_Pointer_get_window(xfc); @@ -465,12 +488,17 @@ static BOOL xf_Pointer_Set(rdpContext* context, const rdpPointer* pointer) XDefineCursor(xfc->display, handle, xfc->pointer->cursor); xf_unlock_x11(xfc); } + else + { + WLog_WARN(TAG, "%s: handle=%ld", __func__, handle); + } #endif return TRUE; } static BOOL xf_Pointer_SetNull(rdpContext* context) { + WLog_DBG(TAG, "%s", __func__); #ifdef WITH_XCURSOR xfContext* xfc = (xfContext*)context; static Cursor nullcursor = None; @@ -527,10 +555,11 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) if (!handle) { - WLog_WARN(TAG, "xf_Pointer_SetPosition: focus %d, handle%lu", xfc->focused, handle); + WLog_WARN(TAG, "%s: focus %d, handle%lu", __func__, xfc->focused, handle); return TRUE; } + WLog_DBG(TAG, "%s: %" PRIu32 "x%" PRIu32, __func__, x, y); if (xfc->remote_app && !xfc->focused) return TRUE; @@ -541,7 +570,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) rc = XGetWindowAttributes(xfc->display, handle, ¤t); if (rc == 0) { - WLog_WARN(TAG, "xf_Pointer_SetPosition: XGetWindowAttributes==%d", rc); + WLog_WARN(TAG, "%s: XGetWindowAttributes==%d", __func__, rc); goto out; } @@ -550,17 +579,17 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) rc = XChangeWindowAttributes(xfc->display, handle, CWEventMask, &tmp); if (rc == 0) { - WLog_WARN(TAG, "xf_Pointer_SetPosition: XChangeWindowAttributes==%d", rc); + WLog_WARN(TAG, "%s: XChangeWindowAttributes==%d", __func__, rc); goto out; } rc = XWarpPointer(xfc->display, None, handle, 0, 0, 0, 0, x, y); if (rc == 0) - WLog_WARN(TAG, "xf_Pointer_SetPosition: XWarpPointer==%d", rc); + WLog_WARN(TAG, "%s: XWarpPointer==%d", __func__, rc); tmp.event_mask = current.your_event_mask; rc = XChangeWindowAttributes(xfc->display, handle, CWEventMask, &tmp); if (rc == 0) - WLog_WARN(TAG, "xf_Pointer_SetPosition: 2.try XChangeWindowAttributes==%d", rc); + WLog_WARN(TAG, "%s: 2.try XChangeWindowAttributes==%d", __func__, rc); ret = TRUE; out: xf_unlock_x11(xfc);