Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnsview_touch.mm
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5// This file is included from qnsview.mm, and only used to organize the code
6
7Q_STATIC_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
8
9@implementation QNSView (Touch)
10
11- (bool)shouldSendSingleTouch
12{
13 if (!m_platformWindow)
14 return true;
15
16 // QtWidgets expects single-point touch events, QtDeclarative does not.
17 // Until there is an API we solve this by looking at the window class type.
18 return m_platformWindow->window()->inherits("QWidgetWindow");
19}
20
21- (void)touchesBeganWithEvent:(NSEvent *)event
22{
23 if (!m_platformWindow)
24 return;
25
26 const NSTimeInterval timestamp = [event timestamp];
27 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
28 qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << Qt::hex << [event deviceID];
29 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
30 m_platformWindow->window(), timestamp * 1000,
31 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
32 points);
33}
34
35- (void)touchesMovedWithEvent:(NSEvent *)event
36{
37 if (!m_platformWindow)
38 return;
39
40 const NSTimeInterval timestamp = [event timestamp];
41
42 QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
43 nativeDrag->setLastInputEvent(event, self);
44
45 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
46 qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
47 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
48 m_platformWindow->window(), timestamp * 1000,
49 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
50 points);
51}
52
53- (void)touchesEndedWithEvent:(NSEvent *)event
54{
55 if (!m_platformWindow)
56 return;
57
58 const NSTimeInterval timestamp = [event timestamp];
59
60 QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
61 nativeDrag->setLastInputEvent(event, self);
62
63 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
64 qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
65 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
66 m_platformWindow->window(), timestamp * 1000,
67 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
68 points);
69}
70
71- (void)touchesCancelledWithEvent:(NSEvent *)event
72{
73 if (!m_platformWindow)
74 return;
75
76 const NSTimeInterval timestamp = [event timestamp];
77
78 QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
79 nativeDrag->setLastInputEvent(event, self);
80
81 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
82 qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << Qt::hex << [event deviceID];
83 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
84 m_platformWindow->window(), timestamp * 1000,
85 QCocoaTouch::getTouchDevice(QInputDevice::DeviceType::TouchPad, [event deviceID]),
86 points);
87}
88
89@end
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")