diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 29489acda89..29c7cbf55d9 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -567,16 +567,18 @@ bool QWaylandXdgSurface::requestActivate() if (const auto xdgSurface = qobject_cast(wlWindow->shellSurface())) appId = xdgSurface->m_appId; - if (const auto seat = wlWindow->display()->lastInputDevice()) { - const auto tokenProvider = activation->requestXdgActivationToken( - wlWindow->display(), wlWindow->wlSurface(), seat->serial(), appId); - connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, - [this](const QString &token) { - m_shell->activation()->activate(token, window()->wlSurface()); - }); - connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater); - return true; - } + std::optional serial; + if (const auto seat = wlWindow->display()->lastInputDevice()) + serial = seat->serial(); + + const auto tokenProvider = activation->requestXdgActivationToken( + wlWindow->display(), wlWindow->wlSurface(), serial, appId); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, + [this](const QString &token) { + m_shell->activation()->activate(token, window()->wlSurface()); + }); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater); + return true; } } return false;