Place OSD windows again on size changes

Summary:
The position of an OSD is based on the size of the window. If the
size of the OSD changed, it would not be positioned correctly any more.

With this change the OSD window gets placed again if the size changes.
Thus it's also placed correctly even if the window changed it's size.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3720
This commit is contained in:
Martin Gräßlin 2016-12-18 10:39:04 +01:00
parent 1c394ab645
commit 6383f83047
2 changed files with 19 additions and 0 deletions

View file

@ -69,6 +69,18 @@ AbstractClient::AbstractClient()
connect(this, &AbstractClient::paletteChanged, this, &AbstractClient::triggerDecorationRepaint);
connect(Decoration::DecorationBridge::self(), &QObject::destroyed, this, &AbstractClient::destroyDecoration);
// replace on-screen-display on size changes
connect(this, &AbstractClient::geometryShapeChanged, this,
[this] (Toplevel *c, const QRect &old) {
Q_UNUSED(c)
if (isOnScreenDisplay() && !geometry().isEmpty() && old.size() != geometry().size()) {
QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop());
Placement::self()->place(this, area);
setGeometryRestore(geometry());
}
}
);
}
AbstractClient::~AbstractClient()

View file

@ -244,6 +244,13 @@ void PlasmaSurfaceTest::testOSDPlacement()
QCOMPARE(screens()->geometry(1), geometries.at(1));
QCOMPARE(c->geometry(), QRect(590, 649, 100, 50));
// change size of window
QSignalSpy geometryChangedSpy(c, &AbstractClient::geometryShapeChanged);
QVERIFY(geometryChangedSpy.isValid());
Test::render(surface.data(), QSize(200, 100), Qt::red);
QVERIFY(geometryChangedSpy.wait());
QCOMPARE(c->geometry(), QRect(540, 616, 200, 100));
}
void PlasmaSurfaceTest::testPanelTypeHasStrut_data()