1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QWAYLANDSHELLSURFACE_H
5#define QWAYLANDSHELLSURFACE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QSize>
19#include <QObject>
20#include <QPoint>
21#include <QtWaylandClient/qtwaylandclientglobal.h>
22#include <QtCore/private/qglobal_p.h>
23
24#include <any>
25
26struct wl_surface;
27
28QT_BEGIN_NAMESPACE
29
30class QVariant;
31class QWindow;
32class QPlatformWindow;
33
34namespace QtWaylandClient {
35
36class QWaylandWindow;
37class QWaylandInputDevice;
38
39class Q_WAYLANDCLIENT_EXPORT QWaylandShellSurface : public QObject
40{
41 Q_OBJECT
42public:
43 explicit QWaylandShellSurface(QWaylandWindow *window);
44 ~QWaylandShellSurface() override {}
45 virtual bool resize(QWaylandInputDevice *, Qt::Edges) { return false; }
46 virtual bool move(QWaylandInputDevice *) { return false; }
47 virtual bool showWindowMenu(QWaylandInputDevice *seat) { Q_UNUSED(seat); return false; }
48 virtual void setTitle(const QString & /*title*/) {}
49 virtual void setAppId(const QString & /*appId*/) {}
50
51 virtual void setWindowFlags(Qt::WindowFlags flags);
52
53 virtual bool isExposed() const { return true; }
54 virtual bool handleExpose(const QRegion &) { return false; }
55
56 virtual void raise() {}
57 virtual void lower() {}
58 virtual void setContentOrientationMask(Qt::ScreenOrientations orientation) { Q_UNUSED(orientation); }
59
60 virtual void sendProperty(const QString &name, const QVariant &value);
61
62 virtual void applyConfigure() {}
63 virtual void requestWindowStates(Qt::WindowStates states) {Q_UNUSED(states);}
64 virtual bool wantsDecorations() const { return false; }
65 virtual QMargins serverSideFrameMargins() const { return QMargins(); }
66
67 virtual void propagateSizeHints() {}
68
69 virtual void setWindowGeometry(const QRect &rect) { Q_UNUSED(rect); }
70 virtual void setWindowPosition(const QPoint &position) { Q_UNUSED(position); }
71
72 virtual bool requestActivate() { return false; }
73 virtual void setXdgActivationToken(const QString &token);
74 virtual void requestXdgActivationToken(quint32 serial);
75
76 virtual void setAlertState(bool enabled) { Q_UNUSED(enabled); }
77 virtual bool isAlertState() const { return false; }
78
79 virtual QString externWindowHandle() { return QString(); }
80
81 inline QWaylandWindow *window() { return m_window; }
82 QPlatformWindow *platformWindow();
83 struct wl_surface *wlSurface();
84
85 virtual std::any surfaceRole() const { return std::any(); };
86
87 virtual void attachPopup(QWaylandShellSurface *popup) { Q_UNUSED(popup); }
88 virtual void detachPopup(QWaylandShellSurface *popup) { Q_UNUSED(popup); }
89
90protected:
91 void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
92 void repositionFromApplyConfigure(const QPoint &position);
93 void setGeometryFromApplyConfigure(const QPoint &globalPosition, const QSize &sizeWithMargins);
94 void applyConfigureWhenPossible();
95 void handleActivationChanged(bool activated);
96
97 static uint32_t getSerial(QWaylandInputDevice *inputDevice);
98
99private:
100 QWaylandWindow *m_window = nullptr;
101 friend class QWaylandWindow;
102};
103
104}
105
106QT_END_NAMESPACE
107
108#endif // QWAYLANDSHELLSURFACE_H
109

source code of qtwayland/src/client/qwaylandshellsurface_p.h