From 6383f8304711719fe22371474138efc144adc750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sun, 18 Dec 2016 10:39:04 +0100 Subject: [PATCH] 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 --- abstract_client.cpp | 12 ++++++++++++ autotests/integration/plasma_surface_test.cpp | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/abstract_client.cpp b/abstract_client.cpp index f86dd84389..cfa7f93f31 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -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() diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 7f58936b0a..5cb620c779 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -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()