11@implementation QNSView (Gestures)
13- (
bool)handleGestureAsBeginEnd:(NSEvent *)event
15 if ([event phase] == NSEventPhaseBegan) {
16 [self beginGestureWithEvent:event];
20 if ([event phase] == NSEventPhaseEnded) {
21 [self endGestureWithEvent:event];
27- (
void)magnifyWithEvent:(NSEvent *)event
29 if (!m_platformWindow)
32 if ([self handleGestureAsBeginEnd:event])
35 qCDebug(lcQpaGestures) <<
"magnifyWithEvent" << [event magnification] <<
"from device" << Qt::hex << [event deviceID];
36 const NSTimeInterval timestamp = [event timestamp];
39 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
40 QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp,
41 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
42 Qt::ZoomNativeGesture, [event magnification], windowPoint, screenPoint);
45- (
void)smartMagnifyWithEvent:(NSEvent *)event
47 if (!m_platformWindow)
50 static bool zoomIn =
true;
51 qCDebug(lcQpaGestures) <<
"smartMagnifyWithEvent" << zoomIn <<
"from device" << Qt::hex << [event deviceID];
52 const NSTimeInterval timestamp = [event timestamp];
55 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
56 QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp,
57 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
58 Qt::SmartZoomNativeGesture, zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
62- (
void)rotateWithEvent:(NSEvent *)event
64 if (!m_platformWindow)
67 if ([self handleGestureAsBeginEnd:event])
70 const NSTimeInterval timestamp = [event timestamp];
73 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
74 QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp,
75 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
76 Qt::RotateNativeGesture, -[event rotation], windowPoint, screenPoint);
79- (
void)swipeWithEvent:(NSEvent *)event
81 if (!m_platformWindow)
84 qCDebug(lcQpaGestures) <<
"swipeWithEvent" << [event deltaX] << [event deltaY] <<
"from device" << Qt::hex << [event deviceID];
85 const NSTimeInterval timestamp = [event timestamp];
88 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
91 if ([event deltaX] == 1)
93 else if ([event deltaX] == -1)
95 else if ([event deltaY] == 1)
97 else if ([event deltaY] == -1)
100 QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp,
101 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
102 Qt::SwipeNativeGesture, angle, windowPoint, screenPoint, 3);
105- (
void)beginGestureWithEvent:(NSEvent *)event
107 if (!m_platformWindow)
110 const NSTimeInterval timestamp = [event timestamp];
113 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
114 qCDebug(lcQpaGestures) <<
"beginGestureWithEvent @" << windowPoint <<
"from device" << Qt::hex << [event deviceID];
115 QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp,
116 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
117 Qt::BeginNativeGesture, windowPoint, screenPoint);
120- (
void)endGestureWithEvent:(NSEvent *)event
122 if (!m_platformWindow)
125 qCDebug(lcQpaGestures) <<
"endGestureWithEvent" <<
"from device" << Qt::hex << [event deviceID];
126 const NSTimeInterval timestamp = [event timestamp];
129 [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
130 QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp,
131 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
132 Qt::EndNativeGesture, windowPoint, screenPoint);
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")