KWaylandServer

compositor_interface.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #include "compositor_interface.h"
8 #include "display.h"
9 #include "region_interface_p.h"
10 #include "surface_interface.h"
11 
12 #include "qwayland-server-wayland.h"
13 
14 namespace KWaylandServer
15 {
16 static const int s_version = 4;
17 
18 class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor
19 {
20 public:
21  CompositorInterfacePrivate(CompositorInterface *q, Display *display);
22 
23  CompositorInterface *q;
24  Display *display;
25 
26 protected:
27  void compositor_create_surface(Resource *resource, uint32_t id) override;
28  void compositor_create_region(Resource *resource, uint32_t id) override;
29 };
30 
31 CompositorInterfacePrivate::CompositorInterfacePrivate(CompositorInterface *q, Display *display)
32  : QtWaylandServer::wl_compositor(*display, s_version)
33  , q(q)
34  , display(display)
35 {
36 }
37 
38 void CompositorInterfacePrivate::compositor_create_surface(Resource *resource, uint32_t id)
39 {
40  wl_resource *surfaceResource = wl_resource_create(resource->client(), &wl_surface_interface, resource->version(), id);
41  if (!surfaceResource) {
42  wl_resource_post_no_memory(resource->handle);
43  return;
44  }
45  Q_EMIT q->surfaceCreated(new SurfaceInterface(q, surfaceResource));
46 }
47 
48 void CompositorInterfacePrivate::compositor_create_region(Resource *resource, uint32_t id)
49 {
50  wl_resource *regionResource = wl_resource_create(resource->client(), &wl_region_interface, resource->version(), id);
51  if (!regionResource) {
52  wl_resource_post_no_memory(resource->handle);
53  return;
54  }
55  new RegionInterface(regionResource);
56 }
57 
58 CompositorInterface::CompositorInterface(Display *display, QObject *parent)
59  : QObject(parent)
60  , d(new CompositorInterfacePrivate(this, display))
61 {
62 }
63 
64 CompositorInterface::~CompositorInterface()
65 {
66 }
67 
69 {
70  return d->display;
71 }
72 
73 } // namespace KWaylandServer
Class holding the Wayland server display loop.
Definition: display.h:47
Display * display() const
Returns the Display object for this CompositorInterface.
QObject * parent() const const
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.