From c11f47db893e76c6bd6ac9824c03294bd0fe6128 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 21 Dec 2022 17:22:43 +0100 Subject: [PATCH] [server,shadow] do treat deactivate/reactivate if a resolution change is required, run postconnect just as if it was successful. --- libfreerdp/core/peer.c | 21 +++++++++------------ server/shadow/shadow_client.c | 14 +++++--------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index d37cbd528..c54f1c75e 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -759,22 +759,19 @@ static state_run_t rdp_peer_handle_state_active(freerdp_peer* client) } if (!client->connected) { - switch (rdp_get_state(rdp)) - { - case CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE: - ret = STATE_RUN_CONTINUE; - break; - case CONNECTION_STATE_ACTIVE: - default: - ret = STATE_RUN_FAILED; - break; - } + ret = STATE_RUN_FAILED; } else if (!client->activated) { - IFCALLRET(client->Activate, client->activated, client); + BOOL activated = TRUE; - if (!client->activated) + /* Set client->activated TRUE before calling the Activate callback. + * the Activate callback might reset the client->activated flag even if it returns success + * (e.g. deactivate/reactivate sequence) */ + client->activated = TRUE; + IFCALLRET(client->Activate, activated, client); + + if (!activated) ret = STATE_RUN_FAILED; else ret = STATE_RUN_SUCCESS; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index f4c41461d..148c49492 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -481,15 +481,6 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer) peer->hostname, settings->DesktopWidth, settings->DesktopHeight, freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)); - /* Resize client if necessary */ - if (shadow_client_recalc_desktop_size(client)) - { - shadow_send_desktop_resize(client); - return FALSE; - } - - shadow_reset_desktop_resize(client); - if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK) return FALSE; @@ -644,6 +635,11 @@ static BOOL shadow_client_activate(freerdp_peer* peer) settings = peer->context->settings; WINPR_ASSERT(settings); + /* Resize client if necessary */ + if (shadow_client_recalc_desktop_size(client)) + return shadow_send_desktop_resize(client); + + shadow_reset_desktop_resize(client); client->activated = TRUE; client->inLobby = client->mayView ? FALSE : TRUE;