Qt 6.x
The Qt SDK
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 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
162
163 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
164 static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1);
165 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
167
168 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
170
171 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
173
174 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
175 static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
176
177 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
179
180#if QT_CONFIG(draganddrop)
181 static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData,
182 const QPoint &p, Qt::DropActions supportedActions,
183 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
184 static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData,
185 const QPoint &p, Qt::DropActions supportedActions,
186 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
187#endif // QT_CONFIG(draganddrop)
188
189 static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result);
190
191 // Changes to the screen
192 static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary = false);
194 static void handlePrimaryScreenChanged(QPlatformScreen *newPrimary);
195
196 static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation);
197 static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry);
198 static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
199 static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate);
200
201 template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
202 static void handleThemeChange(QWindow *window = nullptr);
203
204 static void handleFileOpenEvent(const QString& fileName);
205 static void handleFileOpenEvent(const QUrl &url);
206
207 static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
208 const QPointF &local, const QPointF &global,
209 Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
210 qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
211 static bool handleTabletEvent(QWindow *window, const QPointingDevice *device,
212 const QPointF &local, const QPointF &global,
213 Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
214 qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
215 static bool handleTabletEvent(QWindow *window, ulong timestamp, const QPointF &local, const QPointF &global,
216 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
217 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
218 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
219 static bool handleTabletEvent(QWindow *window, const QPointF &local, const QPointF &global,
220 int device, int pointerType, Qt::MouseButtons buttons, qreal pressure, int xTilt, int yTilt,
221 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
222 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
223 static bool handleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
224 bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
225 Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
226 qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
227 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
228 static bool handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device,
229 bool inProximity, const QPointF &local = QPointF(), const QPointF &global = QPointF(),
230 Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
231 qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
232 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
233
234 // The following 4 functions are deprecated (QTBUG-114560)
235 static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
236 static void handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid);
237 static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
238 static void handleTabletLeaveProximityEvent(int deviceType, int pointerType, qint64 uid);
239
240#ifndef QT_NO_GESTURES
241 static bool handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type,
242 const QPointF &local, const QPointF &global, int fingerCount = 0);
243 static bool handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type,
244 qreal value, const QPointF &local, const QPointF &global, int fingerCount = 2);
245 static bool handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value,
246 const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount = 2);
247#endif // QT_NO_GESTURES
248
249 static void handlePlatformPanelEvent(QWindow *window);
250#ifndef QT_NO_CONTEXTMENU
251 static void handleContextMenuEvent(QWindow *window, bool mouseTriggered,
252 const QPoint &pos, const QPoint &globalPos,
253 Qt::KeyboardModifiers modifiers);
254#endif
255#if QT_CONFIG(whatsthis)
256 static void handleEnterWhatsThisEvent();
257#endif
258
259 // For event dispatcher implementations
260 static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
261 static void setSynchronousWindowSystemEvents(bool enable);
262 static bool flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
263 static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
264 static int windowSystemEventsQueued();
265 static bool nonUserInputEventsQueued();
266};
267
268#ifndef QT_NO_DEBUG_STREAM
270#endif
271
273
274#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:49
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.
Definition qlist.h:74
\inmodule QtCore
Definition qmimedata.h:16
The QPlatformScreen class provides an abstraction for visual displays.
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore\reentrant
Definition qpoint.h:23
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
Definition qrect.h:483
\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:127
\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 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 handleWindowActivated(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
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:55
MouseEventSource
@ MouseEventNotSynthesized
ScreenOrientation
Definition qnamespace.h:270
@ NoModifier
ApplicationState
Definition qnamespace.h:261
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:45
unsigned long ulong
Definition qtypes.h:30
long long qint64
Definition qtypes.h:55
unsigned short ushort
Definition qtypes.h:28
double qreal
Definition qtypes.h:92
ptrdiff_t qintptr
Definition qtypes.h:71
#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