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 | #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 | |
36 | void SubCompositor::release() |
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(pointer: 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(wl_subcompositor: d->subCompositor, surface: *surface, parent: *parentSurface); |
58 | if (d->queue) { |
59 | d->queue->addProxy(proxy: 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 | } |
92 | |
93 | #include "moc_subcompositor.cpp" |
94 |