diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-18 09:01:51 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-18 09:01:51 +0100 |
commit | c7934f2489e2eb9a539206bab35f335b1943c5bd (patch) | |
tree | a27d0ed6c001fe9432e2a0f28fb935acf9e4c65f /tests/auto/other/macnativeevents | |
parent | f40593b11199fbef886bfcb6b210a214d8c3adf3 (diff) | |
parent | 08f9a1bd6ab9b1777ee5ba163d75e5c848c39eb4 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/corelib/io/qprocess.cpp
src/corelib/io/qprocess_unix.cpp
src/network/kernel/qnetworkinterface_winrt.cpp
tools/configure/configureapp.cpp
Change-Id: I47df00a01597d2e63b334b492b3b4221b29f58ea
Diffstat (limited to 'tests/auto/other/macnativeevents')
-rw-r--r-- | tests/auto/other/macnativeevents/qnativeevents_mac.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
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); |