From e15636a610d462d4336c2535308a532d38205aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Tue, 8 Oct 2013 15:03:05 -0400 Subject: [PATCH] code cleanup: move coord conversion from individual mouse events to function mf_scale_mouse_event --- client/Mac/MRDPView.m | 21 +-------------------- client/Mac/mf_client.m | 10 +++++++--- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 4a02dbcb1..0e64d51cd 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -334,8 +334,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_MOVE, x, y); } @@ -354,8 +352,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); } @@ -374,8 +370,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_BUTTON1, x, y); } @@ -394,8 +388,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); } @@ -414,8 +406,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_BUTTON2, x, y); } @@ -434,8 +424,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); } @@ -454,8 +442,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - mf_scale_mouse_event(context, instance->input, PTR_FLAGS_BUTTON3, x, y); } @@ -471,8 +457,6 @@ DWORD mac_client_thread(void* param) NSPoint loc = [event locationInWindow]; int x = (int) loc.x; int y = (int) loc.y; - - y = [self frame].size.height - y; flags = PTR_FLAGS_WHEEL; @@ -506,8 +490,6 @@ DWORD mac_client_thread(void* param) int x = (int) loc.x; int y = (int) loc.y; - y = [self frame].size.height - y; - // send mouse motion event to RDP server mf_scale_mouse_event(context, instance->input, PTR_FLAGS_MOVE, x, y); } @@ -679,7 +661,6 @@ DWORD mac_client_thread(void* param) { int i; - for (i = 0; i < argc; i++) { if (argv[i]) @@ -1472,7 +1453,7 @@ void cliprdr_send_supported_format_list(freerdp* instance) void windows_to_apple_cords(MRDPView* view, NSRect* r) { - r->origin.y = [view frame].size.height - (r->origin.y + r->size.height); + r->origin.y = [view frame].size.height - (r->origin.y + r->size.height); } diff --git a/client/Mac/mf_client.m b/client/Mac/mf_client.m index 2d75b3a7b..f6b6d8dcf 100755 --- a/client/Mac/mf_client.m +++ b/client/Mac/mf_client.m @@ -196,14 +196,18 @@ void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y) void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { mfContext* mfc = (mfContext*) context; + MRDPView* view = (MRDPView*) mfc->view; int ww, wh, dw, dh; - ww = mfc->client_width; - wh = mfc->client_height; - dw = mfc->context.settings->DesktopWidth; + ww = mfc->client_width; + wh = mfc->client_height; + dw = mfc->context.settings->DesktopWidth; dh = mfc->context.settings->DesktopHeight; + // Convert to windows coordinates + y = [view frame].size.height - y; + if (!mfc->context.settings->SmartSizing || ((ww == dw) && (wh == dh))) { y = y + mfc->yCurrentScroll;