Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4// This file is included from qnsview.mm, and only used to organize the code
5
6Q_LOGGING_CATEGORY(lcQpaTouch, "qt.qpa.input.touch")
7
8@implementation QNSView (Touch)
9
10- (bool)shouldSendSingleTouch
11{
12 if (!m_platformWindow)
13 return true;
14
15 // QtWidgets expects single-point touch events, QtDeclarative does not.
16 // Until there is an API we solve this by looking at the window class type.
17 return m_platformWindow->window()->inherits("QWidgetWindow");
18}
19
20- (void)touchesBeganWithEvent:(NSEvent *)event
21{
22 if (!m_platformWindow)
23 return;
24
25 const NSTimeInterval timestamp = [event timestamp];
26 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
27 qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << Qt::hex << [event deviceID];
28 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
29 m_platformWindow->window(), timestamp * 1000,
31 points);
32}
33
34- (void)touchesMovedWithEvent:(NSEvent *)event
35{
36 if (!m_platformWindow)
37 return;
38
39 const NSTimeInterval timestamp = [event timestamp];
40 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
41 qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
42 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
43 m_platformWindow->window(), timestamp * 1000,
45 points);
46}
47
48- (void)touchesEndedWithEvent:(NSEvent *)event
49{
50 if (!m_platformWindow)
51 return;
52
53 const NSTimeInterval timestamp = [event timestamp];
54 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
55 qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << Qt::hex << [event deviceID];
56 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
57 m_platformWindow->window(), timestamp * 1000,
59 points);
60}
61
62- (void)touchesCancelledWithEvent:(NSEvent *)event
63{
64 if (!m_platformWindow)
65 return;
66
67 const NSTimeInterval timestamp = [event timestamp];
68 const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
69 qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << Qt::hex << [event deviceID];
70 QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(
71 m_platformWindow->window(), timestamp * 1000,
73 points);
74}
75
76@end
static QList< QWindowSystemInterface::TouchPoint > getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch)
static QPointingDevice * getTouchDevice(QInputDevice::DeviceType type, quint64 id)
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points