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

source code of qtwayland/src/compositor/extensions/qwaylandwlshellintegration_p.h