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();
|
Platform *platform = kwinApp()->platform();
|
||||||
connect(platform, &Platform::outputEnabled, this, &Workspace::slotOutputEnabled);
|
connect(platform, &Platform::outputAdded, this, &Workspace::slotPlatformOutputAdded);
|
||||||
connect(platform, &Platform::outputDisabled, this, &Workspace::slotOutputDisabled);
|
connect(platform, &Platform::outputRemoved, this, &Workspace::slotPlatformOutputRemoved);
|
||||||
|
|
||||||
const QVector<Output *> outputs = platform->outputs();
|
const QVector<Output *> outputs = platform->outputs();
|
||||||
for (Output *output : outputs) {
|
for (Output *output : outputs) {
|
||||||
if (output->isEnabled()) {
|
slotPlatformOutputAdded(output);
|
||||||
slotOutputEnabled(output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_screens->init();
|
m_screens->init();
|
||||||
|
@ -1380,11 +1378,34 @@ Output *Workspace::outputAt(const QPointF &pos) const
|
||||||
return bestOutput;
|
return bestOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotOutputEnabled(Output *output)
|
void Workspace::slotPlatformOutputAdded(Output *output)
|
||||||
{
|
{
|
||||||
if (output->isNonDesktop()) {
|
if (output->isNonDesktop()) {
|
||||||
return;
|
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) {
|
if (!m_activeOutput) {
|
||||||
m_activeOutput = output;
|
m_activeOutput = output;
|
||||||
}
|
}
|
||||||
|
@ -1405,14 +1426,12 @@ void Workspace::slotOutputEnabled(Output *output)
|
||||||
Q_EMIT outputAdded(output);
|
Q_EMIT outputAdded(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::slotOutputDisabled(Output *output)
|
void Workspace::removeOutput(Output *output)
|
||||||
{
|
{
|
||||||
if (output->isNonDesktop()) {
|
if (!m_outputs.removeOne(output)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputs.removeOne(output);
|
|
||||||
|
|
||||||
if (m_activeOutput == output) {
|
if (m_activeOutput == output) {
|
||||||
m_activeOutput = outputAt(output->geometry().center());
|
m_activeOutput = outputAt(output->geometry().center());
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,8 +539,8 @@ private Q_SLOTS:
|
||||||
void slotCurrentDesktopChangingCancelled();
|
void slotCurrentDesktopChangingCancelled();
|
||||||
void slotDesktopAdded(VirtualDesktop *desktop);
|
void slotDesktopAdded(VirtualDesktop *desktop);
|
||||||
void slotDesktopRemoved(VirtualDesktop *desktop);
|
void slotDesktopRemoved(VirtualDesktop *desktop);
|
||||||
void slotOutputEnabled(Output *output);
|
void slotPlatformOutputAdded(Output *output);
|
||||||
void slotOutputDisabled(Output *output);
|
void slotPlatformOutputRemoved(Output *output);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -619,6 +619,9 @@ private:
|
||||||
Unmanaged *createUnmanaged(xcb_window_t windowId);
|
Unmanaged *createUnmanaged(xcb_window_t windowId);
|
||||||
void addUnmanaged(Unmanaged *c);
|
void addUnmanaged(Unmanaged *c);
|
||||||
|
|
||||||
|
void addOutput(Output *output);
|
||||||
|
void removeOutput(Output *output);
|
||||||
|
|
||||||
void addWaylandWindow(Window *window);
|
void addWaylandWindow(Window *window);
|
||||||
void removeWaylandWindow(Window *window);
|
void removeWaylandWindow(Window *window);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue