KWayland

filtered_display.cpp
1 /*
2  SPDX-FileCopyrightText: 2017 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "filtered_display.h"
8 #include "display.h"
9 
10 #include <wayland-server.h>
11 
12 #include <QByteArray>
13 
14 namespace KWayland
15 {
16 namespace Server
17 {
18 
19 class FilteredDisplay::Private
20 {
21 public:
22  Private(FilteredDisplay *_q);
23  FilteredDisplay *q;
24  static bool globalFilterCallback(const wl_client *client, const wl_global *global, void *data)
25  {
26  auto t = static_cast<FilteredDisplay::Private*>(data);
27  auto clientConnection = t->q->getConnection(const_cast<wl_client*>(client));
28  auto interface = wl_global_get_interface(global);
29  auto name = QByteArray::fromRawData(interface->name, strlen(interface->name));
30  return t->q->allowInterface(clientConnection, name);
31  };
32 };
33 
34 FilteredDisplay::Private::Private(FilteredDisplay *_q):
35  q(_q)
36 {}
37 
38 
39 FilteredDisplay::FilteredDisplay(QObject *parent):
40  Display(parent),
41  d(new Private(this))
42 {
43  connect(this, &Display::runningChanged, [this](bool running) {
44  if (!running) {
45  return;
46  }
47  wl_display_set_global_filter(*this, Private::globalFilterCallback, d.data());
48  });
49 }
50 
51 FilteredDisplay::~FilteredDisplay()
52 {
53 }
54 
55 }
56 }
QByteArray fromRawData(const char *data, int size)
T * data() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 22:48:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.