Commit 062f1c3c authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

Let WaylandServer::findOutput tell us about an output given an OutputInterface

Makes for more readable code and allows to reuse the lookup without
adding the boilerplate.
parent 2ed00e4a
......@@ -137,13 +137,7 @@ void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamInterface *
return;
}
const auto outputs = kwinApp()->platform()->enabledOutputs();
AbstractWaylandOutput *streamOutput = nullptr;
for (auto output : outputs) {
if (static_cast<AbstractWaylandOutput *>(output)->waylandOutput() == outputIface) {
streamOutput = static_cast<AbstractWaylandOutput *>(output);
}
}
AbstractWaylandOutput *streamOutput = waylandServer()->findOutput(outputIface);
if (!streamOutput) {
waylandStream->sendFailed(i18n("Could not find output"));
......
......@@ -7,6 +7,7 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "wayland_server.h"
#include "abstract_wayland_output.h"
#include "x11client.h"
#include "platform.h"
#include "composite.h"
......@@ -212,6 +213,18 @@ void WaylandServer::registerXdgGenericClient(AbstractClient *client)
qCDebug(KWIN_CORE) << "Received invalid xdg client:" << client->surface();
}
AbstractWaylandOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface *outputIface) const
{
AbstractWaylandOutput *outputFound = nullptr;
const auto outputs = kwinApp()->platform()->enabledOutputs();
for (auto output : outputs) {
if (static_cast<AbstractWaylandOutput *>(output)->waylandOutput() == outputIface) {
outputFound = static_cast<AbstractWaylandOutput *>(output);
}
}
return outputFound;
}
class KWinDisplay : public KWaylandServer::FilteredDisplay
{
public:
......
......@@ -69,6 +69,7 @@ class Toplevel;
class XdgPopupClient;
class XdgSurfaceClient;
class XdgToplevelClient;
class AbstractWaylandOutput;
class KWIN_EXPORT WaylandServer : public QObject
{
......@@ -235,6 +236,8 @@ public:
m_linuxDmabufBuffers.remove(buffer);
}
AbstractWaylandOutput *findOutput(KWaylandServer::OutputInterface *output) const;
Q_SIGNALS:
void shellClientAdded(KWin::AbstractClient *);
void shellClientRemoved(KWin::AbstractClient *);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment