diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 298c6db4e..c307569aa 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -722,14 +722,19 @@ static BOOL x11_shadow_check_resize(x11ShadowSubsystem* subsystem) /* Screen size changed. Refresh monitor definitions and trigger screen resize */ subsystem->common.numMonitors = x11_shadow_enum_monitors(subsystem->common.monitors, 16); - shadow_screen_resize(subsystem->common.server->screen); - subsystem->width = attr.width; - subsystem->height = attr.height; + if (!shadow_screen_resize(subsystem->common.server->screen)) + return FALSE; + + WINPR_ASSERT(attr.width > 0); + WINPR_ASSERT(attr.height > 0); + + subsystem->width = (UINT32)attr.width; + subsystem->height = (UINT32)attr.height; virtualScreen->left = 0; virtualScreen->top = 0; - virtualScreen->right = subsystem->width - 1; - virtualScreen->bottom = subsystem->height - 1; + virtualScreen->right = attr.width - 1; + virtualScreen->bottom = attr.height - 1; virtualScreen->flags = 1; return TRUE; } diff --git a/server/shadow/shadow_screen.c b/server/shadow/shadow_screen.c index 8a9e0b304..f5a44d0ba 100644 --- a/server/shadow/shadow_screen.c +++ b/server/shadow/shadow_screen.c @@ -119,23 +119,22 @@ void shadow_screen_free(rdpShadowScreen* screen) BOOL shadow_screen_resize(rdpShadowScreen* screen) { - int x = 0; - int y = 0; - int width = 0; - int height = 0; - MONITOR_DEF* primary = NULL; - rdpShadowSubsystem* subsystem = NULL; - if (!screen) return FALSE; - subsystem = screen->server->subsystem; - primary = &(subsystem->monitors[subsystem->selectedMonitor]); + WINPR_ASSERT(screen->server); - x = primary->left; - y = primary->top; - width = primary->right - primary->left + 1; - height = primary->bottom - primary->top + 1; + rdpShadowSubsystem* subsystem = screen->server->subsystem; + WINPR_ASSERT(subsystem); + WINPR_ASSERT(subsystem->monitors); + + MONITOR_DEF* primary = &(subsystem->monitors[subsystem->selectedMonitor]); + WINPR_ASSERT(primary); + + const INT32 x = primary->left; + const INT32 y = primary->top; + const INT32 width = primary->right - primary->left + 1; + const INT32 height = primary->bottom - primary->top + 1; WINPR_ASSERT(x >= 0); WINPR_ASSERT(x <= UINT16_MAX); @@ -145,6 +144,7 @@ BOOL shadow_screen_resize(rdpShadowScreen* screen) WINPR_ASSERT(width <= UINT16_MAX); WINPR_ASSERT(height >= 0); WINPR_ASSERT(height <= UINT16_MAX); + if (shadow_surface_resize(screen->primary, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height) && shadow_surface_resize(screen->lobby, (UINT16)x, (UINT16)y, (UINT16)width, (UINT16)height))