mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2024-12-04 15:23:32 +08:00
libfreerdp/core: Export monitor layout PDU
* Move update notification related functions to new display.c: Not related to `rdp.c`. * Rename `rdp_write_monitor_layout_pdu` to `display_write_monitor_layout_pdu`. * Add internal `display_convert_rdp_monitor_to_monitor_def` instead of doing the conversion inside `display_write_monitor_layout_pdu`.
This commit is contained in:
parent
aa318e03ee
commit
cd135ceacb
36
include/freerdp/display.h
Normal file
36
include/freerdp/display.h
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_DISPLAY_H
|
||||
#define FREERDP_DISPLAY_H
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FREERDP_API BOOL freerdp_display_send_monitor_layout(rdpContext* context, UINT32 monitorCount,
|
||||
const MONITOR_DEF* monitorDefArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_DISPLAY_UPDATE_H */
|
@ -129,7 +129,9 @@ set(${MODULE_PREFIX}_SRCS
|
||||
listener.c
|
||||
listener.h
|
||||
peer.c
|
||||
peer.h)
|
||||
peer.h
|
||||
display.c
|
||||
display.h)
|
||||
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${${MODULE_PREFIX}_GATEWAY_SRCS})
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "activation.h"
|
||||
#include "display.h"
|
||||
|
||||
/*
|
||||
static const char* const CTRLACTION_STRINGS[] =
|
||||
@ -341,22 +342,25 @@ BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s)
|
||||
peer->AdjustMonitorsLayout(peer))
|
||||
{
|
||||
/* client supports the monitorLayout PDU, let's send him the monitors if any */
|
||||
wStream* st = rdp_data_pdu_init(rdp);
|
||||
BOOL r;
|
||||
MONITOR_DEF* monitors = (MONITOR_DEF*) calloc(settings->MonitorCount, sizeof(MONITOR_DEF));
|
||||
|
||||
if (!st)
|
||||
if (!monitors)
|
||||
return FALSE;
|
||||
|
||||
if (!rdp_write_monitor_layout_pdu(st, settings->MonitorCount, settings->MonitorDefArray))
|
||||
if (!display_convert_rdp_monitor_to_monitor_def(settings->MonitorCount, settings->MonitorDefArray,
|
||||
&monitors))
|
||||
{
|
||||
Stream_Release(st);
|
||||
free(monitors);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
r = rdp_send_data_pdu(rdp, st, DATA_PDU_TYPE_MONITOR_LAYOUT, 0);
|
||||
|
||||
if (!r)
|
||||
if (!freerdp_display_send_monitor_layout(rdp->context, settings->MonitorCount, monitors))
|
||||
{
|
||||
free(monitors);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
free(monitors);
|
||||
}
|
||||
|
||||
if (!rdp_send_server_font_map_pdu(rdp))
|
||||
|
83
libfreerdp/core/display.c
Normal file
83
libfreerdp/core/display.c
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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"
|
||||
|
||||
BOOL display_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
|
||||
const MONITOR_DEF* monitorDefArray)
|
||||
{
|
||||
UINT32 index;
|
||||
const MONITOR_DEF* monitor;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)))
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */
|
||||
|
||||
for (index = 0, monitor = monitorDefArray; index < monitorCount; index++, monitor++)
|
||||
{
|
||||
Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->bottom); /* bottom (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount,
|
||||
const rdpMonitor* monitorDefArray, MONITOR_DEF** result)
|
||||
{
|
||||
UINT32 index;
|
||||
const rdpMonitor* monitor;
|
||||
|
||||
if (!monitorDefArray || !(*result))
|
||||
return FALSE;
|
||||
|
||||
for (index = 0, monitor = monitorDefArray; index < monitorCount; index++, monitor++)
|
||||
{
|
||||
MONITOR_DEF* current = (*result + index);
|
||||
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) */
|
||||
current->flags = monitor->is_primary ? MONITOR_PRIMARY : 0x0; /* flags (4 bytes) */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_display_send_monitor_layout(rdpContext* context, UINT32 monitorCount,
|
||||
const MONITOR_DEF* monitorDefArray)
|
||||
{
|
||||
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);
|
||||
}
|
29
libfreerdp/core/display.h
Normal file
29
libfreerdp/core/display.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_LIB_CORE_DISPLAY_H
|
||||
#define FREERDP_LIB_CORE_DISPLAY_H
|
||||
|
||||
#include <freerdp/display.h>
|
||||
#include "rdp.h"
|
||||
|
||||
FREERDP_LOCAL BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount,
|
||||
const rdpMonitor* monitorDefArray, MONITOR_DEF** result);
|
||||
|
||||
#endif /* FREERDP_LIB_CORE_DISPLAY_H */
|
@ -807,29 +807,6 @@ static BOOL rdp_recv_monitor_layout_pdu(rdpRdp* rdp, wStream* s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL rdp_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
|
||||
const rdpMonitor* monitorDefArray)
|
||||
{
|
||||
UINT32 index;
|
||||
const rdpMonitor* monitor;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)))
|
||||
return FALSE;
|
||||
|
||||
Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */
|
||||
|
||||
for (index = 0, monitor = monitorDefArray; index < monitorCount; index++, monitor++)
|
||||
{
|
||||
Stream_Write_UINT32(s, monitor->x); /* left (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->y); /* top (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->x + monitor->width - 1); /* right (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->y + monitor->height - 1); /* bottom (4 bytes) */
|
||||
Stream_Write_UINT32(s, monitor->is_primary ? 0x01 : 0x00); /* flags (4 bytes) */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rdp_recv_data_pdu(rdpRdp* rdp, wStream* s)
|
||||
{
|
||||
BYTE type;
|
||||
|
@ -223,9 +223,6 @@ FREERDP_LOCAL int rdp_recv_out_of_sequence_pdu(rdpRdp* rdp, wStream* s);
|
||||
|
||||
FREERDP_LOCAL void rdp_read_flow_control_pdu(wStream* s, UINT16* type);
|
||||
|
||||
FREERDP_LOCAL BOOL rdp_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
|
||||
const rdpMonitor* monitorDefArray);
|
||||
|
||||
FREERDP_LOCAL int rdp_recv_callback(rdpTransport* transport, wStream* s,
|
||||
void* extra);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/display.h>
|
||||
#include <freerdp/gdi/gdi.h>
|
||||
#include <freerdp/utils/signal.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user