Rework how wl_output and kde-output-device are created

Create wl_outputs only for outputs in Workspace.
This commit is contained in:
Vlad Zahorodnii 2022-07-30 15:21:00 +03:00
parent c7293d95e0
commit ca6f84dad6
4 changed files with 21 additions and 28 deletions

View file

@ -133,7 +133,6 @@ void WaylandTestApplication::performStartup()
if (!platform()->initialize()) { if (!platform()->initialize()) {
std::exit(1); std::exit(1);
} }
waylandServer()->initPlatform();
// try creating the Wayland Backend // try creating the Wayland Backend
createInput(); createInput();

View file

@ -147,8 +147,6 @@ void ApplicationWayland::performStartup()
std::exit(1); std::exit(1);
} }
waylandServer()->initPlatform();
createInput(); createInput();
createInputMethod(); createInputMethod();
createTabletModeManager(); createTabletModeManager();

View file

@ -272,30 +272,6 @@ void WaylandServer::registerXdgGenericWindow(Window *window)
qCDebug(KWIN_CORE) << "Received invalid xdg shell window:" << window->surface(); qCDebug(KWIN_CORE) << "Received invalid xdg shell window:" << window->surface();
} }
void WaylandServer::initPlatform()
{
connect(kwinApp()->platform(), &Platform::outputAdded, this, &WaylandServer::handleOutputAdded);
connect(kwinApp()->platform(), &Platform::outputRemoved, this, &WaylandServer::handleOutputRemoved);
connect(kwinApp()->platform(), &Platform::outputEnabled, this, &WaylandServer::handleOutputEnabled);
connect(kwinApp()->platform(), &Platform::outputDisabled, this, &WaylandServer::handleOutputDisabled);
connect(kwinApp()->platform(), &Platform::primaryOutputChanged, this, [this](Output *primaryOutput) {
m_primary->setPrimaryOutput(primaryOutput ? primaryOutput->name() : QString());
});
if (auto primaryOutput = kwinApp()->platform()->primaryOutput()) {
m_primary->setPrimaryOutput(primaryOutput->name());
}
const QVector<Output *> outputs = kwinApp()->platform()->outputs();
for (Output *output : outputs) {
handleOutputAdded(output);
if (output->isEnabled()) {
handleOutputEnabled(output);
}
}
}
void WaylandServer::handleOutputAdded(Output *output) void WaylandServer::handleOutputAdded(Output *output)
{ {
if (!output->isPlaceholder() && !output->isNonDesktop()) { if (!output->isPlaceholder() && !output->isNonDesktop()) {
@ -561,6 +537,27 @@ void WaylandServer::initWorkspace()
}); });
} }
connect(kwinApp()->platform(), &Platform::primaryOutputChanged, this, [this](Output *primaryOutput) {
m_primary->setPrimaryOutput(primaryOutput ? primaryOutput->name() : QString());
});
if (auto primaryOutput = kwinApp()->platform()->primaryOutput()) {
m_primary->setPrimaryOutput(primaryOutput->name());
}
const auto availableOutputs = kwinApp()->platform()->outputs();
for (Output *output : availableOutputs) {
handleOutputAdded(output);
}
connect(kwinApp()->platform(), &Platform::outputAdded, this, &WaylandServer::handleOutputAdded);
connect(kwinApp()->platform(), &Platform::outputRemoved, this, &WaylandServer::handleOutputRemoved);
const auto outputs = workspace()->outputs();
for (Output *output : outputs) {
handleOutputEnabled(output);
}
connect(workspace(), &Workspace::outputAdded, this, &WaylandServer::handleOutputEnabled);
connect(workspace(), &Workspace::outputRemoved, this, &WaylandServer::handleOutputDisabled);
if (hasScreenLockerIntegration()) { if (hasScreenLockerIntegration()) {
initScreenLocker(); initScreenLocker();
} }

View file

@ -179,7 +179,6 @@ public:
*/ */
bool hasGlobalShortcutSupport() const; bool hasGlobalShortcutSupport() const;
void initPlatform();
void initWorkspace(); void initWorkspace();
KWaylandServer::ClientConnection *xWaylandConnection() const; KWaylandServer::ClientConnection *xWaylandConnection() const;