From 894679e2af1f5da908e8f2b2d399aaf5287d5775 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 13 Jan 2023 07:47:24 +0400 Subject: client: Attempt to request activate even if there's no focus window The compositor is likely to display some indication even if the activation fails, so it's helpful to always do the request. Change-Id: Ia3a8075e471d5a4b619f420ee166e7146f1229b8 Reviewed-by: Aleix Pol Gonzalez (cherry picked from commit f0de6ff9606ea2bf0622f8d8c67e8688be86bf0d) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index c1462e07..d339bb56 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -535,8 +535,12 @@ bool QWaylandXdgSurface::requestActivate() activation->activate(token, window()->wlSurface()); qunsetenv("XDG_ACTIVATION_TOKEN"); return true; - } else if (const auto focusWindow = QGuiApplication::focusWindow()) { - const auto wlWindow = static_cast(focusWindow->handle()); + } else { + const auto focusWindow = QGuiApplication::focusWindow(); + // At least GNOME requires to request the token in order to get the + // focus stealing prevention indication, so requestXdgActivationToken call + // is still necessary in that case. + const auto wlWindow = focusWindow ? static_cast(focusWindow->handle()) : m_window; if (const auto xdgSurface = qobject_cast(wlWindow->shellSurface())) { if (const auto seat = wlWindow->display()->lastInputDevice()) { const auto tokenProvider = activation->requestXdgActivationToken( -- cgit v1.2.1