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
qwindowsysteminterface.h
Go to the documentation of this file.
1// Copyright (C) 2020 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#ifndef QWINDOWSYSTEMINTERFACE_H
4#define QWINDOWSYSTEMINTERFACE_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is part of the QPA API and is not meant to be used
11// in applications. Usage of this API may make your code
12// source and binary incompatible with future versions of Qt.
13//
14
15#include <QtGui/qtguiglobal.h>
16#include <QtCore/QTime>
17#include <QtGui/qwindowdefs.h>
18#include <QtCore/QEvent>
19#include <QtCore/QAbstractEventDispatcher>
20#include <QtGui/QScreen>
21#include <QtGui/QWindow>
22#include <QtCore/QWeakPointer>
23#include <QtCore/QMutex>
24#include <QtGui/QTouchEvent>
25#include <QtCore/QEventLoop>
26#include <QtGui/QVector2D>
27
29
30class QMimeData;
31class QPointingDevice;
34
35
36class Q_GUI_EXPORT QWindowSystemInterface
37{
38public:
41 struct DefaultDelivery {};
42
43 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
44 static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global,
45 Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type,
46 Qt::KeyboardModifiers mods = Qt::NoModifier,
48 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
50 const QPointF &local, const QPointF &global,
51 Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type,
52 Qt::KeyboardModifiers mods = Qt::NoModifier,
54 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
55 static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointF &local,
56 const QPointF &global, Qt::MouseButtons state,
58 Qt::KeyboardModifiers mods = Qt::NoModifier,
60 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
61 static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
62 const QPointF &local, const QPointF &global, Qt::MouseButtons state,
64 Qt::KeyboardModifiers mods = Qt::NoModifier,
66
67 static bool handleShortcutEvent(QWindow *window, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode,
68 quint32 nativeVirtualKey, quint32 nativeModifiers, const QString & text = QString(), bool autorep = false, ushort count = 1);
69
70 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
71 static bool handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
72 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
73 static bool handleKeyEvent(QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
74
75 static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
76 quint32 nativeScanCode, quint32 nativeVirtualKey,
77 quint32 nativeModifiers,
78 const QString& text = QString(), bool autorep = false,
79 ushort count = 1);
80 static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
81 quint32 nativeScanCode, quint32 nativeVirtualKey,
82 quint32 nativeModifiers,
83 const QString& text = QString(), bool autorep = false,
84 ushort count = 1);
86 QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
87 quint32 nativeScanCode, quint32 nativeVirtualKey,
88 quint32 nativeModifiers,
89 const QString& text = QString(), bool autorep = false,
90 ushort count = 1);
91 static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global,
92 QPoint pixelDelta, QPoint angleDelta,
93 Qt::KeyboardModifiers mods = Qt::NoModifier,
96 static bool handleWheelEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global,
97 QPoint pixelDelta, QPoint angleDelta,
98 Qt::KeyboardModifiers mods = Qt::NoModifier,
101 bool inverted = false);
102 static bool handleWheelEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
103 const QPointF &local, const QPointF &global,
104 QPoint pixelDelta, QPoint angleDelta,
105 Qt::KeyboardModifiers mods = Qt::NoModifier,
108 bool inverted = false);
109
110 // A very-temporary QPA touchpoint which gets converted to a QEventPoint as early as possible
111 // in QWindowSystemInterfacePrivate::fromNativeTouchPoints()
112 struct TouchPoint {
113 TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(QEventPoint::State::Stationary) { }
114 int id; // for application use
115 qint64 uniqueId; // for TUIO: object/token ID; otherwise empty
116 // TODO for TUIO 2.0: add registerPointerUniqueID(QPointingDeviceUniqueId)
117 QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
118 QRectF area; // dimensions of the elliptical contact patch, unrotated, and centered at position in screen coordinates
119 // width is the horizontal diameter, height is the vertical diameter
120 qreal pressure; // 0 to 1
121 qreal rotation; // rotation applied to the elliptical contact patch
122 // 0 means pointing straight up; 0 if unknown (like QTabletEvent::rotation)
123 QEventPoint::State state; // Pressed|Updated|Stationary|Released
124 QVector2D velocity; // in screen coordinate system, pixels / seconds
125 QList<QPointF> rawPositions; // in screen coordinates
126 };
127
128 static void registerInputDevice(const QInputDevice *device);
129
130 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
132 const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
133 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
135 const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
136 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
137 static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
138 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
139 static bool handleTouchCancelEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
140
141 // rect is relative to parent
142 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
143 static void handleGeometryChange(QWindow *window, const QRect &newRect);
144
145 // region is in local coordinates, do not confuse with geometry which is parent-relative
146 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
147 static bool handleExposeEvent(QWindow *window, const QRegion &region);
148
149 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
150 static bool handlePaintEvent(QWindow *window, const QRegion &region);
151
152 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
154
155 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
156 static void handleEnterEvent(QWindow *window, const QPointF &local = QPointF(), const QPointF& global = QPointF());
157 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
159 static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
160
161 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
163
164 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
165 static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1);
166 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
168
169 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
171
172 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
174
175 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
176 static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
177
178 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
180
181#if QT_CONFIG(draganddrop)
182 static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData,
183 const QPoint &p, Qt::DropActions supportedActions,
184 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
185 static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData,
186 const QPoint &p, Qt::DropActions supportedActions,
187 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
188#endif // QT_CONFIG(draganddrop)
189
190 static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result);
191
192 // Changes to the screen
193 static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary = false);
195 static void handlePrimaryScreenChanged(QPlatformScreen *newPrimary);
196
197 static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation);
198 static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry);
199 static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
200 static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate);
201
202 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
203 static void handleThemeChange(QWindow *window = nullptr);
204
205 static void handleFileOpenEvent(const QString& fileName);
206 static void handleFileOpenEvent(const QUrl &url);
207
208 static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
209 const QPointF &local, const QPointF &global,
210 Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
211 qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
212 static bool handleTabletEvent(QWindow *window, const QPointingDevice *device,
213 const QPointF &local, const QPointF &global,
214 Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
215 qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
216 static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global,
217 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
218 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
219 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
220 static bool handleTabletEvent(QWindow *window, const QPointF &local, const QPointF &global,
221 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
222 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
223 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
224 static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
225 bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
226 Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
227 qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
228 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
229 static bool handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device,
230 bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
231 Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
232 qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
233 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
234
235 // The following 4 functions are deprecated (QTBUG-114560)
236 static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
237 static void handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid);
238 static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
239 static void handleTabletLeaveProximityEvent(int deviceType, int pointerType, qint64 uid);
240
241#ifndef QT_NO_GESTURES
242 static bool handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type,
243 const QPointF &local, const QPointF &global, int fingerCount = 0);
244 static bool handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type,
245 qreal value, const QPointF &local, const QPointF &global, int fingerCount = 2);
246 static bool handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value,
247 const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount = 2);
248#endif // QT_NO_GESTURES
249
250 static void handlePlatformPanelEvent(QWindow *window);
251#ifndef QT_NO_CONTEXTMENU
252 static void handleContextMenuEvent(QWindow *window, bool mouseTriggered,
253 const QPoint &pos, const QPoint &globalPos,
254 Qt::KeyboardModifiers modifiers);
255#endif
256#if QT_CONFIG(whatsthis)
257 static void handleEnterWhatsThisEvent();
258#endif
259
260 // For event dispatcher implementations
261 static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
262 static void setSynchronousWindowSystemEvents(bool enable);
263 static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
264 static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
265 static int windowSystemEventsQueued();
266 static bool nonUserInputEventsQueued();
267};
268
269#ifndef QT_NO_DEBUG_STREAM
271#endif
272
274
275#endif // QWINDOWSYSTEMINTERFACE_H
static void handleScreenRemoved(JNIEnv *, jclass, jint displayId)
static void handleScreenAdded(JNIEnv *, jclass, jint displayId)
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
State
Specifies the state of this event point.
Definition qeventpoint.h:48
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
The QInputDevice class describes a device from which a QInputEvent originates.
\inmodule QtCore
Definition qmimedata.h:16
The QPlatformScreen class provides an abstraction for visual displays.
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
The QWindowSystemInterface provides an event queue for the QPA platform.
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleApplicationTermination()
static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void handleSafeAreaMarginsChanged(QWindow *window)
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen)
static void handleLeaveEvent(QWindow *window)
static bool handleMouseEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void handleFocusWindowChanged(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
static void handleThemeChange(QWindow *window=nullptr)
static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleMouseEvent(QWindow *window, const QPointingDevice *device, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static bool handleCloseEvent(QWindow *window)
static bool handleKeyEvent(QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
static bool handlePaintEvent(QWindow *window, const QRegion &region)
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static void handleWindowDevicePixelRatioChanged(QWindow *window)
static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, const QInputDevice *device, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static bool handleTouchCancelEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleTouchEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString &text=QString(), bool autorep=false, ushort count=1)
static bool handleExposeEvent(QWindow *window, const QRegion &region)
static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate=false)
static void handleEnterEvent(QWindow *window, const QPointF &local=QPointF(), const QPointF &global=QPointF())
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState=-1)
\inmodule QtGui
Definition qwindow.h:63
EGLImageKHR int int EGLuint64KHR * modifiers
QString text
QPushButton * button
[2]
else opt state
[0]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
MouseButton
Definition qnamespace.h:56
MouseEventSource
@ MouseEventNotSynthesized
ScreenOrientation
Definition qnamespace.h:271
@ NoModifier
ApplicationState
Definition qnamespace.h:262
NativeGestureType
ScrollPhase
@ NoScrollPhase
FocusReason
@ OtherFocusReason
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLuint64 key
GLboolean r
[2]
GLenum GLuint id
[7]
GLenum GLenum GLsizei count
GLenum type
GLbitfield flags
GLboolean enable
GLuint GLsizei const GLchar * message
GLsizei GLsizei GLchar * source
GLfixed GLfixed GLint GLint GLfixed points
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
QScreen * screen
[1]
Definition main.cpp:29
unsigned int quint32
Definition qtypes.h:50
unsigned long ulong
Definition qtypes.h:35
long long qint64
Definition qtypes.h:60
unsigned short ushort
Definition qtypes.h:33
double qreal
Definition qtypes.h:187
ptrdiff_t qintptr
Definition qtypes.h:166
#define leave(x)
static QPointingDevice::PointerType pointerType(unsigned currentCursor)
static QInputDevice::DeviceType deviceType(const UINT cursorType)
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p)
QUrl url("example.com")
[constructor-url-reference]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QJSValue global