When maximizing a window raise client and gain focus

BUG: 418938 FIXED-IN: 5.20
This commit is contained in:
Benjamin Port 2020-07-17 11:19:38 +02:00 committed by Vlad Zahorodnii
parent 0ec34afdcc
commit 9225848fb0
2 changed files with 31 additions and 0 deletions

View file

@ -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> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> xdgShellSurface(Test::createXdgShellStableSurface(surface.data()));
auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> 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<Toplevel *>{client, client2}));
workspace()->performWindowOperation(client, Options::MaximizeOp);
QVERIFY(client->isActive());
QVERIFY(!client2->isActive());
QCOMPARE(workspace()->stackingOrder(), (QList<Toplevel *>{client2, client}));
xdgShellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(client));
xdgShellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(client2));
}
WAYLANDTEST_MAIN(TestMaximized)
#include "maximize_test.moc"

View file

@ -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();