Port Workspace to Platform::{outputAdded,outputDisabled} signals
This commit is contained in:
parent
b0340dc774
commit
f956d701c4
2 changed files with 34 additions and 12 deletions
|
@ -213,14 +213,12 @@ void Workspace::init()
|
|||
}
|
||||
|
||||
Platform *platform = kwinApp()->platform();
|
||||
connect(platform, &Platform::outputEnabled, this, &Workspace::slotOutputEnabled);
|
||||
connect(platform, &Platform::outputDisabled, this, &Workspace::slotOutputDisabled);
|
||||
connect(platform, &Platform::outputAdded, this, &Workspace::slotPlatformOutputAdded);
|
||||
connect(platform, &Platform::outputRemoved, this, &Workspace::slotPlatformOutputRemoved);
|
||||
|
||||
const QVector<Output *> outputs = platform->outputs();
|
||||
for (Output *output : outputs) {
|
||||
if (output->isEnabled()) {
|
||||
slotOutputEnabled(output);
|
||||
}
|
||||
slotPlatformOutputAdded(output);
|
||||
}
|
||||
|
||||
m_screens->init();
|
||||
|
@ -1380,11 +1378,34 @@ Output *Workspace::outputAt(const QPointF &pos) const
|
|||
return bestOutput;
|
||||
}
|
||||
|
||||
void Workspace::slotOutputEnabled(Output *output)
|
||||
void Workspace::slotPlatformOutputAdded(Output *output)
|
||||
{
|
||||
if (output->isNonDesktop()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (output->isEnabled()) {
|
||||
addOutput(output);
|
||||
}
|
||||
|
||||
connect(output, &Output::enabledChanged, this, [this, output]() {
|
||||
if (output->isEnabled()) {
|
||||
addOutput(output);
|
||||
} else {
|
||||
removeOutput(output);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Workspace::slotPlatformOutputRemoved(Output *output)
|
||||
{
|
||||
if (!output->isNonDesktop()) {
|
||||
removeOutput(output);
|
||||
}
|
||||
}
|
||||
|
||||
void Workspace::addOutput(Output *output)
|
||||
{
|
||||
if (!m_activeOutput) {
|
||||
m_activeOutput = output;
|
||||
}
|
||||
|
@ -1405,14 +1426,12 @@ void Workspace::slotOutputEnabled(Output *output)
|
|||
Q_EMIT outputAdded(output);
|
||||
}
|
||||
|
||||
void Workspace::slotOutputDisabled(Output *output)
|
||||
void Workspace::removeOutput(Output *output)
|
||||
{
|
||||
if (output->isNonDesktop()) {
|
||||
if (!m_outputs.removeOne(output)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_outputs.removeOne(output);
|
||||
|
||||
if (m_activeOutput == output) {
|
||||
m_activeOutput = outputAt(output->geometry().center());
|
||||
}
|
||||
|
|
|
@ -539,8 +539,8 @@ private Q_SLOTS:
|
|||
void slotCurrentDesktopChangingCancelled();
|
||||
void slotDesktopAdded(VirtualDesktop *desktop);
|
||||
void slotDesktopRemoved(VirtualDesktop *desktop);
|
||||
void slotOutputEnabled(Output *output);
|
||||
void slotOutputDisabled(Output *output);
|
||||
void slotPlatformOutputAdded(Output *output);
|
||||
void slotPlatformOutputRemoved(Output *output);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
@ -619,6 +619,9 @@ private:
|
|||
Unmanaged *createUnmanaged(xcb_window_t windowId);
|
||||
void addUnmanaged(Unmanaged *c);
|
||||
|
||||
void addOutput(Output *output);
|
||||
void removeOutput(Output *output);
|
||||
|
||||
void addWaylandWindow(Window *window);
|
||||
void removeWaylandWindow(Window *window);
|
||||
|
||||
|
|
Loading…
Reference in a new issue