From 73bfe648ef1b7f41702814be611e31a1effec68e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 15 Jul 2021 12:08:19 +0300 Subject: [PATCH] wayland: Notify Qt about activated/deactivated windows Currently, internal windows are not marked as active. This breaks focus logic in QtQuick. --- src/input.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 3dd7da8583..e99c0d60fe 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -53,6 +53,7 @@ #include // Qt #include +#include #include @@ -964,14 +965,9 @@ class InternalWindowEventFilter : public InputEventFilter { return e.isAccepted(); } bool keyEvent(QKeyEvent *event) override { - const QList &internalClients = workspace()->internalClients(); - if (internalClients.isEmpty()) { - return false; - } + const QList &clients = workspace()->internalClients(); QWindow *found = nullptr; - auto it = internalClients.end(); - do { - it--; + for (auto it = clients.crbegin(); it != clients.crend(); ++it) { if (QWindow *w = (*it)->internalWindow()) { if (!w->isVisible()) { continue; @@ -991,7 +987,11 @@ class InternalWindowEventFilter : public InputEventFilter { found = w; break; } - } while (it != internalClients.begin()); + } + if (m_lastFocus != found) { + m_lastFocus = found; + QWindowSystemInterface::handleWindowActivated(found); + } if (!found) { return false; } @@ -1096,6 +1096,7 @@ private: QSet m_pressedIds; QPointF m_lastGlobalTouchPos; QPointF m_lastLocalTouchPos; + QPointer m_lastFocus; }; class DecorationEventFilter : public InputEventFilter {