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 
19 class Q_DECL_HIDDEN SubCompositor::Private
20 {
21 public:
22  WaylandPointer<wl_subcompositor, wl_subcompositor_destroy> subCompositor;
23  EventQueue *queue = nullptr;
24 };
25 
26 SubCompositor::SubCompositor(QObject *parent)
27  : QObject(parent)
28  , d(new Private)
29 {
30 }
31 
32 SubCompositor::~SubCompositor()
33 {
34  release();
35 }
36 
37 void SubCompositor::release()
38 {
39  d->subCompositor.release();
40 }
41 
42 void SubCompositor::destroy()
43 {
44  d->subCompositor.destroy();
45 }
46 
47 void SubCompositor::setup(wl_subcompositor *subcompositor)
48 {
49  Q_ASSERT(subcompositor);
50  Q_ASSERT(!d->subCompositor.isValid());
51  d->subCompositor.setup(subcompositor);
52 }
53 
54 SubSurface *SubCompositor::createSubSurface(QPointer<Surface> surface, QPointer<Surface> parentSurface, QObject *parent)
55 {
56  Q_ASSERT(isValid());
57  SubSurface *s = new SubSurface(surface, parentSurface, parent);
58  auto w = wl_subcompositor_get_subsurface(d->subCompositor, *surface, *parentSurface);
59  if (d->queue) {
60  d->queue->addProxy(w);
61  }
62  s->setup(w);
63  return s;
64 }
65 
66 bool SubCompositor::isValid() const
67 {
68  return d->subCompositor.isValid();
69 }
70 
71 SubCompositor::operator wl_subcompositor*()
72 {
73  return d->subCompositor;
74 }
75 
76 SubCompositor::operator wl_subcompositor*() const
77 {
78  return d->subCompositor;
79 }
80 
81 EventQueue *SubCompositor::eventQueue()
82 {
83  return d->queue;
84 }
85 
86 void SubCompositor::setEventQueue(EventQueue *queue)
87 {
88  d->queue = queue;
89 }
90 
91 }
92 }
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
Wrapper for the wl_subsurface interface.
Definition: subsurface.h:41
void setup(wl_subsurface *subsurface)
Setup this SubSurface to manage the subsurface.
Definition: subsurface.cpp:66
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 22:49:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.