From 2f9effeb64e00325c6d0978c48f2c820021bb414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 11 Nov 2015 15:26:03 +0100 Subject: Fix OS X 10.11 (Xcode 7.1) build issues due to strongly typed enums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple changed some enums in the 10.11 SDK from being just: enum { ... }; typedef uint64_t Foo; to: typedef CF_ENUM(uint64_t, Foo) { ... }; which in C++11 mode expands to: typedef enum Foo : uint64_t Foo; enum Foo : uint64_t { ... }; The use of strongly typed enums means we need to explicitly cast from int in the places where we know what we are doing. Change-Id: I7c8cfdbc0549471a3292de14d8b766fe17133e25 Reviewed-by: Simon Hausmann Reviewed-by: Tor Arne Vestbø --- .../other/macnativeevents/qnativeevents_mac.cpp | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'tests/auto/other/macnativeevents') diff --git a/tests/auto/other/macnativeevents/qnativeevents_mac.cpp b/tests/auto/other/macnativeevents/qnativeevents_mac.cpp index 6053a649a1..d3b50a5405 100644 --- a/tests/auto/other/macnativeevents/qnativeevents_mac.cpp +++ b/tests/auto/other/macnativeevents/qnativeevents_mac.cpp @@ -56,15 +56,15 @@ static Qt::KeyboardModifiers getModifiersFromQuartzEvent(CGEventRef inEvent) static void setModifiersFromQNativeEvent(CGEventRef inEvent, const QNativeEvent &event) { - CGEventFlags flags = 0; + CGEventFlags flags = CGEventFlags(0); if (event.modifiers.testFlag(Qt::ShiftModifier)) - flags |= kCGEventFlagMaskShift; + flags = CGEventFlags(flags | kCGEventFlagMaskShift); if (event.modifiers.testFlag(Qt::ControlModifier)) - flags |= kCGEventFlagMaskControl; + flags = CGEventFlags(flags | kCGEventFlagMaskControl); if (event.modifiers.testFlag(Qt::AltModifier)) - flags |= kCGEventFlagMaskAlternate; + flags = CGEventFlags(flags | kCGEventFlagMaskAlternate); if (event.modifiers.testFlag(Qt::MetaModifier)) - flags |= kCGEventFlagMaskCommand; + flags = CGEventFlags(flags | kCGEventFlagMaskCommand); CGEventSetFlags(inEvent, flags); } @@ -240,7 +240,7 @@ Qt::Native::Status sendNativeMouseMoveEvent_Quartz(const QNativeMouseMoveEvent & pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); - CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); + CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, kCGMouseButtonLeft /* ignored */); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); @@ -253,7 +253,7 @@ Qt::Native::Status sendNativeMouseButtonEvent_Quartz(const QNativeMouseButtonEve pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); - CGEventType type = 0; + CGEventType type = kCGEventNull; if (event.button == Qt::LeftButton) type = (event.clickCount > 0) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp; else if (event.button == Qt::RightButton) @@ -261,7 +261,12 @@ Qt::Native::Status sendNativeMouseButtonEvent_Quartz(const QNativeMouseButtonEve else type = (event.clickCount > 0) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp; - CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button); + // The mouseButton argument to CGEventCreateMouseEvent() is ignored unless the type + // is kCGEventOtherSomething, so defaulting to kCGMouseButtonLeft is fine. + CGMouseButton mouseButton = (type == kCGEventOtherMouseDown || type == kCGEventOtherMouseUp) ? + kCGMouseButtonCenter : kCGMouseButtonLeft; + + CGEventRef e = CGEventCreateMouseEvent(0, type, pos, mouseButton); setModifiersFromQNativeEvent(e, event); CGEventSetIntegerValueField(e, kCGMouseEventClickState, event.clickCount); CGEventPost(kCGHIDEventTap, e); @@ -275,7 +280,7 @@ Qt::Native::Status sendNativeMouseDragEvent_Quartz(const QNativeMouseDragEvent & pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); - CGEventType type = 0; + CGEventType type = kCGEventNull; if (event.button == Qt::LeftButton) type = kCGEventLeftMouseDragged; else if (event.button == Qt::RightButton) @@ -283,7 +288,11 @@ Qt::Native::Status sendNativeMouseDragEvent_Quartz(const QNativeMouseDragEvent & else type = kCGEventOtherMouseDragged; - CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button); + // The mouseButton argument to CGEventCreateMouseEvent() is ignored unless the type + // is kCGEventOtherSomething, so defaulting to kCGMouseButtonLeft is fine. + CGMouseButton mouseButton = type == kCGEventOtherMouseDragged ? kCGMouseButtonCenter : kCGMouseButtonLeft; + + CGEventRef e = CGEventCreateMouseEvent(0, type, pos, mouseButton); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); -- cgit v1.2.3