From 689269dcdef60608f58a4e0cdbf955e4944bdc49 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:51:30 +0000 Subject: [PATCH] Fixes some problems with monitor hotplug This fixes some monitor hotplug issues with non-GFX codepaths. 1) The server_version_message() was working on an out-of-date copy of the client_info. As a result, the X server and the window manager did not agree on the number of windows 2) As a result of 1), a memory leak was found in the VNC module. --- libxrdp/libxrdp.c | 9 --------- vnc/vnc.c | 1 + xrdp/xrdp_mm.c | 8 +++++++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index af1714de..400de496 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -1153,15 +1153,6 @@ libxrdp_reset(struct xrdp_session *session, return 0; } - /* if same (and only one monitor on client) don't need to do anything */ - if (client_info->display_sizes.session_width == width && - client_info->display_sizes.session_height == height && - client_info->bpp == bpp && - (client_info->display_sizes.monitorCount == 0 || client_info->multimon == 0)) - { - return 0; - } - client_info->display_sizes.session_width = width; client_info->display_sizes.session_height = height; client_info->display_sizes.monitorCount = 0; diff --git a/vnc/vnc.c b/vnc/vnc.c index 77845e2f..d9b0520f 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -2133,6 +2133,7 @@ lib_mod_set_param(struct vnc *v, const char *name, const char *value) (const struct xrdp_client_info *) value; g_free(v->client_layout.s); + v->client_layout.count = 0; /* Save monitor information from the client */ if (!client_info->multimon || client_info->display_sizes.monitorCount < 1) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 4a7e9073..614175cd 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -1743,6 +1743,13 @@ process_display_control_monitor_layout_data(struct xrdp_wm *wm) mm, WMRZ_SERVER_VERSION_MESSAGE_START); break; case WMRZ_SERVER_VERSION_MESSAGE_START: + /* Update the client_info structure with the new description + * and tell the module so it can communicate the new + * screen layout to the backend */ + sync_dynamic_monitor_data(wm, &(description->description)); + module->mod_set_param(module, "client_info", + (const char *) (wm->session->client_info)); + error = module->mod_server_version_message(module); if (error != 0) { @@ -1813,7 +1820,6 @@ process_display_control_monitor_layout_data(struct xrdp_wm *wm) " xrdp_bitmap_resize failed %d", error); return advance_error(error, mm); } - sync_dynamic_monitor_data(wm, &(description->description)); advance_resize_state_machine(mm, WMRZ_EGFX_INITIALIZE); break; case WMRZ_EGFX_INITIALIZE: