20 #include <freerdp/config.h>
24 #include <winpr/assert.h>
26 #include <freerdp/constants.h>
27 #include <freerdp/utils/signal.h>
28 #include <freerdp/client/cmdline.h>
36 static BOOL mfreerdp_client_global_init(
void)
38 freerdp_handle_signals();
42 static void mfreerdp_client_global_uninit(
void)
46 static int mfreerdp_client_start(rdpContext *context)
51 if (mfc->view == NULL)
55 initWithFrame:NSMakeRect(
57 freerdp_settings_get_uint32(context->settings, FreeRDP_DesktopWidth),
58 freerdp_settings_get_uint32(context->settings,
59 FreeRDP_DesktopHeight))];
60 mfc->view_ownership = TRUE;
64 return [view rdpStart:context];
67 static int mfreerdp_client_stop(rdpContext *context)
71 freerdp_client_common_stop(context);
73 if (mfc->view_ownership)
76 [view releaseResources];
84 static BOOL mfreerdp_client_new(freerdp *instance, rdpContext *context)
88 WINPR_ASSERT(instance);
93 mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
96 context->instance->PreConnect = mac_pre_connect;
97 context->instance->PostConnect = mac_post_connect;
98 context->instance->PostDisconnect = mac_post_disconnect;
99 context->instance->AuthenticateEx = mac_authenticate_ex;
100 context->instance->VerifyCertificateEx = mac_verify_certificate_ex;
101 context->instance->VerifyChangedCertificateEx = mac_verify_changed_certificate_ex;
102 context->instance->LogonErrorInfo = mac_logon_error_info;
106 static void mfreerdp_client_free(freerdp *instance, rdpContext *context)
110 if (!instance || !context)
114 (
void)CloseHandle(mfc->stopEvent);
117 static void mf_scale_mouse_coordinates(
mfContext *mfc, UINT16 *px, UINT16 *py)
121 UINT32 ww = mfc->client_width;
122 UINT32 wh = mfc->client_height;
127 ((ww == dw) && (wh == dh)))
129 y = y + mfc->yCurrentScroll;
130 x = x + mfc->xCurrentScroll;
137 y = y * dh / wh + mfc->yCurrentScroll;
138 x = x * dw / ww + mfc->xCurrentScroll;
145 void mf_scale_mouse_event(
void *context, UINT16 flags, UINT16 x, UINT16 y)
150 y = [view frame].size.height - y;
152 if ((flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL)) == 0)
153 mf_scale_mouse_coordinates(mfc, &x, &y);
154 freerdp_client_send_button_event(&mfc->common, FALSE, flags, x, y);
157 void mf_scale_mouse_event_ex(
void *context, UINT16 flags, UINT16 x, UINT16 y)
162 y = [view frame].size.height - y;
164 mf_scale_mouse_coordinates(mfc, &x, &y);
165 freerdp_client_send_extended_button_event(&mfc->common, FALSE, flags, x, y);
168 void mf_press_mouse_button(
void *context,
int button,
int x,
int y, BOOL down)
175 flags |= PTR_FLAGS_DOWN;
176 xflags |= PTR_XFLAGS_DOWN;
182 mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON1, x, y);
186 mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON2, x, y);
190 mf_scale_mouse_event(context, flags | PTR_FLAGS_BUTTON3, x, y);
194 mf_scale_mouse_event_ex(context, xflags | PTR_XFLAGS_BUTTON1, x, y);
198 mf_scale_mouse_event_ex(context, xflags | PTR_XFLAGS_BUTTON2, x, y);
206 int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS *pEntryPoints)
208 WINPR_ASSERT(pEntryPoints);
210 pEntryPoints->Version = 1;
211 pEntryPoints->Size =
sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
212 pEntryPoints->GlobalInit = mfreerdp_client_global_init;
213 pEntryPoints->GlobalUninit = mfreerdp_client_global_uninit;
214 pEntryPoints->ContextSize =
sizeof(
mfContext);
215 pEntryPoints->ClientNew = mfreerdp_client_new;
216 pEntryPoints->ClientFree = mfreerdp_client_free;
217 pEntryPoints->ClientStart = mfreerdp_client_start;
218 pEntryPoints->ClientStop = mfreerdp_client_stop;
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.