KWayland

global.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 "global.h"
7 #include "display.h"
8 #include "global_p.h"
9 // wayland
10 #include <wayland-server.h>
11 
12 namespace KWayland
13 {
14 namespace Server
15 {
16 Global::Private::Private(Display *d, const wl_interface *interface, quint32 version)
17  : display(d)
18  , m_interface(interface)
19  , m_version(version)
20 {
21 }
22 
23 Global::Private::~Private() = default;
24 
25 void Global::Private::bind(wl_client *client, void *data, uint32_t version, uint32_t id)
26 {
27  auto d = reinterpret_cast<Private *>(data);
28  d->bind(client, version, id);
29 }
30 
31 void Global::Private::create()
32 {
33  Q_ASSERT(!global);
34  global = wl_global_create(*display, m_interface, m_version, this, bind);
35 }
36 
37 Global::Global(Global::Private *d, QObject *parent)
38  : QObject(parent)
39  , d(d)
40 {
41 }
42 
43 Global::~Global()
44 {
45  destroy();
46 }
47 
48 void Global::create()
49 {
50  d->create();
51 }
52 
53 void Global::destroy()
54 {
55  if (!d->global) {
56  return;
57  }
58  Q_EMIT aboutToDestroyGlobal();
59  wl_global_destroy(d->global);
60  d->global = nullptr;
61 }
62 
63 bool Global::isValid() const
64 {
65  return d->global != nullptr;
66 }
67 
68 Global::operator wl_global *() const
69 {
70  return d->global;
71 }
72 
73 Global::operator wl_global *()
74 {
75  return d->global;
76 }
77 
78 Display *Global::display()
79 {
80  return d->display;
81 }
82 
83 }
84 }
Class holding the Wayland server display loop.
Definition: display.h:86
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 Sep 25 2021 22:51:29 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.