From bad07cde1386575fa88bfd50a3ec2fa3dd2b1ee7 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Thu, 26 May 2022 23:49:16 +0800 Subject: [PATCH] shell: move keyboard focus code from frontend to backend It makes the code easier to be maintained across different platforms. CCBUG: 453166 CCBUG: 352476 --- shell/shellcorona.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index ff1c45546..436441aa1 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -265,18 +265,18 @@ void ShellCorona::init() return; } PanelView *activePanel = qobject_cast(qGuiApp->focusWindow()); - Plasma::Containment *containmentToActivate = nullptr; - if (activePanel) { - auto it = m_panelViews.constFind(activePanel->containment()); - it++; - if (it != m_panelViews.constEnd()) { - containmentToActivate = it.value()->containment(); - } + if (!activePanel) { + activePanel = m_panelViews.values().first(); } - if (!containmentToActivate) { - containmentToActivate = m_panelViews.values().first()->containment(); + + if (activePanel->containment()->status() != Plasma::Types::AcceptingInputStatus) { + activePanel->containment()->setStatus(Plasma::Types::AcceptingInputStatus); + + auto nextItem = activePanel->rootObject()->nextItemInFocusChain(); + if (nextItem) { + nextItem->forceActiveFocus(); + } } - emit containmentToActivate->activated(); }); }