Better checks on activation received

Check for reactivation, remember resolution, ...
This commit is contained in:
akallabeth
2022-10-21 09:53:24 +02:00
committed by David Fort
parent 732a7979a3
commit 2ef506cff2
4 changed files with 64 additions and 34 deletions

View File

@@ -558,6 +558,10 @@ BOOL rdp_recv_deactivate_all(rdpRdp* rdp, wStream* s)
{
if (!rdp_finalize_set_flag(rdp, FINALIZE_DEACTIVATE_REACTIVATE))
return FALSE;
rdp->was_deactivated = TRUE;
rdp->deactivated_height = freerdp_settings_get_uint32(rdp->settings, FreeRDP_DesktopHeight);
rdp->deactivated_width = freerdp_settings_get_uint32(rdp->settings, FreeRDP_DesktopWidth);
}
/*
@@ -675,6 +679,8 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s)
GrantId, ControlId);
return FALSE;
}
if (!rdp_send_server_control_granted_pdu(rdp))
return FALSE;
return rdp_finalize_set_flag(rdp, FINALIZE_CS_CONTROL_REQUEST_PDU);
case CTRLACTION_COOPERATE:
if (!rdp_finalize_is_flag_set(rdp, FINALIZE_CS_SYNCHRONIZE_PDU))

View File

@@ -1124,11 +1124,11 @@ int rdp_client_connect_license(rdpRdp* rdp, wStream* s)
int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s)
{
size_t pos;
UINT16 width;
UINT16 height;
UINT16 length;
width = rdp->settings->DesktopWidth;
height = rdp->settings->DesktopHeight;
WINPR_ASSERT(rdp);
WINPR_ASSERT(s);
WINPR_ASSERT(rdp->settings);
pos = Stream_GetPosition(s);
@@ -1152,36 +1152,7 @@ int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s)
return rc;
}
if (freerdp_shall_disconnect_context(rdp->context))
return 0;
if (!rdp_send_confirm_active(rdp))
return -1;
if (!input_register_client_callbacks(rdp->input))
{
WLog_ERR(TAG, "error registering client callbacks");
return -1;
}
/**
* The server may request a different desktop size during Deactivation-Reactivation sequence.
* In this case, the UI should be informed and do actual window resizing at this point.
*/
if (width != rdp->settings->DesktopWidth || height != rdp->settings->DesktopHeight)
{
BOOL status = TRUE;
IFCALLRET(rdp->update->DesktopResize, status, rdp->update->context);
if (!status)
{
WLog_ERR(TAG, "client desktop resize callback failed");
return -1;
}
}
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION);
return rdp_client_connect_finalize(rdp);
return rdp_client_connect_confirm_active(rdp, s);
}
int rdp_client_connect_finalize(rdpRdp* rdp)
@@ -1666,3 +1637,50 @@ BOOL rdp_channels_from_mcs(rdpSettings* settings, const rdpRdp* rdp)
return TRUE;
}
int rdp_client_connect_confirm_active(rdpRdp* rdp, wStream* s)
{
WINPR_ASSERT(rdp);
WINPR_ASSERT(rdp->settings);
WINPR_ASSERT(s);
const UINT32 width = rdp->settings->DesktopWidth;
const UINT32 height = rdp->settings->DesktopHeight;
if (!rdp_send_confirm_active(rdp))
return -1;
if (!input_register_client_callbacks(rdp->input))
{
WLog_ERR(TAG, "error registering client callbacks");
return -1;
}
/**
* The server may request a different desktop size during Deactivation-Reactivation sequence.
* In this case, the UI should be informed and do actual window resizing at this point.
*/
const BOOL deactivate_reactivate =
rdp->was_deactivated && ((rdp->deactivated_width != rdp->settings->DesktopWidth) ||
(rdp->deactivated_height != rdp->settings->DesktopHeight));
const BOOL resolution_change =
((width != rdp->settings->DesktopWidth) || (height != rdp->settings->DesktopHeight));
if (deactivate_reactivate || resolution_change)
{
BOOL status = TRUE;
IFCALLRET(rdp->update->DesktopResize, status, rdp->update->context);
if (!status)
{
WLog_ERR(TAG, "client desktop resize callback failed");
return -1;
}
}
WINPR_ASSERT(rdp->context);
if (freerdp_shall_disconnect_context(rdp->context))
return 0;
rdp_client_transition_to_state(rdp, CONNECTION_STATE_FINALIZATION);
return rdp_client_connect_finalize(rdp);
}

View File

@@ -46,6 +46,7 @@ FREERDP_LOCAL BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStr
FREERDP_LOCAL BOOL rdp_client_connect_auto_detect(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_license(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_demand_active(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_connect_confirm_active(rdpRdp* rdp, wStream* s);
FREERDP_LOCAL int rdp_client_transition_to_state(rdpRdp* rdp, CONNECTION_STATE state);
FREERDP_LOCAL CONNECTION_STATE rdp_get_state(const rdpRdp* rdp);

View File

@@ -201,7 +201,12 @@ struct rdp_rdp
rdpTransportIo* io;
void* ioContext;
HANDLE abortEvent;
wPubSub* pubSub;
BOOL was_deactivated;
UINT32 deactivated_width;
UINT32 deactivated_height;
};
FREERDP_LOCAL BOOL rdp_read_security_header(wStream* s, UINT16* flags, UINT16* length);