client: Support Xdg activation across shell surfaces

XDG activation operates on wl_surfaces, which can be used on all shell
types.

For the case of self activation there is was cast to the xdg
shellintegration on the focused window in order to populate the appId.
Only this part needs to be guarded, not the whole activation.

Pick-to: 6.6
Pick-to: 6.7
Change-Id: If44cc800b7cd98141ba05ba5d1cf0812ef777e7a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: David Redondo <qt@david-redondo.de>
This commit is contained in:
David Edmundson 2023-10-30 16:29:45 +00:00
parent ef30575d37
commit 00fc00115d

View File

@ -637,17 +637,20 @@ bool QWaylandXdgSurface::requestActivate()
// focus stealing prevention indication, so requestXdgActivationToken call
// is still necessary in that case.
const auto wlWindow = focusWindow ? static_cast<QWaylandWindow*>(focusWindow->handle()) : m_window;
if (const auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(wlWindow->shellSurface())) {
if (const auto seat = wlWindow->display()->lastInputDevice()) {
const auto tokenProvider = activation->requestXdgActivationToken(
wlWindow->display(), wlWindow->wlSurface(), seat->serial(), xdgSurface->m_appId);
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
[this, tokenProvider](const QString &token) {
m_shell->activation()->activate(token, window()->wlSurface());
tokenProvider->deleteLater();
});
return true;
}
QString appId;
if (const auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(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, tokenProvider](const QString &token) {
m_shell->activation()->activate(token, window()->wlSurface());
tokenProvider->deleteLater();
});
return true;
}
}
}