1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WAYLANDCOMPOSITOR_H
#define WAYLANDCOMPOSITOR_H
#include <QtAppManCommon/global.h>
#if QT_CONFIG(am_multi_process)
#include <QtWaylandCompositor/QWaylandQuickCompositor>
#include <QtWaylandCompositor/QWaylandQuickSurface>
#include <QtWaylandCompositor/QWaylandQuickItem>
#include <QtCore/QMap>
#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QWaylandResource)
QT_FORWARD_DECLARE_CLASS(QWaylandWlShell)
QT_FORWARD_DECLARE_CLASS(QWaylandWlShellSurface)
QT_FORWARD_DECLARE_CLASS(QWaylandTextInputManager)
QT_FORWARD_DECLARE_CLASS(QWaylandQtTextInputMethodManager)
QT_FORWARD_DECLARE_CLASS(QWaylandXdgShell)
QT_FORWARD_DECLARE_CLASS(QWaylandXdgSurface)
QT_FORWARD_DECLARE_CLASS(QWaylandXdgToplevel)
QT_FORWARD_DECLARE_CLASS(QWaylandXdgPopup)
QT_BEGIN_NAMESPACE_AM
class WaylandCompositor;
class WaylandQtAMServerExtension;
class WaylandXdgWatchdog;
class WindowSurfaceQuickItem;
// A WindowSurface object exists for every Wayland surface created in the Wayland server.
// Not every WindowSurface maybe an application's Window though - those that are, are available
// through the WindowManager model.
//
// we support wl-shell and xdg-shell shell integration extensions. Both wl-shell and xdg-shell-v5
// are deprecated and additionally xdg-shell-v5 is partially broken in qtwayland.
//
// In any case, wl-shell doesn't provide all the features needed by appman, so clients using it will never work
// perfectly.
class WindowSurface : public QWaylandQuickSurface
{
Q_OBJECT
public:
WindowSurface(WaylandCompositor *comp, QWaylandClient *client, uint id, int version);
QWaylandSurface *surface() const;
QWaylandWlShellSurface *shellSurface() const;
QWaylandXdgSurface *xdgSurface() const;
WaylandCompositor *compositor() const;
QString applicationId() const;
bool isPopup() const;
QRect popupGeometry() const;
void sendResizing(const QSize &size);
qint64 processId() const;
QWindow *outputWindow() const;
void close();
Q_SIGNALS:
void pong();
void popupGeometryChanged();
void xdgSurfaceChanged();
private:
void setShellSurface(QWaylandWlShellSurface *ss);
private:
QWaylandSurface *m_surface;
WaylandCompositor *m_compositor;
QPointer<QWaylandWlShellSurface> m_wlSurface = nullptr;
QPointer<QWaylandXdgSurface> m_xdgSurface;
QPointer<QWaylandXdgToplevel> m_topLevel;
QPointer<QWaylandXdgPopup> m_popup;
friend class WaylandCompositor;
};
class WaylandCompositor : public QWaylandQuickCompositor // clazy:exclude=missing-qobject-macro
{
Q_OBJECT
public:
WaylandCompositor(QQuickWindow* window, const QString &waylandSocketName);
~WaylandCompositor() override;
void registerOutputWindow(QQuickWindow *window);
void setWatchdogTimeouts(std::chrono::milliseconds checkInterval,
std::chrono::milliseconds warnTimeout,
std::chrono::milliseconds killTimeout);
WaylandQtAMServerExtension *amExtension();
Q_SIGNALS:
void surfaceMapped(QtAM::WindowSurface *surface);
protected:
void doCreateSurface(QWaylandClient *client, uint id, int version);
void createWlSurface(QWaylandSurface *surface, const QWaylandResource &resource);
void onXdgSurfaceCreated(QWaylandXdgSurface *xdgSurface);
void onTopLevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *xdgSurface);
void onPopupCreated(QWaylandXdgPopup *popup, QWaylandXdgSurface *xdgSurface);
static QObject *preConstructor(QObject *parent);
static bool s_nestedLogging;
void setupLogging();
QWaylandWlShell *m_wlShell;
QWaylandXdgShell *m_xdgShell;
QVector<QWaylandOutput *> m_outputs;
WaylandQtAMServerExtension *m_amExtension;
QWaylandQtTextInputMethodManager *m_qtTextInputMethodManager;
QWaylandTextInputManager *m_textInputManager;
WaylandXdgWatchdog *m_xdgWatchdog;
};
QT_END_NAMESPACE_AM
#endif // QT_CONFIG(am_multi_process)
#endif // WAYLANDCOMPOSITOR_H
|