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

KDE's Doxygen guidelines are available online.