-
Notifications
You must be signed in to change notification settings - Fork 634
fix(WeaselUI): fix#1672, The candidate box is in the wrong position #1685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
还要要用形码测试,比如五笔,menu_size: 6,编码逐渐增加之后候选变少的情况下,m_sticky依然生效(同一次合成过程不会因为候选数量上下晃动) 另外,要lint,安装clang-format 18,用.\clang-format.ps1 -n格式化代码 |
|
@fxliang 我不知道该如何测试,我不会五笔,所以可能需要你来测试,目前拼音方案使用正常。 |
|
另外,我使用clang-format 19.1.1发现 |
linter 不会频繁改,还是会保留在clang-format 18上 |
|
目前我使用全拼和小鹤双拼没发现bug,形码输入有待测试。 |
diff --git a/WeaselUI/WeaselPanel.cpp b/WeaselUI/WeaselPanel.cpp
index 58f16dc..76e0e6e 100644
--- a/WeaselUI/WeaselPanel.cpp
+++ b/WeaselUI/WeaselPanel.cpp
@@ -57,6 +57,7 @@ WeaselPanel::WeaselPanel(weasel::UI& ui)
m_style(ui.style()),
m_ostyle(ui.ostyle()),
m_candidateCount(0),
+ m_lastCandidateCount(0),
m_current_zhung_icon(),
m_inputPos(CRect()),
m_sticky(false),
@@ -133,6 +134,12 @@ void WeaselPanel::Refresh() {
bool should_show_icon =
(m_status.ascii_mode || !m_status.composing || !m_ctx.aux.empty());
m_candidateCount = (BYTE)m_ctx.cinfo.candies.size();
+ // When the candidate window changes from having content to having no content,
+ // reset the sticky state
+ if (m_lastCandidateCount > 0 && m_candidateCount == 0) {
+ m_sticky = false;
+ }
+ m_lastCandidateCount = m_candidateCount;
// check if to hide candidates window
// show tips status, two kind of situation: 1) only aux strings, don't care
// icon status; 2)only icon(ascii mode switching)
@@ -1121,6 +1128,22 @@ void WeaselPanel::MoveTo(RECT const& rc) {
if (!m_layout)
return; // avoid handling nullptr in _RepositionWindow
m_redraw_by_monitor_change = false;
+ // The conditions for resetting the sticky state:
+ // 1. When the input session ends (ctx.empty() is true)
+ // 2. When the input position changes significantly (the position change
+ // exceeds the threshold)
+ bool should_reset_sticky =
+ (m_ctx.empty() || (abs(rc.left - m_inputPos.left) > 50) ||
+ (abs(rc.bottom - m_inputPos.bottom) > 50));
+ if (should_reset_sticky && m_sticky) {
+ m_sticky = false;
+ // Force reposition the window
+ m_inputPos = rc;
+ m_inputPos.OffsetRect(0, 6);
+ _RepositionWindow(true);
+ RedrawWindow();
+ return;
+ }
// if ascii_tip_follow_cursor set, move tip icon to mouse cursor
if (m_style.ascii_tip_follow_cursor && m_ctx.empty() &&
(!m_status.composing) && m_layout->ShouldDisplayStatusIcon()) {
diff --git a/WeaselUI/WeaselPanel.h b/WeaselUI/WeaselPanel.h
index 478e798..0be5e1f 100644
--- a/WeaselUI/WeaselPanel.h
+++ b/WeaselUI/WeaselPanel.h
@@ -134,6 +134,7 @@ class WeaselPanel
CRect rcw;
BYTE m_candidateCount;
+ BYTE m_lastCandidateCount;
bool hide_candidates;
bool m_sticky;这样应该简单一点,试过形码候选减少的时候
|


fix #1672 The candidate box is in the wrong position
add
lastCandidateCountto managestickystate in WeaselPanelThe conditions for resetting the sticky state: