File indexing completed on 2024-11-10 04:57:26
0001 /* 0002 SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "filtered_display.h" 0008 #include "display.h" 0009 0010 #include <wayland-server.h> 0011 0012 #include <QByteArray> 0013 0014 namespace KWin 0015 { 0016 class FilteredDisplayPrivate 0017 { 0018 public: 0019 FilteredDisplayPrivate(FilteredDisplay *_q); 0020 FilteredDisplay *q; 0021 static bool globalFilterCallback(const wl_client *client, const wl_global *global, void *data) 0022 { 0023 auto t = static_cast<FilteredDisplayPrivate *>(data); 0024 auto clientConnection = t->q->getConnection(const_cast<wl_client *>(client)); 0025 auto interface = wl_global_get_interface(global); 0026 auto name = QByteArray::fromRawData(interface->name, strlen(interface->name)); 0027 return t->q->allowInterface(clientConnection, name); 0028 }; 0029 }; 0030 0031 FilteredDisplayPrivate::FilteredDisplayPrivate(FilteredDisplay *_q) 0032 : q(_q) 0033 { 0034 } 0035 0036 FilteredDisplay::FilteredDisplay(QObject *parent) 0037 : Display(parent) 0038 , d(new FilteredDisplayPrivate(this)) 0039 { 0040 connect(this, &Display::runningChanged, [this](bool running) { 0041 if (!running) { 0042 return; 0043 } 0044 wl_display_set_global_filter(*this, FilteredDisplayPrivate::globalFilterCallback, d.get()); 0045 }); 0046 } 0047 0048 FilteredDisplay::~FilteredDisplay() 0049 { 0050 } 0051 0052 } 0053 0054 #include "moc_filtered_display.cpp"