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 {