diff options
Diffstat (limited to 'src/client/qwaylandwindow_p.h')
-rw-r--r-- | src/client/qwaylandwindow_p.h | 96 |
1 files changed, 77 insertions, 19 deletions
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 66d5bdade..b78c8ce4e 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -28,10 +28,14 @@ #include <QtCore/QMap> // for QVariantMap #include <qpa/qplatformwindow.h> +#include <qpa/qplatformwindow_p.h> #include <QtWaylandClient/private/qwayland-wayland.h> #include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/qtwaylandclientglobal.h> +#include <QtWaylandClient/private/qwaylandshellsurface_p.h> + +#include <QtCore/qpointer.h> struct wl_egl_window; @@ -48,13 +52,17 @@ class QWaylandSubSurface; class QWaylandAbstractDecoration; class QWaylandInputDevice; class QWaylandScreen; +class QWaylandShellIntegration; class QWaylandShmBackingStore; class QWaylandPointerEvent; class QWaylandPointerGestureSwipeEvent; class QWaylandPointerGesturePinchEvent; class QWaylandSurface; +class QWaylandFractionalScale; +class QWaylandViewport; -class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QObject, public QPlatformWindow +class Q_WAYLANDCLIENT_EXPORT QWaylandWindow : public QNativeInterface::Private::QWaylandWindow, + public QPlatformWindow { Q_OBJECT public: @@ -85,6 +93,7 @@ public: void setVisible(bool visible) override; void setParent(const QPlatformWindow *parent) override; + QString windowTitle() const; void setWindowTitle(const QString &title) override; inline QIcon windowIcon() const; @@ -104,7 +113,6 @@ public: void damage(const QRect &rect); void safeCommit(QWaylandBuffer *buffer, const QRegion &damage); - void handleExpose(const QRegion ®ion); void commit(QWaylandBuffer *buffer, const QRegion &damage); void commit(); @@ -112,20 +120,29 @@ public: bool waitForFrameSync(int timeout); QMargins frameMargins() const override; + QMargins clientSideMargins() const; + void setCustomMargins(const QMargins &margins) override; QSize surfaceSize() const; + QMargins windowContentMargins() const; QRect windowContentGeometry() const; QPointF mapFromWlSurface(const QPointF &surfacePosition) const; QWaylandSurface *waylandSurface() const { return mSurface.data(); } - ::wl_surface *wlSurface(); + ::wl_surface *wlSurface() const; + ::wl_surface *surface() const override + { + return wlSurface(); + } static QWaylandWindow *fromWlSurface(::wl_surface *surface); QWaylandDisplay *display() const { return mDisplay; } QWaylandShellSurface *shellSurface() const; + std::any _surfaceRole() const override; QWaylandSubSurface *subSurfaceWindow() const; QWaylandScreen *waylandScreen() const; void handleContentOrientationChange(Qt::ScreenOrientation orientation) override; + void updateBufferTransform(); void setOrientationMask(Qt::ScreenOrientations mask); ToplevelWindowTilingStates toplevelWindowTilingStates() const; @@ -141,6 +158,9 @@ public: void setMask(const QRegion ®ion) override; + void setAlertState(bool enabled) override; + bool isAlertState() const override; + qreal scale() const; qreal devicePixelRatio() const override; @@ -170,7 +190,6 @@ public: QWaylandWindow *transientParent() const; - QMutex *resizeMutex() { return &mResizeLock; } void doApplyConfigure(); void setCanResize(bool canResize); @@ -184,9 +203,16 @@ public: QVariant property(const QString &name); QVariant property(const QString &name, const QVariant &defaultValue); +#ifdef QT_PLATFORM_WINDOW_HAS_VIRTUAL_SET_BACKING_STORE + void setBackingStore(QPlatformBackingStore *store) override; +#else void setBackingStore(QWaylandShmBackingStore *backingStore) { mBackingStore = backingStore; } +#endif QWaylandShmBackingStore *backingStore() const { return mBackingStore; } + void setShellIntegration(QWaylandShellIntegration *shellIntegration); + QWaylandShellIntegration *shellIntegration() const { return mShellIntegration; } + bool setKeyboardGrabEnabled(bool) override { return false; } void propagateSizeHints() override; void addAttachOffset(const QPoint point); @@ -200,31 +226,40 @@ public: void deliverUpdateRequest() override; void setXdgActivationToken(const QString &token); - void requestXdgActivationToken(uint serial); + void requestXdgActivationToken(uint serial) override; void beginFrame(); void endFrame(); -public slots: + void closeChildPopups(); + void sendRecursiveExposeEvent(); + + virtual void reinit(); + void reset(); + + bool windowEvent(QEvent *event) override; + +public Q_SLOTS: void applyConfigure(); -signals: +Q_SIGNALS: void wlSurfaceCreated(); void wlSurfaceDestroyed(); - void xdgActivationTokenCreated(const QString &token); protected: virtual void doHandleFrameCallback(); virtual QRect defaultGeometry() const; void sendExposeEvent(const QRect &rect); - QMargins clientSideMargins() const; QWaylandDisplay *mDisplay = nullptr; // mSurface can be written by the main thread. Other threads should claim a read lock for access mutable QReadWriteLock mSurfaceLock; QScopedPointer<QWaylandSurface> mSurface; + QScopedPointer<QWaylandFractionalScale> mFractionalScale; + QScopedPointer<QWaylandViewport> mViewport; + QWaylandShellIntegration *mShellIntegration = nullptr; QWaylandShellSurface *mShellSurface = nullptr; QWaylandSubSurface *mSubSurfaceWindow = nullptr; QList<QWaylandSubSurface *> mChildren; @@ -252,19 +287,20 @@ protected: #endif WId mWindowId; - bool mWaitingForFrameCallback = false; bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out - QAtomicInt mWaitingForUpdateDelivery = false; int mFrameCallbackCheckIntervalTimerId = -1; - QElapsedTimer mFrameCallbackElapsedTimer; - struct ::wl_callback *mFrameCallback = nullptr; + QAtomicInt mWaitingForUpdateDelivery = false; + + bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex + QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex + struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex QMutex mFrameSyncMutex; QWaitCondition mFrameSyncWait; // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer bool mWaitingForUpdate = false; - QMutex mResizeLock; + QRecursiveMutex mResizeLock; bool mWaitingToApplyConfigure = false; bool mCanResize = true; bool mResizeDirty = false; @@ -274,13 +310,19 @@ protected: bool mSentInitialResize = false; QPoint mOffset; - int mScale = 1; + qreal mScale = 1; QPlatformScreen *mLastReportedScreen = nullptr; + QString mWindowTitle; QIcon mWindowIcon; Qt::WindowFlags mFlags; QRegion mMask; + + // Empty QRegion maps to "infinite" input region, needs a dedicated "deliberately empty" state. + QRegion mInputRegion; + bool mTransparentInputRegion = false; + QRegion mOpaqueArea; Qt::WindowStates mLastReportedWindowStates = Qt::WindowNoState; ToplevelWindowTilingStates mLastReportedToplevelWindowTilingStates = WindowNoState; @@ -289,30 +331,46 @@ protected: QWaylandBuffer *mQueuedBuffer = nullptr; QRegion mQueuedBufferDamage; + QMargins mCustomMargins; + + QPointer<QWaylandWindow> mTransientParent; + QList<QPointer<QWaylandWindow>> mChildPopups; + + Qt::ScreenOrientation mLastReportedContentOrientation = Qt::PrimaryOrientation; + +private Q_SLOTS: + void doApplyConfigureFromOtherThread(); + private: void setGeometry_helper(const QRect &rect); void initWindow(); void initializeWlSurface(); bool shouldCreateShellSurface() const; bool shouldCreateSubSurface() const; - void reset(); - static void closePopups(QWaylandWindow *parent); QPlatformScreen *calculateScreenFromSurfaceEvents() const; void setOpaqueArea(const QRegion &opaqueArea); bool isOpaque() const; + void updateInputRegion(); + void updateViewport(); void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e); void handleScreensChanged(); - void sendRecursiveExposeEvent(); + void updateScale(); + void setScale(qreal newScale); + + QWaylandWindow *guessTransientParent() const; + void addChildPopup(QWaylandWindow *child); + void removeChildPopup(QWaylandWindow *child); bool mInResizeFromApplyConfigure = false; bool lastVisible = false; QRect mLastExposeGeometry; static const wl_callback_listener callbackListener; - void handleFrameCallback(); + void handleFrameCallback(struct ::wl_callback* callback); static QWaylandWindow *mMouseGrab; + static QWaylandWindow *mTopPopup; friend class QWaylandSubSurface; }; |