Qt::Native::Status sendNativeMouseButtonEvent_Quartz(const QNativeMouseButtonEvent &event) { CGPoint pos; pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); CGEventType type = kCGEventNull; if (event.button == Qt::LeftButton) type = (event.clickCount > 0) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp; else if (event.button == Qt::RightButton) type = (event.clickCount > 0) ? kCGEventRightMouseDown : kCGEventRightMouseUp; else type = (event.clickCount > 0) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp; // 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); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeKeyEvent_Quartz(const QNativeKeyEvent &event) { CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeMouseMoveEvent_Quartz(const QNativeMouseMoveEvent &event) { CGPoint pos; pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeKeyEventToProcess_Quartz(const QNativeKeyEvent &event, int pid) { ProcessSerialNumber psn; GetProcessForPID(pid, &psn); CGEventRef e = CGEventCreateKeyboardEvent(0, (uint)event.nativeKeyCode, event.press); setModifiersFromQNativeEvent(e, event); SetFrontProcess(&psn); CGEventPostToPSN(&psn, e); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeMouseWheelEvent_Quartz(const QNativeMouseWheelEvent &event) { CGPoint pos; pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); CGEventRef e = CGEventCreateScrollWheelEvent(0, kCGScrollEventUnitPixel, 1, 0); CGEventSetIntegerValueField(e, kCGScrollWheelEventDeltaAxis1, event.delta); CGEventSetLocation(e, pos); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeMouseDragEvent_Quartz(const QNativeMouseDragEvent &event) { CGPoint pos; pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); CGEventType type = 0; if (event.button == Qt::LeftButton) type = kCGEventLeftMouseDragged; else if (event.button == Qt::RightButton) type = kCGEventRightMouseDragged; else type = kCGEventOtherMouseDragged; CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button); setModifiersFromQNativeEvent(e, event); CGEventPost(kCGHIDEventTap, e); CFRelease(e); return Qt::Native::Success; }
Qt::Native::Status sendNativeMouseButtonEvent_Quartz(const QNativeMouseButtonEvent &event) { CGPoint pos; pos.x = event.globalPos.x(); pos.y = event.globalPos.y(); CGEventType type = 0; if (event.button == Qt::LeftButton) type = (event.clickCount > 0) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp; else if (event.button == Qt::RightButton) type = (event.clickCount > 0) ? kCGEventRightMouseDown : kCGEventRightMouseUp; else type = (event.clickCount > 0) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp; CGEventRef e = CGEventCreateMouseEvent(0, type, pos, event.button); setModifiersFromQNativeEvent(e, event); CGEventSetIntegerValueField(e, kCGMouseEventClickState, event.clickCount); CGEventPost(kCGHIDEventTap, e); CFRelease(e); return Qt::Native::Success; }