From 53a3740082d0e5c50a9f539f0a307e02ca6ab3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 9 Jun 2016 16:50:48 +0200 Subject: [PATCH] Request the resize of ShellSurface after Decoration updated the borders when maximizing Summary: This ensures that we don't send a size request with the borders still added. Test Plan: Verified that a maximized window is properly sized and doesn't have empty borders Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D1807 --- autotests/wayland/maximize_test.cpp | 16 ++++++++++++++++ shell_client.cpp | 26 +++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/autotests/wayland/maximize_test.cpp b/autotests/wayland/maximize_test.cpp index 24fbf9d0b2..b694d7f20f 100644 --- a/autotests/wayland/maximize_test.cpp +++ b/autotests/wayland/maximize_test.cpp @@ -176,6 +176,9 @@ void TestMaximized::testMaximizedPassedToDeco() surface->damage(QRect(0, 0, 100, 50)); surface->commit(Surface::CommitFlag::None); + QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged); + QVERIFY(sizeChangedSpy.isValid()); + QVERIFY(clientAddedSpy.isEmpty()); QVERIFY(clientAddedSpy.wait()); auto client = clientAddedSpy.first().first().value(); @@ -186,12 +189,25 @@ void TestMaximized::testMaximizedPassedToDeco() QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); // now maximize + QVERIFY(sizeChangedSpy.isEmpty()); + QSignalSpy bordersChangedSpy(decoration, &KDecoration2::Decoration::bordersChanged); + QVERIFY(bordersChangedSpy.isValid()); QSignalSpy maximizedChangedSpy(decoration->client().data(), &KDecoration2::DecoratedClient::maximizedChanged); QVERIFY(maximizedChangedSpy.isValid()); workspace()->slotWindowMaximize(); QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); QCOMPARE(maximizedChangedSpy.count(), 1); QCOMPARE(maximizedChangedSpy.last().first().toBool(), true); + QCOMPARE(bordersChangedSpy.count(), 1); + QCOMPARE(decoration->borderLeft(), 0); + QCOMPARE(decoration->borderBottom(), 0); + QCOMPARE(decoration->borderRight(), 0); + QVERIFY(decoration->borderTop() != 0); + + QVERIFY(sizeChangedSpy.isEmpty()); + QVERIFY(sizeChangedSpy.wait()); + QCOMPARE(sizeChangedSpy.count(), 1); + QCOMPARE(sizeChangedSpy.first().first().toSize(), QSize(1280, 1024 - decoration->borderTop())); // now unmaximize again workspace()->slotWindowMaximize(); diff --git a/shell_client.cpp b/shell_client.cpp index e76b86126e..ee00cd2be7 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -572,19 +572,6 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust) if (horizontal) m_maximizeMode = MaximizeMode(m_maximizeMode ^ MaximizeHorizontal); } - - // TODO: check rules - if (m_maximizeMode == MaximizeFull) { - m_geomMaximizeRestore = geometry(); - requestGeometry(workspace()->clientArea(MaximizeArea, this)); - workspace()->raiseClient(this); - } else { - if (m_geomMaximizeRestore.isValid()) { - requestGeometry(m_geomMaximizeRestore); - } else { - requestGeometry(workspace()->clientArea(PlacementArea, this)); - } - } // TODO: add more checks as in Client // call into decoration update borders @@ -602,6 +589,19 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust) } changeMaximizeRecursion = false; } + + // TODO: check rules + if (m_maximizeMode == MaximizeFull) { + m_geomMaximizeRestore = geometry(); + requestGeometry(workspace()->clientArea(MaximizeArea, this)); + workspace()->raiseClient(this); + } else { + if (m_geomMaximizeRestore.isValid()) { + requestGeometry(m_geomMaximizeRestore); + } else { + requestGeometry(workspace()->clientArea(PlacementArea, this)); + } + } } MaximizeMode ShellClient::maximizeMode() const