1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6#ifndef WAYLAND_SUBCOMPOSITOR_H
7#define WAYLAND_SUBCOMPOSITOR_H
8
9#include <QObject>
10#include <QPointer>
11
12#include "KWayland/Client/kwaylandclient_export.h"
13
14struct wl_subcompositor;
15
16namespace KWayland
17{
18namespace Client
19{
20class EventQueue;
21class SubSurface;
22class Surface;
23
24/**
25 * @short Wrapper for the wl_subcompositor interface.
26 *
27 * This class is a convenient wrapper for the wl_subcompositor interface.
28 * The main purpose of this class is to create SubSurfaces.
29 *
30 * To create an instance use Registry::createSubCompositor.
31 *
32 * @see Registry
33 **/
34class KWAYLANDCLIENT_EXPORT SubCompositor : public QObject
35{
36 Q_OBJECT
37public:
38 explicit SubCompositor(QObject *parent = nullptr);
39 ~SubCompositor() override;
40
41 /**
42 * @returns @c true if managing a wl_subcompositor.
43 **/
44 bool isValid() const;
45 /**
46 * Setup this SubCompositor to manage the @p subcompositor.
47 * When using Registry::createSubCompositor there is no need to call this
48 * method.
49 **/
50 void setup(wl_subcompositor *subcompositor);
51 /**
52 * Releases the wl_subcompositor interface.
53 * After the interface has been released the SubCompositor instance is no
54 * longer valid and can be setup with another wl_subcompositor interface.
55 **/
56 void release();
57 /**
58 * Destroys the data held by this SubCompositor.
59 * This method is supposed to be used when the connection to the Wayland
60 * server goes away. If the connection is not valid anymore, it's not
61 * possible to call release anymore as that calls into the Wayland
62 * connection and the call would fail. This method cleans up the data, so
63 * that the instance can be deleted or set up to a new wl_subcompositor interface
64 * once there is a new connection available.
65 *
66 * @see release
67 **/
68 void destroy();
69
70 /**
71 * Sets the @p queue to use for creating a SubSurface.
72 **/
73 void setEventQueue(EventQueue *queue);
74 /**
75 * @returns The event queue to use for creating a SubSurface.
76 **/
77 EventQueue *eventQueue();
78
79 /**
80 * Creates and setup a new SubSurface with @p parent.
81 * @param parent The parent to pass to the Surface.
82 * @returns The new created Surface
83 **/
84 SubSurface *createSubSurface(QPointer<Surface> surface, QPointer<Surface> parentSurface, QObject *parent = nullptr);
85
86 operator wl_subcompositor *();
87 operator wl_subcompositor *() const;
88
89Q_SIGNALS:
90 /**
91 * The corresponding global for this interface on the Registry got removed.
92 *
93 * This signal gets only emitted if the Compositor got created by
94 * Registry::createSubCompositor
95 *
96 * @since 5.5
97 **/
98 void removed();
99
100private:
101 class Private;
102 QScopedPointer<Private> d;
103};
104
105}
106}
107
108#endif
109

source code of kwayland/src/client/subcompositor.h