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.
This commit is contained in:
parent
2ed00e4afe
commit
062f1c3c87
3 changed files with 17 additions and 7 deletions
|
@ -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 *);
|
||||
|
|
Loading…
Reference in a new issue