Commit a195223a authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

wayland: Fix Qt clients not being maximized initially

Currently, Qt clients send two maximize requests separated by the
initial commit. From spec's perspective, this is totally fine, the
client should receive two configure events with "maximized" state.

But because changeMaximize() in XdgToplevelClient and setMaximized()
operate on two different maximize modes, the second maximize request
will trick kwin into thinking that the client should be restored.
parent 4acea542
......@@ -878,7 +878,7 @@ void AbstractClient::maximize(MaximizeMode m)
void AbstractClient::setMaximize(bool vertically, bool horizontally)
// changeMaximize() flips the state, so change from set->flip
const MaximizeMode oldMode = maximizeMode();
const MaximizeMode oldMode = requestedMaximizeMode();
oldMode & MaximizeHorizontal ? !horizontally : horizontally,
oldMode & MaximizeVertical ? !vertically : vertically,
......@@ -100,6 +100,7 @@ private Q_SLOTS:
void testXdgWindowGeometryMaximize();
void testPointerInputTransform();
void testReentrantSetFrameGeometry();
void testDoubleMaximize();
void TestXdgShellClient::initTestCase()
......@@ -1558,5 +1559,38 @@ void TestXdgShellClient::testReentrantSetFrameGeometry()
void TestXdgShellClient::testDoubleMaximize()
// This test verifies that the case where a client issues two set_maximized() requests
// separated by the initial commit is handled properly.
// Create the test surface.
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(, nullptr, Test::CreationSetup::CreateOnly));
// Wait for the compositor to respond with a configure event.
QSignalSpy configureRequestedSpy(, &XdgShellSurface::configureRequested);
QCOMPARE(configureRequestedSpy.count(), 1);
QSize size = configureRequestedSpy.last().at(0).value<QSize>();
QCOMPARE(size, QSize(1280, 1024));
XdgShellSurface::States states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>();
// Send another set_maximized() request, but do not attach any buffer yet.
// The compositor must respond with another configure event even if the state hasn't changed.
QCOMPARE(configureRequestedSpy.count(), 2);
size = configureRequestedSpy.last().at(0).value<QSize>();
QCOMPARE(size, QSize(1280, 1024));
states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>();
#include "xdgshellclient_test.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment