From 9225848fb0fba5f32bbc95d672a316711378d4b7 Mon Sep 17 00:00:00 2001 From: Benjamin Port Date: Fri, 17 Jul 2020 11:19:38 +0200 Subject: [PATCH] When maximizing a window raise client and gain focus BUG: 418938 FIXED-IN: 5.20 --- autotests/integration/maximize_test.cpp | 27 +++++++++++++++++++++++++ useractions.cpp | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp index c0eee6cf4b..77ad38cf2c 100644 --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -56,6 +56,7 @@ private Q_SLOTS: void testInitiallyMaximizedBorderless(); void testBorderlessMaximizedWindow(); void testBorderlessMaximizedWindowNoClientSideDecoration(); + void testMaximizedGainFocusAndBeActivated(); }; void TestMaximized::initTestCase() @@ -426,5 +427,31 @@ void TestMaximized::testBorderlessMaximizedWindowNoClientSideDecoration() QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); } +void TestMaximized::testMaximizedGainFocusAndBeActivated() +{ + // This test verifies that a window will be raised and gain focus when it's maximized + QScopedPointer surface(Test::createSurface()); + QScopedPointer xdgShellSurface(Test::createXdgShellStableSurface(surface.data())); + auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QScopedPointer surface2(Test::createSurface()); + QScopedPointer xdgShellSurface2(Test::createXdgShellStableSurface(surface2.data())); + auto client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); + + QVERIFY(!client->isActive()); + QVERIFY(client2->isActive()); + QCOMPARE(workspace()->stackingOrder(), (QList{client, client2})); + + workspace()->performWindowOperation(client, Options::MaximizeOp); + + QVERIFY(client->isActive()); + QVERIFY(!client2->isActive()); + QCOMPARE(workspace()->stackingOrder(), (QList{client2, client})); + + xdgShellSurface.reset(); + QVERIFY(Test::waitForWindowDestroyed(client)); + xdgShellSurface2.reset(); + QVERIFY(Test::waitForWindowDestroyed(client2)); +} + WAYLANDTEST_MAIN(TestMaximized) #include "maximize_test.moc" diff --git a/useractions.cpp b/useractions.cpp index 08e9811285..1b565506f5 100644 --- a/useractions.cpp +++ b/useractions.cpp @@ -1071,15 +1071,19 @@ void Workspace::performWindowOperation(AbstractClient* c, Options::WindowOperati case Options::MaximizeOp: c->maximize(c->maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull); + takeActivity(c, ActivityFocus | ActivityRaise); break; case Options::HMaximizeOp: c->maximize(c->maximizeMode() ^ MaximizeHorizontal); + takeActivity(c, ActivityFocus | ActivityRaise); break; case Options::VMaximizeOp: c->maximize(c->maximizeMode() ^ MaximizeVertical); + takeActivity(c, ActivityFocus | ActivityRaise); break; case Options::RestoreOp: c->maximize(MaximizeRestore); + takeActivity(c, ActivityFocus | ActivityRaise); break; case Options::MinimizeOp: c->minimize();