Fixed shadow server mouse wheel mapping on MacOS

This commit is contained in:
Armin Novak 2017-06-13 14:18:11 +02:00
parent 1dbd2d28d9
commit 6142da9cb8

View File

@ -367,24 +367,25 @@ void mf_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{ {
float width, height; float width, height;
CGWheelCount wheelCount = 2; CGWheelCount wheelCount = 2;
UINT32 scroll_x = 0; INT32 scroll_x = 0;
UINT32 scroll_y = 0; INT32 scroll_y = 0;
if (flags & PTR_FLAGS_WHEEL) if (flags & (PTR_FLAGS_WHEEL | PTR_FLAGS_HWHEEL))
{ {
scroll_y = flags & WheelRotationMask; INT32 scroll = flags & WheelRotationMask;
if (flags & PTR_FLAGS_WHEEL_NEGATIVE) if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
{ scroll = -(flags & WheelRotationMask) / 392;
scroll_y = -(flags & WheelRotationMask) / 392;
}
else else
{ scroll = (flags & WheelRotationMask) / 120;
scroll_y = (flags & WheelRotationMask) / 120;
} if (flags & PTR_FLAGS_WHEEL)
scroll_y = scroll;
else
scroll_x = scroll;
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState); CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
CGEventRef scroll = CGEventCreateScrollWheelEvent(source, CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
kCGScrollEventUnitLine, kCGScrollEventUnitLine,
@ -392,21 +393,21 @@ void mf_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
scroll_y, scroll_y,
scroll_x); scroll_x);
CGEventPost(kCGHIDEventTap, scroll); CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll); CFRelease(scroll);
CFRelease(source); CFRelease(source);
} }
else else
{ {
mfInfo * mfi; mfInfo * mfi;
CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState); CGEventSourceRef source = CGEventSourceCreate (kCGEventSourceStateHIDSystemState);
CGEventType mouseType = kCGEventNull; CGEventType mouseType = kCGEventNull;
CGMouseButton mouseButton = kCGMouseButtonLeft; CGMouseButton mouseButton = kCGMouseButtonLeft;
mfi = mf_info_get_instance(); mfi = mf_info_get_instance();
//width and height of primary screen (even in multimon setups //width and height of primary screen (even in multimon setups
width = (float) mfi->servscreen_width; width = (float) mfi->servscreen_width;
height = (float) mfi->servscreen_height; height = (float) mfi->servscreen_height;