123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 | // Copyright (C) 2020 The Qt Company Ltd.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only#ifndef QWINDOWSYSTEMINTERFACE_H#define QWINDOWSYSTEMINTERFACE_H//// W A R N I N G// -------------//// This file is part of the QPA API and is not meant to be used// in applications. Usage of this API may make your code// source and binary incompatible with future versions of Qt.//#include <QtGui/qtguiglobal.h>#include <QtCore/QTime>#include <QtGui/qwindowdefs.h>#include <QtCore/QEvent>#include <QtCore/QAbstractEventDispatcher>#include <QtGui/QScreen>#include <QtGui/QWindow>#include <QtCore/QMutex>#include <QtGui/QTouchEvent>#include <QtCore/QEventLoop>#include <QtGui/QVector2D> QT_BEGIN_NAMESPACE class QMimeData;class QPointingDevice;class QPlatformDragQtResponse;class QPlatformDropQtResponse;class Q_GUI_EXPORT QWindowSystemInterface {public:struct SynchronousDelivery {};struct AsynchronousDelivery {};struct DefaultDelivery {};template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleMouseEvent(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);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleMouseEvent(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);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleMouseEvent(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);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleMouseEvent(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 boolhandleShortcutEvent(QWindow *window, ulong timestamp,int k,Qt::KeyboardModifiers mods, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,const QString & text =QString(),bool autorep =false, ushort count =1);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleKeyEvent(QWindow *window,QEvent::Type t,int k,Qt::KeyboardModifiers mods,const QString & text =QString(),bool autorep =false, ushort count =1);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleKeyEvent(QWindow *window, ulong timestamp,QEvent::Type t,int k,Qt::KeyboardModifiers mods,const QString & text =QString(),bool autorep =false, ushort count =1);static boolhandleExtendedKeyEvent(QWindow *window,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 boolhandleExtendedKeyEvent(QWindow *window, ulong timestamp,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 boolhandleExtendedKeyEvent(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 boolhandleWheelEvent(QWindow *window,const QPointF &local,const QPointF &global, QPoint pixelDelta, QPoint angleDelta,Qt::KeyboardModifiers mods =Qt::NoModifier,Qt::ScrollPhase phase =Qt::NoScrollPhase,Qt::MouseEventSource source =Qt::MouseEventNotSynthesized);static boolhandleWheelEvent(QWindow *window, ulong timestamp,const QPointF &local,const QPointF &global, QPoint pixelDelta, QPoint angleDelta,Qt::KeyboardModifiers mods =Qt::NoModifier,Qt::ScrollPhase phase =Qt::NoScrollPhase,Qt::MouseEventSource source =Qt::MouseEventNotSynthesized,bool inverted =false);static boolhandleWheelEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,const QPointF &local,const QPointF &global, QPoint pixelDelta, QPoint angleDelta,Qt::KeyboardModifiers mods =Qt::NoModifier,Qt::ScrollPhase phase =Qt::NoScrollPhase,Qt::MouseEventSource source =Qt::MouseEventNotSynthesized,bool inverted =false);// A very-temporary QPA touchpoint which gets converted to a QEventPoint as early as possible// in QWindowSystemInterfacePrivate::fromNativeTouchPoints()struct TouchPoint {TouchPoint() :id(0),uniqueId(-1),pressure(0),rotation(0),state(QEventPoint::State::Stationary) { }int id;// for application use qint64 uniqueId;// for TUIO: object/token ID; otherwise empty// TODO for TUIO 2.0: add registerPointerUniqueID(QPointingDeviceUniqueId) QPointF normalPosition;// touch device coordinates, (0 to 1, 0 to 1) QRectF area;// dimensions of the elliptical contact patch, unrotated, and centered at position in screen coordinates// width is the horizontal diameter, height is the vertical diameter qreal pressure;// 0 to 1 qreal rotation;// rotation applied to the elliptical contact patch// 0 means pointing straight up; 0 if unknown (like QTabletEvent::rotation)QEventPoint::State state;// Pressed|Updated|Stationary|Released QVector2D velocity;// in screen coordinate system, pixels / seconds QList<QPointF> rawPositions;// in screen coordinates};static voidregisterInputDevice(const QInputDevice *device);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleTouchEvent(QWindow *window,const QPointingDevice *device,const QList<struct TouchPoint> &points,Qt::KeyboardModifiers mods =Qt::NoModifier);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleTouchEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,const QList<struct TouchPoint> &points,Qt::KeyboardModifiers mods =Qt::NoModifier);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleTouchCancelEvent(QWindow *window,const QPointingDevice *device,Qt::KeyboardModifiers mods =Qt::NoModifier);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleTouchCancelEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,Qt::KeyboardModifiers mods =Qt::NoModifier);// rect is relative to parenttemplate<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleGeometryChange(QWindow *window,const QRect &newRect);// region is in local coordinates, do not confuse with geometry which is parent-relativetemplate<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleExposeEvent(QWindow *window,const QRegion ®ion);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandlePaintEvent(QWindow *window,const QRegion ®ion);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleCloseEvent(QWindow *window);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleEnterEvent(QWindow *window,const QPointF &local =QPointF(),const QPointF& global =QPointF());template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleLeaveEvent(QWindow *window);static voidhandleEnterLeaveEvent(QWindow *enter, QWindow *leave,const QPointF &local =QPointF(),const QPointF& global =QPointF());template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleFocusWindowChanged(QWindow *window,Qt::FocusReason r =Qt::OtherFocusReason);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleWindowStateChanged(QWindow *window,Qt::WindowStates newState,int oldState = -1);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleWindowScreenChanged(QWindow *window, QScreen *newScreen);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleWindowDevicePixelRatioChanged(QWindow *window);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleSafeAreaMarginsChanged(QWindow *window);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleApplicationStateChanged(Qt::ApplicationState newState,bool forcePropagate =false);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleApplicationTermination();#if QT_CONFIG(draganddrop)static QPlatformDragQtResponse handleDrag(QWindow *window,const QMimeData *dropData,const QPoint &p,Qt::DropActions supportedActions,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers);static QPlatformDropQtResponse handleDrop(QWindow *window,const QMimeData *dropData,const QPoint &p,Qt::DropActions supportedActions,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers);#endif// QT_CONFIG(draganddrop)static boolhandleNativeEvent(QWindow *window,const QByteArray &eventType,void*message, qintptr *result);// Changes to the screenstatic voidhandleScreenAdded(QPlatformScreen *screen,bool isPrimary =false);static voidhandleScreenRemoved(QPlatformScreen *screen);static voidhandlePrimaryScreenChanged(QPlatformScreen *newPrimary);static voidhandleScreenOrientationChange(QScreen *screen,Qt::ScreenOrientation newOrientation);static voidhandleScreenGeometryChange(QScreen *screen,const QRect &newGeometry,const QRect &newAvailableGeometry);static voidhandleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);static voidhandleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate);template<typename Delivery =QWindowSystemInterface::DefaultDelivery>static voidhandleThemeChange();static voidhandleFileOpenEvent(const QString& fileName);static voidhandleFileOpenEvent(const QUrl &url);static boolhandleTabletEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,const QPointF &local,const QPointF &global,Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt, qreal tangentialPressure, qreal rotation,int z,Qt::KeyboardModifiers modifiers =Qt::NoModifier);static boolhandleTabletEvent(QWindow *window,const QPointingDevice *device,const QPointF &local,const QPointF &global,Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt, qreal tangentialPressure, qreal rotation,int z,Qt::KeyboardModifiers modifiers =Qt::NoModifier);static boolhandleTabletEvent(QWindow *window, ulong timestamp,const QPointF &local,const QPointF &global,int device,int pointerType,Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt, qreal tangentialPressure, qreal rotation,int z, qint64 uid,Qt::KeyboardModifiers modifiers =Qt::NoModifier);static boolhandleTabletEvent(QWindow *window,const QPointF &local,const QPointF &global,int device,int pointerType,Qt::MouseButtons buttons, qreal pressure, qreal xTilt, qreal yTilt, qreal tangentialPressure, qreal rotation,int z, qint64 uid,Qt::KeyboardModifiers modifiers =Qt::NoModifier);static boolhandleTabletEnterLeaveProximityEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,bool inProximity,const QPointF &local =QPointF(),const QPointF &global =QPointF(),Qt::MouseButtons buttons = {}, qreal xTilt =0, qreal yTilt =0, qreal tangentialPressure =0, qreal rotation =0,int z =0,Qt::KeyboardModifiers modifiers =Qt::NoModifier);static boolhandleTabletEnterLeaveProximityEvent(QWindow *window,const QPointingDevice *device,bool inProximity,const QPointF &local =QPointF(),const QPointF &global =QPointF(),Qt::MouseButtons buttons = {}, qreal xTilt =0, qreal yTilt =0, qreal tangentialPressure =0, qreal rotation =0,int z =0,Qt::KeyboardModifiers modifiers =Qt::NoModifier);// The following 4 functions are deprecated (QTBUG-114560)static boolhandleTabletEnterProximityEvent(ulong timestamp,int deviceType,int pointerType, qint64 uid);static voidhandleTabletEnterProximityEvent(int deviceType,int pointerType, qint64 uid);static boolhandleTabletLeaveProximityEvent(ulong timestamp,int deviceType,int pointerType, qint64 uid);static voidhandleTabletLeaveProximityEvent(int deviceType,int pointerType, qint64 uid);#ifndef QT_NO_GESTURESstatic boolhandleGestureEvent(QWindow *window, ulong timestamp,const QPointingDevice *device,Qt::NativeGestureType type,const QPointF &local,const QPointF &global,int fingerCount =0);static boolhandleGestureEventWithRealValue(QWindow *window, ulong timestamp,const QPointingDevice *device,Qt::NativeGestureType type, qreal value,const QPointF &local,const QPointF &global,int fingerCount =2);static boolhandleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp,const QPointingDevice *device,Qt::NativeGestureType type, qreal value,const QPointF &delta,const QPointF &local,const QPointF &global,int fingerCount =2);#endif// QT_NO_GESTURESstatic voidhandlePlatformPanelEvent(QWindow *window);#ifndef QT_NO_CONTEXTMENU#if QT_GUI_REMOVED_SINCE(6, 8)static voidhandleContextMenuEvent(QWindow *window,bool mouseTriggered,const QPoint &pos,const QPoint &globalPos,Qt::KeyboardModifiers modifiers);#endiftemplate<typename Delivery =QWindowSystemInterface::DefaultDelivery>static boolhandleContextMenuEvent(QWindow *window,bool mouseTriggered,const QPoint &pos,const QPoint &globalPos,Qt::KeyboardModifiers modifiers);#endif#if QT_CONFIG(whatsthis)static voidhandleEnterWhatsThisEvent();#endif// For event dispatcher implementationsstatic boolsendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);static voidsetSynchronousWindowSystemEvents(bool enable);static boolflushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags =QEventLoop::AllEvents);static voiddeferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);static intwindowSystemEventsQueued();static boolnonUserInputEventsQueued();};#ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug dbg,constQWindowSystemInterface::TouchPoint &p);#endif QT_END_NAMESPACE #endif// QWINDOWSYSTEMINTERFACE_H
|