Commit d299e849 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Make sure we get to decide where our panels go

Workaround a lack of API from Qt where it will decide to move the panels
around without us being able to control it.
This patch overrides the QWindow::screenDestroyed slot to be able to decide
where to move the Panel or whether it needs to be removed. This is
considered a workaround and should be removed once the new API is in and
released.

See also: https://codereview.qt-project.org/#/c/88351/
BUG: 335710
parent 5c230211
......@@ -871,4 +871,18 @@ void PanelView::showTemporarily()
t->start();
}
void PanelView::screenDestroyed(QObject* screen)
{
// NOTE: this is overriding the screen destroyed slot, we need to do this because
// otherwise Qt goes mental and starts moving our panels. See:
// https://codereview.qt-project.org/#/c/88351/
QScreen* newScreen = m_corona->screenForId(containment()->lastScreen());
if (newScreen)
setScreen(newScreen);
else
m_corona->removePanel(this);
}
#include "moc_panelview.cpp"
......@@ -125,6 +125,7 @@ private Q_SLOTS:
void containmentChanged();
void statusChanged(Plasma::Types::ItemStatus);
void restoreAutoHide();
void screenDestroyed(QObject* screen);
private:
void integrateScreen();
......
......@@ -520,6 +520,12 @@ QRect ShellCorona::availableScreenRect(int id) const
return r;
}
QScreen* ShellCorona::screenForId(int screenId) const
{
DesktopView* v = d->views.value(screenId);
return v ? v->screen() : Q_NULLPTR;
}
PanelView *ShellCorona::panelView(Plasma::Containment *containment) const
{
return d->panelViews.value(containment);
......@@ -626,16 +632,15 @@ void ShellCorona::removeDesktop(DesktopView *view)
screenInvariants();
}
void ShellCorona::removePanel(QObject *screen)
void ShellCorona::removePanel(PanelView* panelView)
{
foreach(PanelView* v, d->panelViews) {
if (v->screen() == screen) {
Plasma::Containment* cont = v->containment();
d->waitingPanels << cont;
d->panelViews.remove(cont);
v->deleteLater();
}
}
Plasma::Containment* cont = panelView->containment();
d->waitingPanels << cont;
d->panelViews.remove(cont);
panelView->deleteLater();
emit availableScreenRectChanged();
emit availableScreenRegionChanged();
}
Plasma::Containment *ShellCorona::createContainmentForActivity(const QString& activity, int screenNum)
......@@ -686,7 +691,6 @@ void ShellCorona::createWaitingPanels()
d->panelViews[cont]->show();
connect(cont, SIGNAL(destroyed(QObject*)), this, SLOT(containmentDeleted(QObject*)));
connect(screen, SIGNAL(destroyed(QObject*)), this, SLOT(removePanel(QObject*)));
}
d->waitingPanels = stillWaitingPanels;
emit availableScreenRectChanged();
......
......@@ -80,6 +80,9 @@ public:
KScreen::Config* screensConfiguration() const;
void removePanel(PanelView* panelView);
QScreen* screenForId(int screenId) const;
public Q_SLOTS:
/**
* Request saving applicationConfig on disk, it's event compressed, not immediate
......@@ -143,7 +146,6 @@ private Q_SLOTS:
void containmentDeleted(QObject* cont);
void outputEnabledChanged();
void removePanel(QObject* cont);
void removeDesktop(DesktopView* screen);
void addOutput(KScreen::Output* output);
void primaryOutputChanged();
......
Supports Markdown
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