1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDXDGSHELLINTEGRATION_H
5#define QWAYLANDXDGSHELLINTEGRATION_H
6
7#include <QtWaylandCompositor/private/qwaylandquickshellsurfaceitem_p.h>
8#include <QtWaylandCompositor/QWaylandQuickShellSurfaceItem>
9#include <QtWaylandCompositor/QWaylandXdgToplevel>
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
24class QWaylandXdgSurface;
25
26namespace QtWayland {
27
28class XdgToplevelIntegration : public QWaylandQuickShellIntegration
29{
30 Q_OBJECT
31public:
32 XdgToplevelIntegration(QWaylandQuickShellSurfaceItem *item);
33
34protected:
35 bool eventFilter(QObject *object, QEvent *event) override;
36
37private Q_SLOTS:
38 void handleStartMove(QWaylandSeat *seat);
39 void handleStartResize(QWaylandSeat *seat, Qt::Edges edges);
40 void handleSetMaximized();
41 void handleUnsetMaximized();
42 void handleMaximizedChanged();
43 void handleSetFullscreen();
44 void handleUnsetFullscreen();
45 void handleFullscreenChanged();
46 void handleActivatedChanged();
47 void handleSurfaceSizeChanged();
48 void handleToplevelDestroyed();
49 void handleMaximizedSizeChanged();
50 void handleFullscreenSizeChanged();
51
52private:
53 QWaylandQuickShellSurfaceItem *m_item = nullptr;
54 QWaylandXdgSurface *m_xdgSurface = nullptr;
55 QWaylandXdgToplevel *m_toplevel = nullptr;
56
57 enum class GrabberState {
58 Default,
59 Resize,
60 Move
61 };
62 GrabberState grabberState;
63
64 struct {
65 QWaylandSeat *seat = nullptr;
66 QPointF initialOffset;
67 bool initialized;
68 } moveState;
69
70 struct {
71 QWaylandSeat *seat = nullptr;
72 Qt::Edges resizeEdges;
73 QSizeF initialWindowSize;
74 QPointF initialMousePos;
75 QPointF initialPosition;
76 QSize initialSurfaceSize;
77 bool initialized;
78 } resizeState;
79
80 struct {
81 QSize initialWindowSize;
82 QPointF initialPosition;
83 } windowedGeometry;
84
85 struct {
86 QWaylandOutput *output = nullptr;
87 QMetaObject::Connection sizeChangedConnection; // Depending on whether maximized or fullscreen,
88 // will be hooked to geometry-changed or available-
89 // geometry-changed.
90 } nonwindowedState;
91
92 bool filterPointerMoveEvent(const QPointF &scenePosition);
93 bool filterMouseMoveEvent(QMouseEvent *event);
94 bool filterPointerReleaseEvent();
95 bool filterTouchUpdateEvent(QTouchEvent *event);
96};
97
98class XdgPopupIntegration : public QWaylandQuickShellIntegration
99{
100 Q_OBJECT
101public:
102 XdgPopupIntegration(QWaylandQuickShellSurfaceItem *item);
103
104private Q_SLOTS:
105 void handleGeometryChanged();
106
107private:
108 QWaylandQuickShellSurfaceItem *m_item = nullptr;
109 QWaylandXdgSurface *m_xdgSurface = nullptr;
110 QWaylandXdgPopup *m_popup = nullptr;
111};
112
113}
114
115QT_END_NAMESPACE
116
117#endif // QWAYLANDXDGSHELLINTEGRATION_H
118

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