Skip to content

Commit 0d8cde4

Browse files
committed
fix: enforce baseLayer focus when launcher becomes visible
To address the low-probability issue where the launcher loses keyboard focus upon opening (preventing direct text input), this commit explicitly calls forceActiveFocus() on the baseLayer (InputEventItem) when LauncherController.visible becomes true. The focus acquisition check is deferred via Qt.callLater() to avoid false warnings caused by QML's asynchronous focus event processing. Unlike previous attempts that focused the searchEdit directly (which violated the design requirement of not activating the search bar visually upon open), this approach ensures the root item safely receives key events and forwards them to the search edit without triggering unwanted visual states. 修复启动器以极低概率打开时丢失键盘焦点(无法直接输入文本)的问题。 在启动器显示(LauncherController.visible 为 true)时,显式调用 baseLayer (InputEventItem) 的 forceActiveFocus() 强制获取活跃焦点。 焦点获取检查通过 Qt.callLater() 延迟执行,避免因 QML 焦点事件的 异步处理特性导致的误报警告。 与之前直接聚焦 searchEdit 的尝试(违背了打开时不直接激活搜索框 的设计要求)不同,此方法确保根节点能安全地接收按键事件并将其转发 给搜索框,同时不会触发不需要的视觉激活状态。 PMS: BUG-301743
1 parent c5982f0 commit 0d8cde4

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

qml/FullscreenFrame.qml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,15 @@ InputEventItem {
887887
Connections {
888888
target: LauncherController
889889
function onVisibleChanged() {
890-
// only do these clean-up steps on launcher get hide
891-
if (LauncherController.visible) return
890+
if (LauncherController.visible) {
891+
baseLayer.forceActiveFocus()
892+
Qt.callLater(() => {
893+
if (!baseLayer.activeFocus) {
894+
console.warn("[LaunchpadFocus] FullscreenFrame: BUG_WARNING - baseLayer failed to acquire activeFocus after forceActiveFocus()!")
895+
}
896+
})
897+
return
898+
}
892899
// clear searchEdit text
893900
searchEdit.text = ""
894901
if (listviewPage.currentItem) {

qml/windowed/WindowedFrame.qml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,15 @@ InputEventItem {
305305
Connections {
306306
target: LauncherController
307307
function onVisibleChanged() {
308-
// only do these clean-up steps on launcher get hide
309-
if (LauncherController.visible) return
308+
if (LauncherController.visible) {
309+
baseLayer.forceActiveFocus()
310+
Qt.callLater(() => {
311+
if (!baseLayer.activeFocus) {
312+
console.warn("[LaunchpadFocus] WindowedFrame: BUG_WARNING - baseLayer failed to acquire activeFocus after forceActiveFocus()!")
313+
}
314+
})
315+
return
316+
}
310317

311318
// clear searchEdit text
312319
bottomBar.searchEdit.text = ""

0 commit comments

Comments
 (0)