FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
display.c
1
20#include "display.h"
21
22static BOOL display_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount,
23 const MONITOR_DEF* monitorDefArray)
24{
25 if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20)))
26 return FALSE;
27
28 Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */
29
30 for (UINT32 index = 0; index < monitorCount; index++)
31 {
32 const MONITOR_DEF* monitor = &monitorDefArray[index];
33
34 Stream_Write_INT32(s, monitor->left); /* left (4 bytes) */
35 Stream_Write_INT32(s, monitor->top); /* top (4 bytes) */
36 Stream_Write_INT32(s, monitor->right); /* right (4 bytes) */
37 Stream_Write_INT32(s, monitor->bottom); /* bottom (4 bytes) */
38 Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
39 }
40
41 return TRUE;
42}
43
44BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount,
45 const rdpMonitor* monitorDefArray,
46 MONITOR_DEF** result)
47{
48 MONITOR_DEF* mdef = NULL;
49
50 if (!monitorDefArray || !result || (*result))
51 return FALSE;
52
53 mdef = (MONITOR_DEF*)calloc(monitorCount, sizeof(MONITOR_DEF));
54
55 if (!mdef)
56 return FALSE;
57
58 for (UINT32 index = 0; index < monitorCount; index++)
59 {
60 const rdpMonitor* monitor = &monitorDefArray[index];
61 MONITOR_DEF* current = &mdef[index];
62
63 current->left = monitor->x; /* left (4 bytes) */
64 current->top = monitor->y; /* top (4 bytes) */
65 current->right = monitor->x + monitor->width - 1; /* right (4 bytes) */
66 current->bottom = monitor->y + monitor->height - 1; /* bottom (4 bytes) */
67 current->flags = monitor->is_primary ? MONITOR_PRIMARY : 0x0; /* flags (4 bytes) */
68 }
69
70 *result = mdef;
71 return TRUE;
72}
73
74BOOL freerdp_display_send_monitor_layout(rdpContext* context, UINT32 monitorCount,
75 const MONITOR_DEF* monitorDefArray)
76{
77 rdpRdp* rdp = context->rdp;
78 UINT16 sec_flags = 0;
79 wStream* st = rdp_data_pdu_init(rdp, &sec_flags);
80
81 if (!st)
82 return FALSE;
83
84 if (!display_write_monitor_layout_pdu(st, monitorCount, monitorDefArray))
85 {
86 Stream_Release(st);
87 return FALSE;
88 }
89
90 return rdp_send_data_pdu(rdp, st, DATA_PDU_TYPE_MONITOR_LAYOUT, 0, sec_flags);
91}