1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDQTSHELL_P_H
5#define QWAYLANDQTSHELL_P_H
6
7#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
8#include <QtWaylandCompositor/QWaylandSurfaceRole>
9
10#include <QHash>
11
12#include "qwayland-server-qt-shell-unstable-v1.h"
13#include "qwaylandqtshell.h"
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
26QT_BEGIN_NAMESPACE
27
28class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShellPrivate
29 : public QWaylandCompositorExtensionPrivate
30 , public QtWaylandServer::zqt_shell_v1
31{
32 Q_DECLARE_PUBLIC(QWaylandQtShell)
33
34public:
35 QWaylandQtShellPrivate();
36 static QWaylandQtShellPrivate *get(QWaylandQtShell *qtShell) { return qtShell->d_func(); }
37 void unregisterQtShellSurface(QWaylandQtShellSurface *qtShellSurface);
38
39 QList<QWaylandQtShellChrome *> m_chromes;
40
41protected:
42 void zqt_shell_v1_surface_create(Resource *resource, wl_resource *surface, uint32_t id) override;
43};
44
45class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShellSurfacePrivate
46 : public QWaylandCompositorExtensionPrivate
47 , public QtWaylandServer::zqt_shell_surface_v1
48{
49 Q_DECLARE_PUBLIC(QWaylandQtShellSurface)
50
51public:
52 QWaylandQtShellSurfacePrivate();
53 static QWaylandQtShellSurfacePrivate *get(QWaylandQtShellSurface *qtShellSurface)
54 {
55 return qtShellSurface->d_func();
56 }
57
58 void updateFrameMargins();
59 void configure(uint windowState, const QRect &newGeometry);
60
61protected:
62 void zqt_shell_surface_v1_destroy_resource(Resource *resource) override;
63 void zqt_shell_surface_v1_destroy(Resource *resource) override;
64 void zqt_shell_surface_v1_reposition(Resource *resource, int32_t x, int32_t y) override;
65 void zqt_shell_surface_v1_set_size(Resource *resource, int32_t width, int32_t height) override;
66 void zqt_shell_surface_v1_set_minimum_size(Resource *resource, int32_t width, int32_t height) override;
67 void zqt_shell_surface_v1_set_maximum_size(Resource *resource, int32_t width, int32_t height) override;
68 void zqt_shell_surface_v1_set_window_title(Resource *resource, const QString &title) override;
69 void zqt_shell_surface_v1_set_window_flags(Resource *resource, uint32_t flags) override;
70 void zqt_shell_surface_v1_change_window_state(Resource *resource, uint32_t state) override;
71 void zqt_shell_surface_v1_ack_configure(Resource *resource, uint32_t serial) override;
72
73 void zqt_shell_surface_v1_start_system_resize(Resource *resource, uint32_t serial, uint32_t edge) override;
74 void zqt_shell_surface_v1_start_system_move(Resource *resource, uint32_t serial) override;
75
76 void zqt_shell_surface_v1_raise(Resource *resource) override;
77 void zqt_shell_surface_v1_lower(Resource *resource) override;
78
79 void zqt_shell_surface_v1_request_activate(Resource *resource) override;
80
81private:
82 QWaylandQtShell *m_qtShell = nullptr;
83 QWaylandSurface *m_surface = nullptr;
84 QRect m_windowGeometry;
85 QSize m_minimumSize;
86 QSize m_maximumSize;
87 uint m_windowFlags = 0;
88 uint m_windowState = 0;
89 QString m_windowTitle;
90 QMargins m_frameMargins;
91 bool m_positionSet = false;
92 bool m_active = false;
93
94 QPoint m_pendingPosition;
95 bool m_pendingPositionValid = false;
96 QSize m_pendingSize;
97
98 uint32_t m_lastAckedConfigure = UINT32_MAX;
99 QMap<uint32_t, QPair<uint, QRect> > m_pendingConfigures;
100
101 QWaylandQtShellSurface::CapabilityFlags m_capabilities;
102
103 static QWaylandSurfaceRole s_role;
104};
105
106QT_END_NAMESPACE
107
108#endif // QWAYLANDQTSHELL_P_H
109

source code of qtwayland/src/imports/compositor-extensions/qtshell/qwaylandqtshell_p.h