From 0b17406eec3bb46726d275197ecd01e823a46a7f Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 18 Jan 2019 14:38:51 +0100 Subject: [PATCH 1/4] Unified buffer update and screen refresh on focus --- client/Wayland/wlfreerdp.c | 72 ++++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 04a9c68d4..658c7ae02 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -69,34 +69,25 @@ static BOOL wl_begin_paint(rdpContext* context) return TRUE; } - -static BOOL wl_end_paint(rdpContext* context) +static BOOL wl_update_buffer(wlfContext* context_w, UINT32 x, UINT32 y, UINT32 w, UINT32 h) { rdpGdi* gdi; char* data; - wlfContext* context_w; - INT32 x, y; - UINT32 w, h; UINT32 i; - if (!context || !context->gdi || !context->gdi->primary) + if (!context_w) return FALSE; - gdi = context->gdi; - - if (gdi->primary->hdc->hwnd->invalid->null) - return TRUE; - - x = gdi->primary->hdc->hwnd->invalid->x; - y = gdi->primary->hdc->hwnd->invalid->y; - w = gdi->primary->hdc->hwnd->invalid->w; - h = gdi->primary->hdc->hwnd->invalid->h; - context_w = (wlfContext*) context; data = UwacWindowGetDrawingBuffer(context_w->window); if (!data) return FALSE; + gdi = context_w->context.gdi; + + if (!gdi) + return FALSE; + for (i = 0; i < h; i++) { memcpy(data + ((i + y) * (gdi->width * GetBytesPerPixel( @@ -113,6 +104,29 @@ static BOOL wl_end_paint(rdpContext* context) return wl_update_content(context_w); } +static BOOL wl_end_paint(rdpContext* context) +{ + rdpGdi* gdi; + wlfContext* context_w; + INT32 x, y; + UINT32 w, h; + + if (!context || !context->gdi || !context->gdi->primary) + return FALSE; + + gdi = context->gdi; + + if (gdi->primary->hdc->hwnd->invalid->null) + return TRUE; + + x = gdi->primary->hdc->hwnd->invalid->x; + y = gdi->primary->hdc->hwnd->invalid->y; + w = gdi->primary->hdc->hwnd->invalid->w; + h = gdi->primary->hdc->hwnd->invalid->h; + context_w = (wlfContext*) context; + return wl_update_buffer(context_w, x, y, w, h); +} + static BOOL wl_pre_connect(freerdp* instance) { @@ -189,12 +203,8 @@ static BOOL wl_post_connect(freerdp* instance) UwacWindowSetOpaqueRegion(context->window, 0, 0, gdi->width, gdi->height); instance->update->BeginPaint = wl_begin_paint; instance->update->EndPaint = wl_end_paint; - memcpy(UwacWindowGetDrawingBuffer(context->window), gdi->primary_buffer, - gdi->width * gdi->height * 4); - UwacWindowAddDamage(context->window, 0, 0, gdi->width, gdi->height); - context->haveDamage = TRUE; freerdp_keyboard_init(instance->context->settings->KeyboardLayout); - return wl_update_content(context); + return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); } static void wl_post_disconnect(freerdp* instance) @@ -214,6 +224,17 @@ static void wl_post_disconnect(freerdp* instance) UwacDestroyWindow(&context->window); } +static BOOL wl_refresh_display(wlfContext* context) +{ + rdpGdi* gdi; + + if (!context || !context->context.gdi) + return FALSE; + + gdi = context->context.gdi; + return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); +} + static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) { UwacEvent event; @@ -222,6 +243,8 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) if (UwacDisplayDispatch(display, 1) < 0) return FALSE; + context = (wlfContext*)instance->context; + while (UwacHasEvent(display)) { if (UwacNextEvent(display, &event) != UWAC_SUCCESS) @@ -234,7 +257,6 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) if (!instance) continue; - context = (wlfContext*)instance->context; context->waitingFrameDone = FALSE; if (context->haveDamage && !wl_update_content(context)) @@ -278,6 +300,12 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) break; + case UWAC_EVENT_CONFIGURE: + if (!wl_refresh_display(context)) + return FALSE; + + break; + default: break; } From a5cee1751fce5aea2aad49aa29166d19e6983d99 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Fri, 18 Jan 2019 14:39:14 +0100 Subject: [PATCH 2/4] Resubmit buffer if necessary. --- uwac/libuwac/uwac-window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index 324c520d3..e62986997 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -641,6 +641,7 @@ UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNex if (window->pendingBuffer) { /* we already have a pending frame, don't do anything*/ + UwacSubmitBufferPtr(window, window->pendingBuffer); return UWAC_SUCCESS; } From 5ef6b71974b2fe544ae4994f602da3a326fb4232 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 22 Jan 2019 10:29:08 +0100 Subject: [PATCH 3/4] Implemented DesktopResize callback for wayland client. --- client/Wayland/wlfreerdp.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 658c7ae02..59d679d10 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -127,6 +127,28 @@ static BOOL wl_end_paint(rdpContext* context) return wl_update_buffer(context_w, x, y, w, h); } +static BOOL wl_refresh_display(wlfContext* context) +{ + rdpGdi* gdi; + + if (!context || !context->context.gdi) + return FALSE; + + gdi = context->context.gdi; + return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); +} + +static BOOL wl_resize_display(rdpContext* context) +{ + wlfContext* wlc = (wlfContext*)context; + rdpGdi* gdi = context->gdi; + rdpSettings* settings = context->settings; + + if (!gdi_resize(gdi, settings->DesktopWidth, settings->DesktopHeight)) + return FALSE; + + return wl_refresh_display(wlc); +} static BOOL wl_pre_connect(freerdp* instance) { @@ -203,6 +225,7 @@ static BOOL wl_post_connect(freerdp* instance) UwacWindowSetOpaqueRegion(context->window, 0, 0, gdi->width, gdi->height); instance->update->BeginPaint = wl_begin_paint; instance->update->EndPaint = wl_end_paint; + instance->update->DesktopResize = wl_resize_display; freerdp_keyboard_init(instance->context->settings->KeyboardLayout); return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); } @@ -224,17 +247,6 @@ static void wl_post_disconnect(freerdp* instance) UwacDestroyWindow(&context->window); } -static BOOL wl_refresh_display(wlfContext* context) -{ - rdpGdi* gdi; - - if (!context || !context->context.gdi) - return FALSE; - - gdi = context->context.gdi; - return wl_update_buffer(context, 0, 0, gdi->width, gdi->height); -} - static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display) { UwacEvent event; From f2fd785128177b622bbf1662ee3ff3974c185a89 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 22 Jan 2019 16:55:46 +0100 Subject: [PATCH 4/4] Fixed comment. --- uwac/libuwac/uwac-window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index e62986997..267f6f6b5 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -640,7 +640,8 @@ UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNex if (window->pendingBuffer) { - /* we already have a pending frame, don't do anything*/ + /* we already have a pending frame. resubmit as the buffer + * might have been discarded due to focus loss */ UwacSubmitBufferPtr(window, window->pendingBuffer); return UWAC_SUCCESS; }