From dd85c549615cb3c9699df0da83d24587e383eff0 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 13 Jul 2021 00:08:39 -0700 Subject: [PATCH] GUACAMOLE-377: Add handling for EndPaint required by software GDI implementation of RDPGFX. --- src/protocols/rdp/gdi.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/protocols/rdp/gdi.c b/src/protocols/rdp/gdi.c index 1cbee144..4ecbe396 100644 --- a/src/protocols/rdp/gdi.c +++ b/src/protocols/rdp/gdi.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -372,8 +373,37 @@ BOOL guac_rdp_gdi_set_bounds(rdpContext* context, const rdpBounds* bounds) { } BOOL guac_rdp_gdi_end_paint(rdpContext* context) { - /* IGNORE */ + + guac_client* client = ((rdp_freerdp_context*) context)->client; + guac_rdp_client* rdp_client = (guac_rdp_client*) client->data; + rdpGdi* gdi = context->gdi; + + /* Ignore paint if GDI output is suppressed */ + if (gdi->suppressOutput) + return TRUE; + + /* Ignore paint if nothing has been done (empty rect) */ + if (gdi->primary->hdc->hwnd->invalid->null) + return TRUE; + + INT32 x = gdi->primary->hdc->hwnd->invalid->x; + INT32 y = gdi->primary->hdc->hwnd->invalid->y; + UINT32 w = gdi->primary->hdc->hwnd->invalid->w; + UINT32 h = gdi->primary->hdc->hwnd->invalid->h; + + /* Create surface from image data */ + cairo_surface_t* surface = cairo_image_surface_create_for_data( + gdi->primary_buffer + 4*x + y*gdi->stride, + CAIRO_FORMAT_RGB24, w, h, gdi->stride); + + /* Send surface to buffer */ + guac_common_surface_draw(rdp_client->display->default_surface, x, y, surface); + + /* Free surface */ + cairo_surface_destroy(surface); + return TRUE; + } BOOL guac_rdp_gdi_desktop_resize(rdpContext* context) {