Commit e06077e
committed
fix: forward InputMethodQuery to searchEdit for correct IME candidate window positioning
When launcher opens, focus is on InputEventItem (root node) while searchEdit has no focus or cursor, as per design requirements. However, IMEs like Sogou send InputMethodQuery events to the focused control during pre-edit stage to query cursor position for candidate window placement. Since InputEventItem is not a text input control, it cannot return meaningful cursor position, causing the candidate window to appear at incorrect positions (e.g., top-left corner or other wrong locations).
This commit implements a forwarding mechanism: when InputEventItem receives InputMethodQuery, it forwards the query to searchEdit and maps the returned cursor rectangle coordinates from searchEdit's local coordinate system to the query target's coordinate system, then returns the mapped result to the IME framework. This allows the candidate window to be positioned correctly near the search box while keeping focus on InputEventItem (no visible cursor in search box).
Changes:
- Add inputMethodSource property to InputEventItem for specifying the text control to forward queries to
- Implement InputMethodQuery event forwarding and coordinate mapping in eventFilter
- Set inputMethodSource to searchEdit in FullscreenFrame and WindowedFrame
- Clean up temporary diagnostic logs
启动器打开时,焦点在 InputEventItem(根节点)上,searchEdit 无焦点、无光标,这是设计要求。但搜狗等输入法在预编辑阶段会向焦点控件发送 InputMethodQuery 事件查询光标位置以定位候选框。由于 InputEventItem 不是文本输入控件,无法返回有意义的光标位置,导致候选框出现在错误位置(如屏幕左上角或其他位置)。
本次提交实现了转发机制:InputEventItem 收到 InputMethodQuery 时,将查询转发给 searchEdit,并将 searchEdit 返回的光标矩形坐标从其局部坐标系映射到查询目标的坐标系,再将映射后的结果返回给输入法框架。这样候选框能正确定位到搜索框附近,同时焦点保持在 InputEventItem 上(搜索框不显示光标)。
修改内容:
- 为 InputEventItem 添加 inputMethodSource 属性,用于指定转发查询的文本控件
- 在 eventFilter 中实现 InputMethodQuery 事件转发和坐标映射
- 在 FullscreenFrame 和 WindowedFrame 中设置 inputMethodSource 为 searchEdit
- 清理临时诊断日志
PMS: BUG-3017431 parent a8dd424 commit e06077e
4 files changed
Lines changed: 75 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
15 | 31 | | |
16 | | - | |
| 32 | + | |
| 33 | + | |
17 | 34 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
22 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
23 | 71 | | |
24 | 72 | | |
25 | 73 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
883 | 884 | | |
884 | 885 | | |
885 | 886 | | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | 887 | | |
| 888 | + | |
892 | 889 | | |
893 | 890 | | |
894 | 891 | | |
| |||
912 | 909 | | |
913 | 910 | | |
914 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
915 | 915 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
296 | 300 | | |
297 | 301 | | |
298 | 302 | | |
| |||
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | 310 | | |
| 311 | + | |
| 312 | + | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
0 commit comments