2019-05-20 14:05:32 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Display update notifications
|
|
|
|
*
|
|
|
|
* Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "display.h"
|
|
|
|
|
2019-11-20 13:30:14 +03:00
|
|
|
static BOOL display_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
|
|
|
|
const MONITOR_DEF* monitorDefArray)
|
2019-05-20 14:05:32 +03:00
|
|
|
{
|
|
|
|
if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 index = 0; index < monitorCount; index++)
|
2019-05-20 14:05:32 +03:00
|
|
|
{
|
2022-04-19 15:29:17 +03:00
|
|
|
const MONITOR_DEF* monitor = &monitorDefArray[index];
|
|
|
|
|
2022-06-23 08:57:38 +03:00
|
|
|
Stream_Write_INT32(s, monitor->left); /* left (4 bytes) */
|
|
|
|
Stream_Write_INT32(s, monitor->top); /* top (4 bytes) */
|
|
|
|
Stream_Write_INT32(s, monitor->right); /* right (4 bytes) */
|
|
|
|
Stream_Write_INT32(s, monitor->bottom); /* bottom (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
|
2019-05-20 14:05:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount,
|
2019-11-06 17:24:51 +03:00
|
|
|
const rdpMonitor* monitorDefArray,
|
|
|
|
MONITOR_DEF** result)
|
2019-05-20 14:05:32 +03:00
|
|
|
{
|
2022-04-28 09:00:39 +03:00
|
|
|
MONITOR_DEF* mdef = NULL;
|
2019-05-20 14:05:32 +03:00
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
if (!monitorDefArray || !result || (*result))
|
2019-05-20 14:05:32 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
mdef = (MONITOR_DEF*)calloc(monitorCount, sizeof(MONITOR_DEF));
|
|
|
|
|
|
|
|
if (!mdef)
|
|
|
|
return FALSE;
|
|
|
|
|
2024-01-30 12:25:38 +03:00
|
|
|
for (UINT32 index = 0; index < monitorCount; index++)
|
2019-05-20 14:05:32 +03:00
|
|
|
{
|
2022-04-28 09:00:39 +03:00
|
|
|
const rdpMonitor* monitor = &monitorDefArray[index];
|
|
|
|
MONITOR_DEF* current = &mdef[index];
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
current->left = monitor->x; /* left (4 bytes) */
|
|
|
|
current->top = monitor->y; /* top (4 bytes) */
|
|
|
|
current->right = monitor->x + monitor->width - 1; /* right (4 bytes) */
|
|
|
|
current->bottom = monitor->y + monitor->height - 1; /* bottom (4 bytes) */
|
2019-05-20 14:05:32 +03:00
|
|
|
current->flags = monitor->is_primary ? MONITOR_PRIMARY : 0x0; /* flags (4 bytes) */
|
|
|
|
}
|
|
|
|
|
2022-04-28 09:00:39 +03:00
|
|
|
*result = mdef;
|
2019-05-20 14:05:32 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL freerdp_display_send_monitor_layout(rdpContext* context, UINT32 monitorCount,
|
2019-11-06 17:24:51 +03:00
|
|
|
const MONITOR_DEF* monitorDefArray)
|
2019-05-20 14:05:32 +03:00
|
|
|
{
|
|
|
|
rdpRdp* rdp = context->rdp;
|
|
|
|
wStream* st = rdp_data_pdu_init(rdp);
|
|
|
|
|
|
|
|
if (!st)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!display_write_monitor_layout_pdu(st, monitorCount, monitorDefArray))
|
|
|
|
{
|
|
|
|
Stream_Release(st);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rdp_send_data_pdu(rdp, st, DATA_PDU_TYPE_MONITOR_LAYOUT, 0);
|
|
|
|
}
|