| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QWAYLANDWLSHELLINTEGRATION_H |
| 5 | #define QWAYLANDWLSHELLINTEGRATION_H |
| 6 | |
| 7 | #include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h> |
| 8 | |
| 9 | #include <QtWaylandCompositor/QWaylandWlShellSurface> |
| 10 | |
| 11 | #include <QtCore/qpointer.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | // |
| 16 | // W A R N I N G |
| 17 | // ------------- |
| 18 | // |
| 19 | // This file is not part of the Qt API. It exists purely as an |
| 20 | // implementation detail. This header file may change from version to |
| 21 | // version without notice, or even be removed. |
| 22 | // |
| 23 | // We mean it. |
| 24 | // |
| 25 | |
| 26 | namespace QtWayland { |
| 27 | |
| 28 | class WlShellIntegration : public QWaylandQuickShellIntegration |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | WlShellIntegration(QWaylandQuickShellSurfaceItem *item); |
| 33 | ~WlShellIntegration() override; |
| 34 | |
| 35 | protected: |
| 36 | bool eventFilter(QObject *object, QEvent *event) override; |
| 37 | |
| 38 | private Q_SLOTS: |
| 39 | void handleStartMove(QWaylandSeat *seat); |
| 40 | void handleStartResize(QWaylandSeat *seat, QWaylandWlShellSurface::ResizeEdge edges); |
| 41 | void handleSetDefaultTopLevel(); |
| 42 | void handleSetTransient(QWaylandSurface *parentSurface, const QPoint &relativeToParent, bool inactive); |
| 43 | void handleSetMaximized(QWaylandOutput *output); |
| 44 | void handleSetFullScreen(QWaylandWlShellSurface::FullScreenMethod method, uint framerate, QWaylandOutput *output); |
| 45 | void handleSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const QPoint &relativeToParent); |
| 46 | void handleShellSurfaceDestroyed(); |
| 47 | void handleSurfaceHasContentChanged(); |
| 48 | void handleRedraw(); |
| 49 | void adjustOffsetForNextFrame(const QPointF &offset); |
| 50 | void handleFullScreenSizeChanged(); |
| 51 | void handleMaximizedSizeChanged(); |
| 52 | |
| 53 | private: |
| 54 | enum class GrabberState { |
| 55 | Default, |
| 56 | Resize, |
| 57 | Move |
| 58 | }; |
| 59 | |
| 60 | void handlePopupClosed(); |
| 61 | void handlePopupRemoved(); |
| 62 | qreal devicePixelRatio() const; |
| 63 | |
| 64 | QWaylandQuickShellSurfaceItem *m_item = nullptr; |
| 65 | QPointer<QWaylandWlShellSurface> m_shellSurface; |
| 66 | GrabberState grabberState = GrabberState::Default; |
| 67 | struct { |
| 68 | QWaylandSeat *seat = nullptr; |
| 69 | QPointF initialOffset; |
| 70 | bool initialized = false; |
| 71 | } moveState; |
| 72 | struct { |
| 73 | QWaylandSeat *seat = nullptr; |
| 74 | QWaylandWlShellSurface::ResizeEdge resizeEdges; |
| 75 | QSizeF initialSize; |
| 76 | QPointF initialMousePos; |
| 77 | bool initialized = false; |
| 78 | } resizeState; |
| 79 | |
| 80 | bool isPopup = false; |
| 81 | |
| 82 | enum class State { |
| 83 | Windowed, |
| 84 | Maximized, |
| 85 | FullScreen |
| 86 | }; |
| 87 | |
| 88 | State currentState = State::Windowed; |
| 89 | State nextState = State::Windowed; |
| 90 | |
| 91 | struct { |
| 92 | QWaylandOutput *output = nullptr; |
| 93 | QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen, |
| 94 | // will be hooked to geometry-changed or available- |
| 95 | // geometry-changed. |
| 96 | } nonwindowedState; |
| 97 | |
| 98 | QPointF normalPosition; |
| 99 | QPointF finalPosition; |
| 100 | |
| 101 | bool filterMouseMoveEvent(QMouseEvent *event); |
| 102 | bool filterMouseReleaseEvent(QMouseEvent *event); |
| 103 | }; |
| 104 | |
| 105 | } |
| 106 | |
| 107 | QT_END_NAMESPACE |
| 108 | |
| 109 | #endif // QWAYLANDWLSHELLINTEGRATION_H |
| 110 | |