From 99cc6e7398c815527b45d6fcd3bff3f44a0cc2d7 Mon Sep 17 00:00:00 2001 From: fxliang Date: Wed, 20 Dec 2023 10:07:20 +0800 Subject: [PATCH 1/2] refactor: on hover actions, performance enhancement, less ui update. --- WeaselTSF/CandidateList.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/WeaselTSF/CandidateList.cpp b/WeaselTSF/CandidateList.cpp index 0b10cd8d6..a1dd66e0b 100644 --- a/WeaselTSF/CandidateList.cpp +++ b/WeaselTSF/CandidateList.cpp @@ -454,22 +454,25 @@ void WeaselTSF::_HandleMousePageEvent( bool* const nextPage, bool* const scrollN void WeaselTSF::_HandleMouseHoverEvent(const size_t index) { - // ToDo: if feature new api comes, replace the processes bellow UINT current_select = 0; _cand->GetSelection(¤t_select); - weasel::KeyEvent ke{ 0, 0 }; - ke.keycode = current_select < index ? ibus::Down : ibus::Up; - int inc = index > current_select ? 1 : (index < current_select ) ? -1 : 0; - if (_cand->GetIsReposition()) inc = -inc; if(index != current_select) { - for(auto i=0; i < abs((INT)((INT)index - (INT)current_select)); i++) + // simuulate change current_select in librime + // maybe replace with new api in the future + weasel::KeyEvent ke{ 0, 0 }; + ke.keycode = current_select < index ? ibus::Down : ibus::Up; + int inc = index > current_select ? 1 : (index < current_select ) ? -1 : 0; + if (_cand->GetIsReposition()) inc = -inc; + UINT gap = abs((INT)((INT)index - (INT)current_select)); + for(UINT i=0; i < gap; i++) { - _cand->SetSelection(current_select + inc); m_client.ProcessKeyEvent(ke); - _UpdateComposition(_pEditSessionContext); } + // simuulate change current_select end + _cand->SetSelection(current_select + inc * gap); + _UpdateComposition(_pEditSessionContext); } } From b8dee7eb083824f639523a54652151e8a5353701 Mon Sep 17 00:00:00 2001 From: fxliang Date: Wed, 20 Dec 2023 18:17:37 +0800 Subject: [PATCH 2/2] Update CandidateList.cpp --- WeaselTSF/CandidateList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WeaselTSF/CandidateList.cpp b/WeaselTSF/CandidateList.cpp index a1dd66e0b..4553a1e8c 100644 --- a/WeaselTSF/CandidateList.cpp +++ b/WeaselTSF/CandidateList.cpp @@ -463,7 +463,7 @@ void WeaselTSF::_HandleMouseHoverEvent(const size_t index) // maybe replace with new api in the future weasel::KeyEvent ke{ 0, 0 }; ke.keycode = current_select < index ? ibus::Down : ibus::Up; - int inc = index > current_select ? 1 : (index < current_select ) ? -1 : 0; + int inc = index > current_select ? 1 : -1; if (_cand->GetIsReposition()) inc = -inc; UINT gap = abs((INT)((INT)index - (INT)current_select)); for(UINT i=0; i < gap; i++)