Merge pull request #11619 from akallabeth/x11-log-extended

[client,x11] log XPutImage and XCopyRect
This commit is contained in:
akallabeth
2025-05-22 16:12:16 +02:00
committed by GitHub
6 changed files with 98 additions and 33 deletions

View File

@@ -329,8 +329,9 @@ void xf_draw_screen_(xfContext* xfc, int x, int y, int w, int h, const char* fkt
}
#endif
XCopyArea(xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y,
WINPR_ASSERTING_INT_CAST(uint32_t, w), WINPR_ASSERTING_INT_CAST(uint32_t, h), x, y);
LogDynAndXCopyArea(xfc->log, xfc->display, xfc->primary, xfc->window->handle, xfc->gc, x, y,
WINPR_ASSERTING_INT_CAST(uint32_t, w), WINPR_ASSERTING_INT_CAST(uint32_t, h),
x, y);
}
static BOOL xf_desktop_resize(rdpContext* context)
@@ -424,9 +425,10 @@ static BOOL xf_paint(xfContext* xfc, const GDI_RGN* region)
}
else
{
XPutImage(xfc->display, xfc->primary, xfc->gc, xfc->image, region->x, region->y, region->x,
region->y, WINPR_ASSERTING_INT_CAST(UINT16, region->w),
WINPR_ASSERTING_INT_CAST(UINT16, region->h));
LogDynAndXPutImage(xfc->log, xfc->display, xfc->primary, xfc->gc, xfc->image, region->x,
region->y, region->x, region->y,
WINPR_ASSERTING_INT_CAST(UINT16, region->w),
WINPR_ASSERTING_INT_CAST(UINT16, region->h));
xf_draw_screen(xfc, region->x, region->y, region->w, region->h);
}
return TRUE;

View File

@@ -94,10 +94,11 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
if (xfc->remote_app)
{
XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc), WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst), WINPR_ASSERTING_INT_CAST(int, nYDst),
dwidth, dheight);
LogDynAndXPutImage(xfc->log, xfc->display, xfc->primary, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc),
WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst),
WINPR_ASSERTING_INT_CAST(int, nYDst), dwidth, dheight);
xf_lock_x11(xfc);
xf_rail_paint_surface(xfc, surface->gdi.windowId, rect);
xf_unlock_x11(xfc);
@@ -107,10 +108,11 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
XPutImage(xfc->display, xfc->primary, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc), WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst), WINPR_ASSERTING_INT_CAST(int, nYDst),
dwidth, dheight);
LogDynAndXPutImage(xfc->log, xfc->display, xfc->primary, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc),
WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst),
WINPR_ASSERTING_INT_CAST(int, nYDst), dwidth, dheight);
xf_draw_screen(xfc, WINPR_ASSERTING_INT_CAST(int32_t, nXDst),
WINPR_ASSERTING_INT_CAST(int32_t, nYDst),
WINPR_ASSERTING_INT_CAST(int32_t, dwidth),
@@ -119,10 +121,11 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
else
#endif
{
XPutImage(xfc->display, xfc->drawable, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc), WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst), WINPR_ASSERTING_INT_CAST(int, nYDst),
dwidth, dheight);
LogDynAndXPutImage(xfc->log, xfc->display, xfc->drawable, xfc->gc, surface->image,
WINPR_ASSERTING_INT_CAST(int, nXSrc),
WINPR_ASSERTING_INT_CAST(int, nYSrc),
WINPR_ASSERTING_INT_CAST(int, nXDst),
WINPR_ASSERTING_INT_CAST(int, nYDst), dwidth, dheight);
}
}

View File

@@ -243,3 +243,45 @@ const char* x11_error_to_string(xfContext* xfc, int error, char* buffer, size_t
WLog_WARN(TAG, "XGetErrorText returned %d", rc);
return buffer;
}
int LogDynAndXCopyArea_ex(wLog* log, const char* file, const char* fkt, size_t line,
Display* display, Pixmap src, Window dest, GC gc, int src_x, int src_y,
unsigned int width, unsigned int height, int dest_x, int dest_y)
{
if (WLog_IsLevelActive(log, log_level))
{
XWindowAttributes attr = { 0 };
const Status rc = XGetWindowAttributes(display, dest, &attr);
write_log(log, log_level, file, fkt, line,
"XCopyArea(%p, src: {}, dest: [%d]{%lu, %d}, gc: {}, src_x: {%d}, src_y: {%d}, "
"width: {%d}, "
"height: {%d}, dest_x: {%d}, dest_y: {%d})",
display, rc, attr.root, attr.depth, src_x, src_y, width, height, dest_x, dest_y);
}
const int rc = XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y);
if (rc)
WLog_WARN(TAG, "XCopyArea returned %d", rc);
return rc;
}
int LogDynAndXPutImage_ex(wLog* log, const char* file, const char* fkt, size_t line,
Display* display, Drawable d, GC gc, XImage* image, int src_x, int src_y,
int dest_x, int dest_y, unsigned int width, unsigned int height)
{
if (WLog_IsLevelActive(log, log_level))
{
write_log(log, log_level, file, fkt, line,
"XPutImage(%p, d: {}, gc: {}, image: [%p]{%d}, src_y: {%d}, dest_x: {%d}, "
"dest_y: {%d}, width: {%d}, "
"height: {%d})",
display, image, image ? image->depth : -1, src_x, src_y, dest_x, dest_y, width,
height);
}
const int rc = XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
if (rc)
WLog_WARN(TAG, "XPutImage returned %d", rc);
return rc;
}

View File

@@ -103,4 +103,21 @@ int LogDynAndXConvertSelection_ex(wLog* log, const char* file, const char* fkt,
Display* display, Atom selection, Atom target, Atom property,
Window requestor, Time time);
#define LogDynAndXPutImage(log, display, d, gc, image, src_x, src_y, dest_x, dest_y, width, \
height) \
LogDynAndXPutImage_ex(log, __FILE__, __func__, __LINE__, (display), (d), (gc), (image), \
(src_x), (src_y), (dest_x), (dest_y), (width), (height))
int LogDynAndXPutImage_ex(wLog* log, const char* file, const char* fkt, size_t line,
Display* display, Drawable d, GC gc, XImage* image, int src_x, int src_y,
int dest_x, int dest_y, unsigned int width, unsigned int height);
#define LogDynAndXCopyArea(log, display, src, dest, gc, src_x, src_y, width, height, dest_x, \
dest_y) \
LogDynAndXCopyArea_ex(log, __FILE__, __func__, __LINE__, (display), (src), (dest), (gc), \
(src_x), (src_y), (width), (height), (dest_x), (dest_y))
extern int LogDynAndXCopyArea_ex(wLog* log, const char* file, const char* fkt, size_t line,
Display* display, Pixmap src, Window dest, GC gc, int src_x,
int src_y, unsigned int width, unsigned int height, int dest_x,
int dest_y);
BOOL IsGnome(void);

View File

@@ -83,9 +83,9 @@ static BOOL xfVideoShowSurface(VideoClientContext* video, const VideoSurface* su
if (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ||
freerdp_settings_get_bool(settings, FreeRDP_MultiTouchGestures))
{
XPutImage(xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0,
WINPR_ASSERTING_INT_CAST(int, surface->x),
WINPR_ASSERTING_INT_CAST(int, surface->y), surface->w, surface->h);
LogDynAndXPutImage(xfc->log, xfc->display, xfc->primary, xfc->gc, xfSurface->image, 0, 0,
WINPR_ASSERTING_INT_CAST(int, surface->x),
WINPR_ASSERTING_INT_CAST(int, surface->y), surface->w, surface->h);
xf_draw_screen(xfc, WINPR_ASSERTING_INT_CAST(int32_t, surface->x),
WINPR_ASSERTING_INT_CAST(int32_t, surface->y),
WINPR_ASSERTING_INT_CAST(int32_t, surface->w),
@@ -94,9 +94,9 @@ static BOOL xfVideoShowSurface(VideoClientContext* video, const VideoSurface* su
else
#endif
{
XPutImage(xfc->display, xfc->drawable, xfc->gc, xfSurface->image, 0, 0,
WINPR_ASSERTING_INT_CAST(int, surface->x),
WINPR_ASSERTING_INT_CAST(int, surface->y), surface->w, surface->h);
LogDynAndXPutImage(xfc->log, xfc->display, xfc->drawable, xfc->gc, xfSurface->image, 0, 0,
WINPR_ASSERTING_INT_CAST(int, surface->x),
WINPR_ASSERTING_INT_CAST(int, surface->y), surface->w, surface->h);
}
return TRUE;

View File

@@ -1357,14 +1357,14 @@ void xf_UpdateWindowArea(xfContext* xfc, xfAppWindow* appWindow, int x, int y, i
if (freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi))
{
XPutImage(xfc->display, appWindow->pixmap, appWindow->gc, xfc->image, ax, ay, x, y,
WINPR_ASSERTING_INT_CAST(uint32_t, width),
WINPR_ASSERTING_INT_CAST(uint32_t, height));
LogDynAndXPutImage(xfc->log, xfc->display, appWindow->pixmap, appWindow->gc, xfc->image, ax,
ay, x, y, WINPR_ASSERTING_INT_CAST(uint32_t, width),
WINPR_ASSERTING_INT_CAST(uint32_t, height));
}
XCopyArea(xfc->display, appWindow->pixmap, appWindow->handle, appWindow->gc, x, y,
WINPR_ASSERTING_INT_CAST(uint32_t, width), WINPR_ASSERTING_INT_CAST(uint32_t, height),
x, y);
LogDynAndXCopyArea(xfc->log, xfc->display, appWindow->pixmap, appWindow->handle, appWindow->gc,
x, y, WINPR_ASSERTING_INT_CAST(uint32_t, width),
WINPR_ASSERTING_INT_CAST(uint32_t, height), x, y);
XFlush(xfc->display);
xf_unlock_x11(xfc);
}
@@ -1514,11 +1514,12 @@ UINT xf_AppUpdateWindowFromSurface(xfContext* xfc, gdiGfxSurface* surface)
const UINT32 width = rect->right - rect->left;
const UINT32 height = rect->bottom - rect->top;
XPutImage(xfc->display, appWindow->pixmap, appWindow->gc, image, rect->left, rect->top,
rect->left, rect->top, width, height);
LogDynAndXPutImage(xfc->log, xfc->display, appWindow->pixmap, appWindow->gc, image,
rect->left, rect->top, rect->left, rect->top, width, height);
XCopyArea(xfc->display, appWindow->pixmap, appWindow->handle, appWindow->gc, rect->left,
rect->top, width, height, rect->left, rect->top);
LogDynAndXCopyArea(xfc->log, xfc->display, appWindow->pixmap, appWindow->handle,
appWindow->gc, rect->left, rect->top, width, height, rect->left,
rect->top);
}
rc = CHANNEL_RC_OK;