候选窗首次显示先在旧位置、再跳到光标(Electron 宿主;UI throttle 修复后仍有残留)

Open
#1,966 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, electron
Domain
backend, desktop

Research direction

Start by tracing the candidate window's first display and UpdateInputPosition handling in the Weasel UI code, then compare how it obtains the caret rectangle from Electron's text service. Reproduce with the supplied first-input steps and verify whether the candidate window appears at the caret on its first visible frame; the issue names no source file or test to start from.

Written by the indexing model from the issue text.

Description

环境

  • Windows 11 26200
  • 小狼毫 0.17.4(官方)以及 0.17.4.1-ui-throttle(revaraver 构建,commit 392a478,对应 PR #1869)
  • 宿主程序:Electron 应用(DSH Desktop,Chromium 内核)
  • 相关配置:inline_preedit: true,enhanced_position: false,横排候选,9 个候选

现象

聚焦一个输入框后第一次输入时,候选窗会先在旧位置/中间位置画出来(通常在输入框左侧或上方,约一帧),随后跳到光标位置。主动盯着看能稳定捕捉到;换成官方 0.17.4 时几乎每次都能看到,换成 0.17.4.1-ui-throttle 后概率明显降低,但仍然存在。

录屏/截图里表现为:候选窗第一帧出现在输入框左边,第二帧才对齐到光标。

复现

  1. 打开 Electron 宿主(本例 DSH Desktop),点击聊天输入框
  2. 输入任意拼音,让候选窗首次弹出
  3. 观察候选窗第一帧的位置

已排除

  • 不是贴屏幕底部导致的翻转:把窗口拉高、让输入框不在屏幕下沿,仍然闪烁
  • 与 inline_preedit 无关:把该进程的 inline_preedit 设为 false(编码条回到候选窗内)后仍然闪烁
  • enhanced_position: false 只解决另一种闪(拿不到光标矩形时先闪到窗口左上角),与本次现象无关

推测

Chromium/Electron 的 GetTextExt 在首次合成时可能返回上一帧的光标矩形,Weasel 在第一帧就 ShowWindow + SetWindowPos,因此先画在旧位置;等宿主上报新矩形后再移动。

UI throttle 修复(跳过重复 ShowWindow / SetWindowPos)已经显著改善,但没有覆盖"首次显示"这一帧。

期望

  • 首次显示前拿到有效光标矩形,或先以隐藏状态创建/topmost 定位,再一次性显示
  • 或者首帧先按"不可见"处理,等 UpdateInputPosition 收到有效值再 Show

参考

  • #1672(记事本类候选框位置问题,已关闭)
  • #1017(Word 中候选框闪烁)
  • #1869(UI throttle 修复,本 issue 基于包含该修复的构建测试)

如果需要,我可以提供录屏、复现用的宿主程序和更细的时间线日志。

Dominant language
C++
Stars
8.4k
Forks
878
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rime/weasel

All issues in rime/weasel

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.