KWayland

subcompositor.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "subcompositor.h"
7 #include "event_queue.h"
8 #include "subsurface.h"
9 #include "surface.h"
10 #include "wayland_pointer_p.h"
11 // Wayland
12 #include <wayland-client-protocol.h>
13 
14 namespace KWayland
15 {
16 namespace Client
17 {
18 class Q_DECL_HIDDEN SubCompositor::Private
19 {
20 public:
21  WaylandPointer<wl_subcompositor, wl_subcompositor_destroy> subCompositor;
22  EventQueue *queue = nullptr;
23 };
24 
25 SubCompositor::SubCompositor(QObject *parent)
26  : QObject(parent)
27  , d(new Private)
28 {
29 }
30 
31 SubCompositor::~SubCompositor()
32 {
33  release();
34 }
35 
37 {
38  d->subCompositor.release();
39 }
40 
41 void SubCompositor::destroy()
42 {
43  d->subCompositor.destroy();
44 }
45 
46 void SubCompositor::setup(wl_subcompositor *subcompositor)
47 {
48  Q_ASSERT(subcompositor);
49  Q_ASSERT(!d->subCompositor.isValid());
50  d->subCompositor.setup(subcompositor);
51 }
52 
53 SubSurface *SubCompositor::createSubSurface(QPointer<Surface> surface, QPointer<Surface> parentSurface, QObject *parent)
54 {
55  Q_ASSERT(isValid());
56  SubSurface *s = new SubSurface(surface, parentSurface, parent);
57  auto w = wl_subcompositor_get_subsurface(d->subCompositor, *surface, *parentSurface);
58  if (d->queue) {
59  d->queue->addProxy(w);
60  }
61  s->setup(w);
62  return s;
63 }
64 
65 bool SubCompositor::isValid() const
66 {
67  return d->subCompositor.isValid();
68 }
69 
70 SubCompositor::operator wl_subcompositor *()
71 {
72  return d->subCompositor;
73 }
74 
75 SubCompositor::operator wl_subcompositor *() const
76 {
77  return d->subCompositor;
78 }
79 
80 EventQueue *SubCompositor::eventQueue()
81 {
82  return d->queue;
83 }
84 
85 void SubCompositor::setEventQueue(EventQueue *queue)
86 {
87  d->queue = queue;
88 }
89 
90 }
91 }
virtual void release(quint64 objid)
Wrapper for the wl_subsurface interface.
Definition: subsurface.h:40
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
void setup(wl_subsurface *subsurface)
Setup this SubSurface to manage the subsurface.
Definition: subsurface.cpp:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 03:56:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.