Fix C++20 deprecated capture of *this in [=]

The exec() function is synchronous, so we can just replace [=] with
[&].

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I1b672b0ef456977fa0b898dff9c88f48765a3e41
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-08-02 09:02:27 +02:00
parent 63e2f90266
commit d8f0396961
13 changed files with 140 additions and 140 deletions

View File

@ -172,21 +172,21 @@ void tst_WaylandClient::activeWindowFollowsKeyboardFocus()
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
QCOMPOSITOR_TRY_VERIFY(window.isExposed());
QCOMPARE(window.focusInEventCount, 0);
exec([=] {
exec([&] {
keyboard()->sendEnter(s);
});
QTRY_COMPARE(window.focusInEventCount, 1);
QCOMPARE(QGuiApplication::focusWindow(), &window);
QCOMPARE(window.focusOutEventCount, 0);
exec([=] {
exec([&] {
keyboard()->sendLeave(s); // or implement setFocus in Keyboard
});
QTRY_COMPARE(window.focusOutEventCount, 1);
@ -200,7 +200,7 @@ void tst_WaylandClient::events()
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
@ -208,7 +208,7 @@ void tst_WaylandClient::events()
QCOMPARE(window.focusInEventCount, 0);
exec([=] {
exec([&] {
keyboard()->sendEnter(s);
});
QTRY_COMPARE(window.focusInEventCount, 1);
@ -222,14 +222,14 @@ void tst_WaylandClient::events()
// xkb_v1 1 libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode
uint keyCode = 80; // arbitrarily chosen
QCOMPARE(window.keyPressEventCount, 0);
exec([=] {
exec([&] {
keyboard()->sendKey(client(), keyCode - 8, Keyboard::key_state_pressed); // related with native scan code
});
QTRY_COMPARE(window.keyPressEventCount, 1);
QCOMPARE(window.keyCode, keyCode);
QCOMPARE(window.keyReleaseEventCount, 0);
exec([=] {
exec([&] {
keyboard()->sendKey(client(), keyCode - 8, Keyboard::key_state_released); // related with native scan code
});
QTRY_COMPARE(window.keyReleaseEventCount, 1);
@ -241,12 +241,12 @@ void tst_WaylandClient::events()
});
// Note: wl_touch.frame should not be the last event in a test until QTBUG-66563 is fixed.
// See also: QTBUG-66537
exec([=] {
exec([&] {
touch()->sendFrame(client());
});
QTRY_COMPARE(window.touchEventCount, 1);
exec([=] {
exec([&] {
touch()->sendUp(client(), touchId);
touch()->sendFrame(client());
});
@ -266,7 +266,7 @@ void tst_WaylandClient::events()
QTRY_COMPARE(window.mousePressPos, mousePressPos);
QCOMPARE(window.mouseReleaseEventCount, 0);
exec([=] {
exec([&] {
pointer()->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
pointer()->sendFrame(client());
});
@ -280,7 +280,7 @@ void tst_WaylandClient::backingStore()
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
@ -391,7 +391,7 @@ void tst_WaylandClient::touchDrag()
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
@ -405,7 +405,7 @@ void tst_WaylandClient::touchDrag()
&test, &DNDTest::touchDrag);
});
exec([=] {
exec([&] {
keyboard()->sendEnter(s);
});
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
@ -428,7 +428,7 @@ void tst_WaylandClient::mouseDrag()
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
@ -441,7 +441,7 @@ void tst_WaylandClient::mouseDrag()
&test, &DNDTest::finishMouseDrag);
});
exec([=] {
exec([&] {
keyboard()->sendEnter(s);
});
QTRY_COMPARE(QGuiApplication::focusWindow(), &window);
@ -516,7 +516,7 @@ void tst_WaylandClient::hiddenPopupParent()
// with the set_popup request.
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});
QCOMPOSITOR_TRY_VERIFY(toplevel.isExposed());
@ -553,7 +553,7 @@ void tst_WaylandClient::glWindow()
testWindow->show();
Surface *s = nullptr;
QCOMPOSITOR_TRY_VERIFY(s = surface());
exec([=] {
exec([&] {
sendShellSurfaceConfigure(s);
});

View File

@ -41,7 +41,7 @@ void tst_nooutput::noScreens()
// The window should not be exposed before the first xdg_surface configure event
QTRY_VERIFY(!window.isExposed());
exec([=] {
exec([&] {
xdgToplevel()->sendConfigure({0, 0}, {}); // Let the window decide the size
xdgSurface()->sendConfigure(nextSerial());
});

View File

@ -48,7 +48,7 @@ void tst_output::primaryScreen()
void tst_output::secondaryHiDpiScreen()
{
exec([=] {
exec([&] {
OutputData d;
d.position = {1920, 0}; // in global compositor space (not pixels)
d.mode.resolution = {800, 640};
@ -74,15 +74,15 @@ void tst_output::secondaryHiDpiScreen()
QCOMPARE(screen->geometry(), QRect(QPoint(1920, 0), QSize(400, 320)));
QCOMPARE(screen->virtualGeometry(), QRect(QPoint(0, 0), QSize(1920 + 800 / 2, 1080)));
exec([=] { remove(output(1)); });
exec([&] { remove(output(1)); });
}
// QTBUG-62044
void tst_output::addScreenWithGeometryChange()
{
const QPoint initialPosition = exec([=] { return output(0)->m_data.position; });
const QPoint initialPosition = exec([&] { return output(0)->m_data.position; });
exec([=] {
exec([&] {
auto *oldOutput = output(0);
auto *newOutput = add<Output>();
newOutput->m_data.mode.resolution = {1280, 720};
@ -98,7 +98,7 @@ void tst_output::addScreenWithGeometryChange()
QTRY_COMPARE(QGuiApplication::primaryScreen()->geometry(), QRect(QPoint(1280, 0), QSize(1920, 1080)));
// Remove the extra output and move the old one back
exec([=] {
exec([&] {
remove(output(1));
output()->m_data.position = initialPosition;
output()->sendGeometry();
@ -119,7 +119,7 @@ void tst_output::windowScreens()
QScreen *primaryScreen = QGuiApplication::screens().first();
QCOMPARE(window.screen(), primaryScreen);
exec([=] { add<Output>(); });
exec([&] { add<Output>(); });
QTRY_COMPARE(QGuiApplication::screens().size(), 2);
QScreen *secondaryScreen = QGuiApplication::screens().at(1);
@ -128,19 +128,19 @@ void tst_output::windowScreens()
window.setScreen(secondaryScreen);
QCOMPARE(window.screen(), secondaryScreen);
exec([=] {
exec([&] {
xdgToplevel()->surface()->sendEnter(output(0));
xdgToplevel()->surface()->sendEnter(output(1));
});
QTRY_COMPARE(window.screen(), primaryScreen);
exec([=] {
exec([&] {
xdgToplevel()->surface()->sendLeave(output(0));
});
QTRY_COMPARE(window.screen(), secondaryScreen);
exec([=] {
exec([&] {
remove(output(1));
});
QTRY_COMPARE(QGuiApplication::screens().size(), 1);
@ -186,7 +186,7 @@ void tst_output::removePrimaryScreen()
// QTBUG-72828
void tst_output::screenOrder()
{
exec([=] {
exec([&] {
add<Output>()->m_data.model = "Screen 1";
add<Output>()->m_data.model = "Screen 2";
});
@ -197,7 +197,7 @@ void tst_output::screenOrder()
QCOMPARE(screens[1]->model(), "Screen 1");
QCOMPARE(screens[2]->model(), "Screen 2");
exec([=] {
exec([&] {
remove(output(2));
remove(output(1));
});
@ -215,8 +215,8 @@ void tst_output::removeAllScreens()
const QString wlOutputPrimaryScreenModel = QGuiApplication::primaryScreen()->model();
// Get screen info so we can restore it after
auto screenInfo = exec([=] { return output()->m_data; });
exec([=] { remove(output()); });
auto screenInfo = exec([&] { return output()->m_data; });
exec([&] { remove(output()); });
// Make sure the wl_output is actually removed before we continue
QTRY_VERIFY(!QGuiApplication::primaryScreen() || QGuiApplication::primaryScreen()->model() != wlOutputPrimaryScreenModel);
@ -226,7 +226,7 @@ void tst_output::removeAllScreens()
window2.resize(400, 320);
window2.show();
exec([=] { add<Output>(screenInfo); });
exec([&] { add<Output>(screenInfo); });
// Things should be back to normal
QTRY_VERIFY(QGuiApplication::primaryScreen());

View File

@ -261,7 +261,7 @@ void tst_primaryselectionv1::createsPrimaryDevice()
void tst_primaryselectionv1::createsPrimaryDeviceForNewSeats()
{
exec([=] { add<Seat>(); });
exec([&] { add<Seat>(); });
QCOMPOSITOR_TRY_VERIFY(primarySelectionDevice(1));
}

View File

@ -192,14 +192,14 @@ void tst_WaylandReconnect::keyFocus()
configureWindow();
QTRY_VERIFY(window.isExposed());
exec([=] {
exec([&] {
m_comp->keyboard()->sendEnter(m_comp->surface());
});
QTRY_COMPARE(window.focusInEventCount, 1);
uint keyCode = 80;
QCOMPARE(window.keyPressEventCount, 0);
exec([=] {
exec([&] {
m_comp->keyboard()->sendKey(m_comp->client(), keyCode - 8, Keyboard::key_state_pressed);
});
QTRY_COMPARE(window.keyPressEventCount, 1);
@ -213,10 +213,10 @@ void tst_WaylandReconnect::keyFocus()
QTRY_COMPARE(window.focusOutEventCount, 1);
// fake the user explicitly focussing this window afterwards
exec([=] {
exec([&] {
m_comp->keyboard()->sendEnter(m_comp->surface());
});
exec([=] {
exec([&] {
m_comp->keyboard()->sendKey(m_comp->client(), keyCode - 8, Keyboard::key_state_pressed);
});
QTRY_COMPARE(window.focusInEventCount, 2);
@ -227,7 +227,7 @@ void tst_WaylandReconnect::keyFocus()
void tst_WaylandReconnect::configureWindow()
{
QCOMPOSITOR_TRY_VERIFY(m_comp->xdgToplevel());
m_comp->exec([=] {
m_comp->exec([&] {
m_comp->xdgToplevel()->sendConfigure({0, 0}, {});
const uint serial = m_comp->nextSerial(); // Let the window decide the size
m_comp->xdgSurface()->sendConfigure(serial);

View File

@ -33,12 +33,12 @@ void tst_scaling::scaledWindow()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy configureSpy(exec([=] { return xdgSurface(); }), &XdgSurface::configureCommitted);
QSignalSpy surfaceCommitSpy(exec([=] { return surface(); }), &Surface::commit);
QSignalSpy configureSpy(exec([&] { return xdgSurface(); }), &XdgSurface::configureCommitted);
QSignalSpy surfaceCommitSpy(exec([&] { return surface(); }), &Surface::commit);
const QSize configureSize(100, 100);
exec([=] {
exec([&] {
QVERIFY(fractionalScale());
fractionalScale()->send_preferred_scale(1.5 * 120);
xdgToplevel()->sendCompleteConfigure(configureSize);
@ -47,7 +47,7 @@ void tst_scaling::scaledWindow()
QTRY_COMPARE(configureSpy.count(), 1);
QCOMPARE(window.devicePixelRatio(), 1.5);
exec([=] {
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
QVERIFY(buffer);
QCOMPARE(buffer->size(), QSize(150, 150));
@ -61,7 +61,7 @@ void tst_scaling::scaledWindow()
QCOMPARE(window.size(), QSize(200,200));
QVERIFY(surfaceCommitSpy.wait());
exec([=] {
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
QVERIFY(buffer);
QCOMPARE(buffer->size(), QSize(300, 300));
@ -71,7 +71,7 @@ void tst_scaling::scaledWindow()
});
// dynamic scale change
exec([=] {
exec([&] {
QVERIFY(fractionalScale());
fractionalScale()->send_preferred_scale(2.5 * 120);
});
@ -79,7 +79,7 @@ void tst_scaling::scaledWindow()
QCOMPARE(window.size(), QSize(200,200));
QVERIFY(surfaceCommitSpy.wait());
exec([=] {
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
QVERIFY(buffer);
QCOMPARE(buffer->size(), QSize(500, 500));
@ -112,9 +112,9 @@ void tst_scaling::roundingPolicy()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy surfaceCommitSpy(exec([=] { return surface(); }), &Surface::commit);
QSignalSpy surfaceCommitSpy(exec([&] { return surface(); }), &Surface::commit);
exec([=] {
exec([&] {
QVERIFY(fractionalScale());
fractionalScale()->send_preferred_scale(scale * 120);
xdgToplevel()->sendCompleteConfigure();
@ -122,7 +122,7 @@ void tst_scaling::roundingPolicy()
QVERIFY(surfaceCommitSpy.wait());
exec([=] {
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
QVERIFY(buffer);
QCOMPARE(buffer->size(), expectedBufferSize);

View File

@ -70,7 +70,7 @@ void tst_seat::setsCursorOnEnter()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *surface = xdgSurface()->m_surface;
pointer()->sendEnter(surface, {0, 0});
pointer()->sendFrame(surface->resource()->client());
@ -81,13 +81,13 @@ void tst_seat::setsCursorOnEnter()
void tst_seat::usesEnterSerial()
{
QSignalSpy setCursorSpy(exec([=] { return pointer(); }), &Pointer::setCursor);
QSignalSpy setCursorSpy(exec([&] { return pointer(); }), &Pointer::setCursor);
QRasterWindow window;
window.resize(64, 64);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
uint enterSerial = exec([=] {
uint enterSerial = exec([&] {
return pointer()->sendEnter(xdgSurface()->m_surface, {0, 0});
});
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
@ -164,7 +164,7 @@ void tst_seat::simpleAxis()
WheelWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *p = pointer();
p->sendEnter(xdgToplevel()->surface(), {32, 32});
p->sendFrame(client());
@ -196,7 +196,7 @@ void tst_seat::fingerScroll()
WheelWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendEnter(xdgToplevel()->surface(), {32, 32});
@ -236,7 +236,7 @@ void tst_seat::fingerScroll()
QTRY_VERIFY(window.m_events.empty());
// Scroll horizontally as well
exec([=] {
exec([&] {
pointer()->sendAxisSource(client(), Pointer::axis_source_finger);
pointer()->sendAxis(client(), Pointer::axis_horizontal_scroll, 10);
pointer()->sendFrame(client());
@ -251,7 +251,7 @@ void tst_seat::fingerScroll()
}
// Scroll diagonally
exec([=] {
exec([&] {
pointer()->sendAxisSource(client(), Pointer::axis_source_finger);
pointer()->sendAxis(client(), Pointer::axis_horizontal_scroll, 10);
pointer()->sendAxis(client(), Pointer::axis_vertical_scroll, 10);
@ -275,7 +275,7 @@ void tst_seat::fingerScroll()
QVERIFY(window.m_events.empty());
// Sending axis_stop is mandatory when axis source == finger
exec([=] {
exec([&] {
pointer()->sendAxisStop(client(), Pointer::axis_vertical_scroll);
pointer()->sendFrame(client());
});
@ -293,7 +293,7 @@ void tst_seat::fingerScrollSlow()
WheelWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendEnter(xdgToplevel()->surface(), {32, 32});
@ -323,7 +323,7 @@ void tst_seat::highResolutionScroll()
WheelWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendEnter(xdgToplevel()->surface(), {32, 32});
@ -344,7 +344,7 @@ void tst_seat::highResolutionScroll()
QCOMPARE(e.pixelDelta, QPoint(0, 0));
}
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendAxisSource(c, Pointer::axis_source_wheel);
@ -369,7 +369,7 @@ void tst_seat::continuousScroll()
WheelWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendEnter(xdgToplevel()->surface(), {32, 32});
@ -429,7 +429,7 @@ void tst_seat::singleTap()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
@ -460,7 +460,7 @@ void tst_seat::singleTapFloat()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
t->sendDown(xdgToplevel()->surface(), {32.75, 32.25}, 1);
@ -491,7 +491,7 @@ void tst_seat::multiTouch()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
@ -563,7 +563,7 @@ void tst_seat::multiTouchUpAndMotionFrame()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
@ -612,7 +612,7 @@ void tst_seat::tapAndMoveInSameFrame()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
@ -644,7 +644,7 @@ void tst_seat::cancelTouch()
TouchWindow window;
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *t = touch();
auto *c = client();
t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);

View File

@ -100,7 +100,7 @@ void tst_seatv7::wheelDiscreteScroll()
QFETCH(uint, source);
exec([=] {
exec([&] {
auto *p = pointer();
auto *c = client();
p->sendEnter(xdgToplevel()->surface(), {32, 32});

View File

@ -93,8 +93,8 @@ uint DefaultCompositor::sendXdgShellPing()
void DefaultCompositor::xdgPingAndWaitForPong()
{
QSignalSpy pongSpy(exec([=] { return get<XdgWmBase>(); }), &XdgWmBase::pong);
uint serial = exec([=] { return sendXdgShellPing(); });
QSignalSpy pongSpy(exec([&] { return get<XdgWmBase>(); }), &XdgWmBase::pong);
uint serial = exec([&] { return sendXdgShellPing(); });
QTRY_COMPARE(pongSpy.size(), 1);
QTRY_COMPARE(pongSpy.first().at(0).toUInt(), serial);
}

View File

@ -51,8 +51,8 @@ void tst_surface::waitForFrameCallbackRaster()
TestWindow window;
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy bufferSpy(exec([=] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
QSignalSpy bufferSpy(exec([&] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
// We should get the first buffer without waiting for a frame callback
QTRY_COMPARE(bufferSpy.size(), 1);
@ -92,8 +92,8 @@ void tst_surface::waitForFrameCallbackGl()
TestWindow window;
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy bufferSpy(exec([=] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
QSignalSpy bufferSpy(exec([&] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
// We should get the first buffer without waiting for a frame callback
QTRY_COMPARE(bufferSpy.size(), 1);
@ -128,8 +128,8 @@ void tst_surface::negotiateShmFormat()
window.resize(64, 48);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy bufferSpy(exec([=] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
const uint serial = exec([=] { return xdgToplevel()->sendCompleteConfigure(); });
QSignalSpy bufferSpy(exec([&] { return xdgSurface()->m_surface; }), &Surface::bufferCommitted);
const uint serial = exec([&] { return xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committedConfigureSerial, serial);
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
@ -157,11 +157,11 @@ void tst_surface::createSubsurface()
QCOMPOSITOR_TRY_VERIFY(subSurface());
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
const Surface *mainSurface = exec([=] {return surface(0);});
const Surface *childSurface = exec([=] {return surface(1);});
const Surface *mainSurface = exec([&] {return surface(0);});
const Surface *childSurface = exec([&] {return surface(1);});
QSignalSpy mainSurfaceCommitSpy(mainSurface, &Surface::commit);
QSignalSpy childSurfaceCommitSpy(childSurface, &Surface::commit);
@ -187,7 +187,7 @@ void tst_surface::createSubsurfaceForHiddenParent()
window.resize(64, 64);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
window.hide();
@ -201,7 +201,7 @@ void tst_surface::createSubsurfaceForHiddenParent()
xdgPingAndWaitForPong();
// Make sure the subsurface was actually created
const Subsurface *subsurface = exec([=] {return subSurface(0);});
const Subsurface *subsurface = exec([&] {return subSurface(0);});
QVERIFY(subsurface);
}

View File

@ -151,7 +151,7 @@ void tst_xdgdecorationv1::clientSidePreferredByCompositor()
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QCOMPOSITOR_TRY_VERIFY(toplevelDecoration()->m_unsetModeRequested);
QVERIFY(window.frameMargins().isNull()); // We're still waiting for a configure
exec([=] {
exec([&] {
toplevelDecoration()->sendConfigure(XdgToplevelDecorationV1::mode_client_side);
xdgToplevel()->sendCompleteConfigure();
});
@ -165,7 +165,7 @@ void tst_xdgdecorationv1::initialFramelessWindowHint()
window.show();
QCOMPOSITOR_TRY_COMPARE(get<XdgDecorationManagerV1>()->resourceMap().size(), 1);
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=]{
exec([&]{
xdgToplevel()->sendCompleteConfigure();
});
QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);
@ -181,7 +181,7 @@ void tst_xdgdecorationv1::delayedFramelessWindowHint()
window.show();
QCOMPOSITOR_TRY_COMPARE(get<XdgDecorationManagerV1>()->resourceMap().size(), 1);
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=]{
exec([&]{
xdgToplevel()->sendCompleteConfigure();
});
QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial);

View File

@ -43,7 +43,7 @@ void tst_xdgoutput::primaryScreen()
{
// Verify that the client has bound to the global
QCOMPOSITOR_TRY_COMPARE(get<XdgOutputManagerV1>()->resourceMap().size(), 1);
exec([=] {
exec([&] {
auto *resource = xdgOutput()->resourceMap().value(client());
QCOMPARE(resource->version(), 3);
QCOMPARE(xdgOutput()->m_logicalGeometry.size(), QSize(1920, 1080));
@ -56,7 +56,7 @@ void tst_xdgoutput::primaryScreen()
void tst_xdgoutput::overrideGeometry()
{
exec([=] {
exec([&] {
auto *output = add<Output>();
auto *xdgOutput = get<XdgOutputManagerV1>()->getXdgOutput(output);
xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200);
@ -68,12 +68,12 @@ void tst_xdgoutput::overrideGeometry()
QTRY_COMPARE(s->size(), QSize(800, 1200));
QTRY_COMPARE(s->geometry().topLeft(), QPoint(10, 20));
exec([=] { remove(output(1)); });
exec([&] { remove(output(1)); });
}
void tst_xdgoutput::changeGeometry()
{
auto *xdgOutput = exec([=] {
auto *xdgOutput = exec([&] {
auto *output = add<Output>();
auto *xdgOutput = get<XdgOutputManagerV1>()->getXdgOutput(output);
xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200);
@ -84,7 +84,7 @@ void tst_xdgoutput::changeGeometry()
auto *screen = QGuiApplication::screens()[1];
QTRY_COMPARE(screen->size(), QSize(800, 1200));
exec([=] {
exec([&] {
xdgOutput->sendLogicalSize(QSize(1024, 768));
});
@ -92,21 +92,21 @@ void tst_xdgoutput::changeGeometry()
// done event. If we TRY_COMPARE immediately, we risk that the client just hasn't handled the
// logical_size request yet, so we add a screen and verify it on the client side just to give
// the client a chance to mess up.
exec([=] { add<Output>(); });
exec([&] { add<Output>(); });
QTRY_COMPARE(QGuiApplication::screens().size(), 3);
exec([=] { remove(output(2)); });
exec([&] { remove(output(2)); });
// The logical_size event should have been handled by now, but state should not have been applied yet.
QTRY_COMPARE(screen->size(), QSize(800, 1200));
exec([=] {
exec([&] {
xdgOutput->m_output->sendDone();
});
// Finally, the size should change
QTRY_COMPARE(screen->size(), QSize(1024, 768));
exec([=] { remove(output(1)); });
exec([&] { remove(output(1)); });
}
void tst_xdgoutput::outputCreateEnterRace()
@ -118,13 +118,13 @@ void tst_xdgoutput::outputCreateEnterRace()
window.resize(400, 320);
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
exec([=] { xdgToplevel()->surface()->sendEnter(output(0));});
exec([&] { xdgToplevel()->surface()->sendEnter(output(0));});
QTRY_COMPARE(QGuiApplication::screens().size(), 1);
QScreen *primaryScreen = QGuiApplication::screens().first();
QCOMPARE(window.screen(), primaryScreen);
auto *out = exec([=] {
auto *out = exec([&] {
return add<Output>();
});
@ -138,7 +138,7 @@ void tst_xdgoutput::outputCreateEnterRace()
QTRY_COMPARE(QGuiApplication::screens().size(), 2);
QTRY_COMPARE(window.screen(), QGuiApplication::screens()[1]);
exec([=] { remove(out); });
exec([&] { remove(out); });
m_config.autoConfigure = false;
m_config.autoEnter = true;
}

View File

@ -60,13 +60,13 @@ void tst_xdgshell::basicConfigure()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy configureSpy(exec([=] { return xdgSurface(); }), &XdgSurface::configureCommitted);
QSignalSpy configureSpy(exec([&] { return xdgSurface(); }), &XdgSurface::configureCommitted);
QTRY_VERIFY(window.isVisible());
// The window should not be exposed before the first xdg_surface configure event
QTRY_VERIFY(!window.isExposed());
exec([=] {
exec([&] {
xdgToplevel()->sendConfigure({0, 0}, {}); // Let the window decide the size
});
@ -74,9 +74,9 @@ void tst_xdgshell::basicConfigure()
QTRY_VERIFY(!window.isExposed()); //Window should not be exposed before the first configure event
QVERIFY(configureSpy.isEmpty());
const uint serial = exec([=] { return nextSerial(); });
const uint serial = exec([&] { return nextSerial(); });
exec([=] {
exec([&] {
xdgSurface()->sendConfigure(serial);
});
@ -102,17 +102,17 @@ void tst_xdgshell::configureSize()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy configureSpy(exec([=] { return xdgSurface(); }), &XdgSurface::configureCommitted);
QSignalSpy configureSpy(exec([&] { return xdgSurface(); }), &XdgSurface::configureCommitted);
const QSize configureSize(60, 40);
exec([=] {
exec([&] {
xdgToplevel()->sendCompleteConfigure(configureSize);
});
QTRY_COMPARE(configureSpy.size(), 1);
exec([=] {
exec([&] {
Buffer *buffer = xdgToplevel()->surface()->m_committed.buffer;
QVERIFY(buffer);
QCOMPARE(buffer->size(), configureSize);
@ -128,7 +128,7 @@ void tst_xdgshell::configureStates()
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
const QSize windowedSize(320, 240);
const uint windowedSerial = exec([=] {
const uint windowedSerial = exec([&] {
return xdgToplevel()->sendCompleteConfigure(windowedSize, { XdgToplevel::state_activated });
});
QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committedConfigureSerial, windowedSerial);
@ -146,7 +146,7 @@ void tst_xdgshell::configureStates()
Qt::WindowActive)); // Just make sure it eventually get's set correctly
const QSize screenSize(640, 480);
const uint maximizedSerial = exec([=] {
const uint maximizedSerial = exec([&] {
return xdgToplevel()->sendCompleteConfigure(screenSize, { XdgToplevel::state_activated, XdgToplevel::state_maximized });
});
QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committedConfigureSerial, maximizedSerial);
@ -155,7 +155,7 @@ void tst_xdgshell::configureStates()
QCOMPARE(window.frameGeometry().size(), screenSize);
// QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
const uint fullscreenSerial = exec([=] {
const uint fullscreenSerial = exec([&] {
return xdgToplevel()->sendCompleteConfigure(screenSize, { XdgToplevel::state_activated, XdgToplevel::state_fullscreen });
});
QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committedConfigureSerial, fullscreenSerial);
@ -165,7 +165,7 @@ void tst_xdgshell::configureStates()
// QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
// The window should remember its original size
const uint restoreSerial = exec([=] {
const uint restoreSerial = exec([&] {
return xdgToplevel()->sendCompleteConfigure({0, 0}, { XdgToplevel::state_activated });
});
QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committedConfigureSerial, restoreSerial);
@ -184,7 +184,7 @@ void tst_xdgshell::configureBounds()
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
// Take xdg_toplevel.configure_bounds into account only if the configure event has 0x0 size.
const uint serial1 = exec([=] {
const uint serial1 = exec([&] {
xdgToplevel()->sendConfigureBounds(QSize(800, 600));
return xdgToplevel()->sendCompleteConfigure(QSize(0, 0), { XdgToplevel::state_activated });
});
@ -192,7 +192,7 @@ void tst_xdgshell::configureBounds()
QCOMPARE(window.frameGeometry().size(), QSize(800, 600));
// Window size in xdg_toplevel configure events takes precedence over the configure bounds.
const uint serial2 = exec([=] {
const uint serial2 = exec([&] {
xdgToplevel()->sendConfigureBounds(QSize(800, 600));
return xdgToplevel()->sendCompleteConfigure(QSize(1600, 900), { XdgToplevel::state_activated });
});
@ -220,11 +220,11 @@ void tst_xdgshell::popup()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
QSignalSpy toplevelConfigureSpy(exec([=] { return xdgSurface(); }), &XdgSurface::configureCommitted);
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
QSignalSpy toplevelConfigureSpy(exec([&] { return xdgSurface(); }), &XdgSurface::configureCommitted);
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QTRY_COMPARE(toplevelConfigureSpy.size(), 1);
uint clickSerial = exec([=] {
uint clickSerial = exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -238,7 +238,7 @@ void tst_xdgshell::popup()
QTRY_VERIFY(window.m_popup);
QCOMPOSITOR_TRY_VERIFY(xdgPopup());
QSignalSpy popupConfigureSpy(exec([=] { return xdgPopup()->m_xdgSurface; }), &XdgSurface::configureCommitted);
QSignalSpy popupConfigureSpy(exec([&] { return xdgPopup()->m_xdgSurface; }), &XdgSurface::configureCommitted);
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_grabbed);
QCOMPOSITOR_TRY_COMPARE(xdgPopup()->m_grabSerial, clickSerial);
@ -246,13 +246,13 @@ void tst_xdgshell::popup()
QVERIFY(!popup->isExposed()); // wait for configure
QRect rect1 = QRect(100, 100, 100, 100);
exec([=] { xdgPopup()->sendConfigure(rect1); });
exec([&] { xdgPopup()->sendConfigure(rect1); });
// Nothing should happen before the *xdg_surface* configure
QTRY_VERIFY(!popup->isExposed()); // Popup shouldn't be exposed before the first configure event
QVERIFY(popupConfigureSpy.isEmpty());
const uint configureSerial = exec([=] {
const uint configureSerial = exec([&] {
return xdgPopup()->m_xdgSurface->sendConfigure();
});
@ -265,9 +265,9 @@ void tst_xdgshell::popup()
QCOMPARE(popup->geometry(), rect1);
QRect rect2 = QRect(50, 50, 150, 150);
exec([=] { xdgPopup()->sendConfigure(rect2); });
exec([&] { xdgPopup()->sendConfigure(rect2); });
const uint configureSerial2 = exec([=] {
const uint configureSerial2 = exec([&] {
return xdgPopup()->m_xdgSurface->sendConfigure();
});
@ -318,10 +318,10 @@ void tst_xdgshell::tooltipOnPopup()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -335,11 +335,11 @@ void tst_xdgshell::tooltipOnPopup()
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup());
exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_grabbed);
exec([=] {
exec([&] {
auto *surface = xdgPopup()->surface();
auto *p = pointer();
auto *c = client();
@ -351,7 +351,7 @@ void tst_xdgshell::tooltipOnPopup()
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
QCOMPOSITOR_TRY_VERIFY(!xdgPopup(1)->m_grabbed);
@ -400,10 +400,10 @@ void tst_xdgshell::tooltipAndSiblingPopup()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -417,11 +417,11 @@ void tst_xdgshell::tooltipAndSiblingPopup()
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup());
exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
exec([=] {
exec([&] {
auto *surface = xdgPopup()->surface();
auto *p = pointer();
auto *c = client();
@ -433,7 +433,7 @@ void tst_xdgshell::tooltipAndSiblingPopup()
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
@ -488,10 +488,10 @@ void tst_xdgshell::switchPopups()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -505,13 +505,13 @@ void tst_xdgshell::switchPopups()
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup());
exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_grabbed);
QSignalSpy firstDestroyed(exec([=] { return xdgPopup(); }), &XdgPopup::destroyRequested);
QSignalSpy firstDestroyed(exec([&] { return xdgPopup(); }), &XdgPopup::destroyRequested);
exec([=] {
exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -536,7 +536,7 @@ void tst_xdgshell::switchPopups()
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_parentXdgSurface == xdgToplevel()->m_xdgSurface);
// For good measure just check that configuring works as usual
exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
exec([&] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
}
@ -560,10 +560,10 @@ void tst_xdgshell::hidePopupParent()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
exec([=] {
exec([&] {
auto *surface = xdgToplevel()->surface();
auto *p = pointer();
auto *c = client();
@ -574,7 +574,7 @@ void tst_xdgshell::hidePopupParent()
p->sendFrame(c);
});
QCOMPOSITOR_TRY_VERIFY(xdgPopup());
exec([=] {
exec([&] {
xdgPopup()->sendConfigure(QRect(100, 100, 100, 100));
xdgPopup()->m_xdgSurface->sendConfigure();
});
@ -595,9 +595,9 @@ void tst_xdgshell::pongs()
// Verify that the client has bound to the global
QCOMPOSITOR_TRY_COMPARE(get<XdgWmBase>()->resourceMap().size(), 1);
QSignalSpy pongSpy(exec([=] { return get<XdgWmBase>(); }), &XdgWmBase::pong);
const uint serial = exec([=] { return nextSerial(); });
exec([=] {
QSignalSpy pongSpy(exec([&] { return get<XdgWmBase>(); }), &XdgWmBase::pong);
const uint serial = exec([&] { return nextSerial(); });
exec([&] {
auto *base = get<XdgWmBase>();
wl_resource *resource = base->resourceMap().first()->handle;
base->send_ping(resource, serial);
@ -634,7 +634,7 @@ void tst_xdgshell::windowGeometry()
window.show();
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
exec([=] { xdgToplevel()->sendCompleteConfigure(); });
exec([&] { xdgToplevel()->sendCompleteConfigure(); });
QSize marginsSize;
marginsSize.setWidth(window.frameMargins().left() + window.frameMargins().right());
@ -666,7 +666,7 @@ void tst_xdgshell::foreignSurface()
// Just do something to make sure we don't destroy the surface before
// the pointer events above are handled.
QSignalSpy spy(exec([=] { return surface(newSurfaceIndex); }), &Surface::commit);
QSignalSpy spy(exec([&] { return surface(newSurfaceIndex); }), &Surface::commit);
wl_surface_commit(foreignSurface);
QTRY_COMPARE(spy.size(), 1);