File indexing completed on 2024-12-22 05:09:24

0001 /*
0002     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 #ifndef WAYLAND_SUBCOMPOSITOR_H
0007 #define WAYLAND_SUBCOMPOSITOR_H
0008 
0009 #include <QObject>
0010 #include <QPointer>
0011 
0012 #include "KWayland/Client/kwaylandclient_export.h"
0013 
0014 struct wl_subcompositor;
0015 
0016 namespace KWayland
0017 {
0018 namespace Client
0019 {
0020 class EventQueue;
0021 class SubSurface;
0022 class Surface;
0023 
0024 /**
0025  * @short Wrapper for the wl_subcompositor interface.
0026  *
0027  * This class is a convenient wrapper for the wl_subcompositor interface.
0028  * The main purpose of this class is to create SubSurfaces.
0029  *
0030  * To create an instance use Registry::createSubCompositor.
0031  *
0032  * @see Registry
0033  **/
0034 class KWAYLANDCLIENT_EXPORT SubCompositor : public QObject
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit SubCompositor(QObject *parent = nullptr);
0039     ~SubCompositor() override;
0040 
0041     /**
0042      * @returns @c true if managing a wl_subcompositor.
0043      **/
0044     bool isValid() const;
0045     /**
0046      * Setup this SubCompositor to manage the @p subcompositor.
0047      * When using Registry::createSubCompositor there is no need to call this
0048      * method.
0049      **/
0050     void setup(wl_subcompositor *subcompositor);
0051     /**
0052      * Releases the wl_subcompositor interface.
0053      * After the interface has been released the SubCompositor instance is no
0054      * longer valid and can be setup with another wl_subcompositor interface.
0055      **/
0056     void release();
0057     /**
0058      * Destroys the data held by this SubCompositor.
0059      * This method is supposed to be used when the connection to the Wayland
0060      * server goes away. If the connection is not valid anymore, it's not
0061      * possible to call release anymore as that calls into the Wayland
0062      * connection and the call would fail. This method cleans up the data, so
0063      * that the instance can be deleted or set up to a new wl_subcompositor interface
0064      * once there is a new connection available.
0065      *
0066      * @see release
0067      **/
0068     void destroy();
0069 
0070     /**
0071      * Sets the @p queue to use for creating a SubSurface.
0072      **/
0073     void setEventQueue(EventQueue *queue);
0074     /**
0075      * @returns The event queue to use for creating a SubSurface.
0076      **/
0077     EventQueue *eventQueue();
0078 
0079     /**
0080      * Creates and setup a new SubSurface with @p parent.
0081      * @param parent The parent to pass to the Surface.
0082      * @returns The new created Surface
0083      **/
0084     SubSurface *createSubSurface(QPointer<Surface> surface, QPointer<Surface> parentSurface, QObject *parent = nullptr);
0085 
0086     operator wl_subcompositor *();
0087     operator wl_subcompositor *() const;
0088 
0089 Q_SIGNALS:
0090     /**
0091      * The corresponding global for this interface on the Registry got removed.
0092      *
0093      * This signal gets only emitted if the Compositor got created by
0094      * Registry::createSubCompositor
0095      *
0096      * @since 5.5
0097      **/
0098     void removed();
0099 
0100 private:
0101     class Private;
0102     QScopedPointer<Private> d;
0103 };
0104 
0105 }
0106 }
0107 
0108 #endif