FreeRDP
Loading...
Searching...
No Matches
ios_disp.m
1
20
21#include <freerdp/config.h>
22
23#include <winpr/assert.h>
24#include <winpr/wlog.h>
25
26#include <freerdp/channels/disp.h>
27#include <freerdp/client/disp.h>
28
29#include "ios_disp.h"
30
31#import "RDPSession.h"
32
33#define TAG CLIENT_TAG("ios.disp")
34
35// layouts are sent only after the server announced its limits (as xfreerdp does)
36static UINT ios_disp_caps(DispClientContext *disp, UINT32 maxNumMonitors,
37 UINT32 maxMonitorAreaFactorA, UINT32 maxMonitorAreaFactorB)
38{
39 WINPR_ASSERT(disp);
40
41 mfContext *afc = (mfContext *)disp->custom;
42 WINPR_ASSERT(afc);
43
44 afc->dispActivated = TRUE;
45
46 // the view may have resized while the channel was not ready (connecting or reconnecting)
47 [afc->mfi->session performSelectorOnMainThread:@selector(sessionDidActivateDisplayControl)
48 withObject:nil
49 waitUntilDone:NO];
50
51 WLog_DBG(TAG,
52 "DisplayControlCaps: MaxNumMonitors: %" PRIu32 " MaxMonitorAreaFactorA: %" PRIu32
53 " MaxMonitorAreaFactorB: %" PRIu32,
54 maxNumMonitors, maxMonitorAreaFactorA, maxMonitorAreaFactorB);
55 return CHANNEL_RC_OK;
56}
57
58BOOL ios_disp_init(mfContext *afc, DispClientContext *disp)
59{
60 WINPR_ASSERT(afc);
61 WINPR_ASSERT(disp);
62
63 afc->disp = disp;
64 afc->dispActivated = FALSE;
65 disp->custom = afc;
66 disp->DisplayControlCaps = ios_disp_caps;
67
68 WLog_DBG(TAG, "disp channel connected");
69 return TRUE;
70}
71
72BOOL ios_disp_uninit(mfContext *afc, DispClientContext *disp)
73{
74 WINPR_ASSERT(afc);
75 WINPR_UNUSED(disp);
76
77 afc->disp = nullptr;
78 afc->dispActivated = FALSE;
79 WLog_DBG(TAG, "disp channel disconnected");
80 return TRUE;
81}
82
83BOOL ios_disp_send_monitor_layout(mfContext *afc, UINT32 width, UINT32 height)
84{
85 WINPR_ASSERT(afc);
86
87 DispClientContext *disp = afc->disp;
88 if (!disp || !disp->SendMonitorLayout || !afc->dispActivated)
89 {
90 WLog_WARN(TAG, "disp channel not available");
91 return FALSE;
92 }
93
94 rdpSettings *settings = afc->_p.settings;
95
96 DISPLAY_CONTROL_MONITOR_LAYOUT layout = WINPR_C_ARRAY_INIT;
97 layout.Flags = DISPLAY_CONTROL_MONITOR_PRIMARY;
98 layout.Top = layout.Left = 0;
99 layout.Width = width;
100 layout.Height = height;
101 layout.PhysicalWidth = 0;
102 layout.PhysicalHeight = 0;
103 layout.Orientation = freerdp_settings_get_uint16(settings, FreeRDP_DesktopOrientation);
104 layout.DesktopScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
105 layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
106
107 UINT rc = disp->SendMonitorLayout(disp, 1, &layout);
108 if (rc != CHANNEL_RC_OK)
109 {
110 WLog_ERR(TAG, "SendMonitorLayout failed: %" PRIu32, rc);
111 return FALSE;
112 }
113
114 WLog_DBG(TAG, "SendMonitorLayout: %" PRIu32 "x%" PRIu32, width, height);
115 return TRUE;
116}
WINPR_ATTR_NODISCARD FREERDP_API UINT16 freerdp_settings_get_uint16(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id)
Returns a UINT16 settings value.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
Layout layout(float leftWidth, float leftHeight, float rightWidth, float rightHeight, float width, float margin)