Client: Stop requesting activation on every focus object change

Currently, windows with xdg-toplevel surface role request window activation
every time the focus object changes. It conflicts with the compositor's
activation and stacking order policies.

For example, when a window is minimized, the compositor will start an
animation and move focus to the next window. If that window activates
itself, it can be raised in the stack and start covering the minimized
window, thus making it look as if no animation is played at all.

This activation logic was introduced as part of qt-shell activation
model in a7bb7210ac76a397b4aec8d8f32d902dc932d855. On the other hand,
with the introduction of the xdg-activation-v1 protocol, there is a
better way to pass input focus, so drop the qt-shell hack in favor of
that.

Fixes: QTBUG-111377
Pick-to: 6.5
Change-Id: I8ed19f1be17f49fa9748b1cb5fdd0070791d2ecd
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Vlad Zahorodnii 2023-02-21 18:41:11 +02:00
parent fb79f4c3bd
commit cbab88861b

View File

@ -88,19 +88,6 @@ QWaylandIntegration::QWaylandIntegration()
QWaylandWindow::fixedToplevelPositions = QWaylandWindow::fixedToplevelPositions =
!qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS"); !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
// ### Not ideal...
// We don't want to use QPlatformWindow::requestActivate here, since that gives a warning
// for most shells. Also, we don't want to put this into the specific shells that can use
// it, since we want to support more than one shell in one client.
// In addition, this will send a new requestActivate when the focus object changes, even if
// the focus window stays the same.
QObject::connect(qApp, &QGuiApplication::focusObjectChanged, qApp, [](){
QWindow *fw = QGuiApplication::focusWindow();
auto *w = fw ? static_cast<QWaylandWindow*>(fw->handle()) : nullptr;
if (w && w->shellSurface())
w->shellSurface()->requestActivate();
});
} }
QWaylandIntegration::~QWaylandIntegration() QWaylandIntegration::~QWaylandIntegration()