Merge pull request #5416 from m4ntis/proxy/multimon

Add multimon support to proxy server
This commit is contained in:
David Fort 2019-06-03 15:20:14 +02:00 committed by GitHub
commit 2b84ed8681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 226 additions and 37 deletions

36
include/freerdp/display.h Normal file
View 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 */

View File

@ -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})

View File

@ -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
View 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
View 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 */

View File

@ -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;

View File

@ -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);

View File

@ -37,10 +37,10 @@
#include <freerdp/client/cliprdr.h>
#include <freerdp/client/channels.h>
#include <freerdp/channels/channels.h>
#include <freerdp/log.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <freerdp/log.h>
#include "pf_channels.h"
#include "pf_gdi.h"
@ -82,7 +82,6 @@ static void pf_OnErrorInfo(void* ctx, ErrorInfoEventArgs* e)
}
}
/**
* Called before a connection is established.
*

View File

@ -51,6 +51,7 @@ void pf_common_copy_settings(rdpSettings* dst, rdpSettings* src)
dst->DesktopOrientation = src->DesktopOrientation;
dst->DesktopScaleFactor = src->DesktopScaleFactor;
dst->DeviceScaleFactor = src->DeviceScaleFactor;
dst->SupportMonitorLayoutPdu = src->SupportMonitorLayoutPdu;
/* client info */
dst->AutoLogonEnabled = src->AutoLogonEnabled;
dst->CompressionEnabled = src->CompressionEnabled;

View File

@ -77,5 +77,45 @@ rdpContext* p_client_context_create(rdpSettings* clientSettings,
settings->ServerPort = port;
settings->SoftwareGdi = FALSE;
settings->RedirectClipboard = FALSE;
/* Client Monitor Data */
settings->MonitorCount = clientSettings->MonitorCount;
settings->SpanMonitors = clientSettings->SpanMonitors;
settings->UseMultimon = clientSettings->UseMultimon;
settings->ForceMultimon = clientSettings->ForceMultimon;
settings->DesktopPosX = clientSettings->DesktopPosX;
settings->DesktopPosY = clientSettings->DesktopPosY;
settings->ListMonitors = clientSettings->ListMonitors;
settings->NumMonitorIds = clientSettings->NumMonitorIds;
settings->MonitorLocalShiftX = clientSettings->MonitorLocalShiftX;
settings->MonitorLocalShiftY = clientSettings->MonitorLocalShiftY;
settings->HasMonitorAttributes = clientSettings->HasMonitorAttributes;
settings->MonitorCount = clientSettings->MonitorCount;
settings->MonitorDefArraySize = clientSettings->MonitorDefArraySize;
if (clientSettings->MonitorDefArraySize > 0)
{
settings->MonitorDefArray = (rdpMonitor*) calloc(clientSettings->MonitorDefArraySize,
sizeof(rdpMonitor));
if (!settings->MonitorDefArray)
{
goto error;
}
CopyMemory(settings->MonitorDefArray, clientSettings->MonitorDefArray,
sizeof(rdpMonitor) * clientSettings->MonitorDefArraySize);
}
else
settings->MonitorDefArray = NULL;
settings->MonitorIds = (UINT32*) calloc(16, sizeof(UINT32));
if (!settings->MonitorIds)
goto error;
CopyMemory(settings->MonitorIds, clientSettings->MonitorIds, 16 * sizeof(UINT32));
return context;
error:
freerdp_client_context_free(context);
return NULL;
}

View File

@ -180,6 +180,12 @@ static BOOL pf_server_activate(freerdp_peer* client)
return TRUE;
}
static BOOL pf_server_adjust_monitor_layout(freerdp_peer* peer)
{
/* proxy as is, there's no need to do anything here */
return TRUE;
}
/**
* Handles an incoming client connection, to be run in it's own thread.
*
@ -232,8 +238,11 @@ static DWORD WINAPI pf_server_handle_client(LPVOID arg)
client->settings->ColorDepth = 32;
client->settings->SuppressOutput = TRUE;
client->settings->RefreshRect = TRUE;
client->settings->UseMultimon = TRUE;
client->settings->SupportMonitorLayoutPdu = TRUE;
client->PostConnect = pf_server_post_connect;
client->Activate = pf_server_activate;
client->AdjustMonitorsLayout = pf_server_adjust_monitor_layout;
pf_server_register_input_callbacks(client->input);
pf_server_register_update_callbacks(client->update);
client->settings->MultifragMaxRequestSize = 0xFFFFFF; /* FIXME */

View File

@ -19,6 +19,8 @@
* limitations under the License.
*/
#include <freerdp/update.h>
#include "pf_update.h"
#include "pf_context.h"
@ -83,6 +85,15 @@ static BOOL pf_client_desktop_resize(rdpContext* context)
return ps->update->DesktopResize(ps);
}
static BOOL pf_client_remote_monitors(rdpContext* context, UINT32 count,
const MONITOR_DEF* monitors)
{
pClientContext* pc = (pClientContext*) context;
proxyData* pdata = pc->pdata;
rdpContext* ps = (rdpContext*)pdata->ps;
return freerdp_display_send_monitor_layout(ps, count, monitors);
}
static BOOL pf_client_send_pointer_system(rdpContext* context,
const POINTER_SYSTEM_UPDATE* pointer_system)
{
@ -134,6 +145,7 @@ void pf_client_register_update_callbacks(rdpUpdate* update)
update->EndPaint = pf_client_end_paint;
update->BitmapUpdate = pf_client_bitmap_update;
update->DesktopResize = pf_client_desktop_resize;
update->RemoteMonitors = pf_client_remote_monitors;
update->pointer->PointerSystem = pf_client_send_pointer_system;
update->pointer->PointerPosition = pf_client_send_pointer_position;