KWaylandServer

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 KWaylandServer
15 {
16 class FilteredDisplayPrivate
17 {
18 public:
19  FilteredDisplayPrivate(FilteredDisplay *_q);
20  FilteredDisplay *q;
21  static bool globalFilterCallback(const wl_client *client, const wl_global *global, void *data)
22  {
23  auto t = static_cast<FilteredDisplayPrivate *>(data);
24  auto clientConnection = t->q->getConnection(const_cast<wl_client *>(client));
25  auto interface = wl_global_get_interface(global);
26  auto name = QByteArray::fromRawData(interface->name, strlen(interface->name));
27  return t->q->allowInterface(clientConnection, name);
28  };
29 };
30 
31 FilteredDisplayPrivate::FilteredDisplayPrivate(FilteredDisplay *_q)
32  : q(_q)
33 {
34 }
35 
36 FilteredDisplay::FilteredDisplay(QObject *parent)
37  : Display(parent)
38  , d(new FilteredDisplayPrivate(this))
39 {
40  connect(this, &Display::runningChanged, [this](bool running) {
41  if (!running) {
42  return;
43  }
44  wl_display_set_global_filter(*this, FilteredDisplayPrivate::globalFilterCallback, d.data());
45  });
46 }
47 
48 FilteredDisplay::~FilteredDisplay()
49 {
50 }
51 
52 }
QString name(const QVariant &location)
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-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.