diff --git a/WeaselUI/WeaselPanel.cpp b/WeaselUI/WeaselPanel.cpp index 4e52ba8c4..faed8f410 100644 --- a/WeaselUI/WeaselPanel.cpp +++ b/WeaselUI/WeaselPanel.cpp @@ -1156,6 +1156,8 @@ LRESULT WeaselPanel::OnDestroy(UINT uMsg, m_hoverIndex = -1; m_lastMousePos = {-1, -1}; m_sticky = false; + m_lastWindowPos = {-1, -1}; + m_hasLastWindowPos = false; delete m_layout; m_layout = NULL; return 0; @@ -1287,6 +1289,11 @@ void WeaselPanel::_RepositionWindow(const bool& adj) { y = rcWorkArea.top; // over workarea top // memorize adjusted position (to avoid window bouncing on height change) m_inputPos.bottom = y; + if (m_hasLastWindowPos && m_lastWindowPos.x == x && m_lastWindowPos.y == y && + !m_redraw_by_monitor_change) + return; + m_lastWindowPos = {x, y}; + m_hasLastWindowPos = true; SetWindowPos(HWND_TOPMOST, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW); } diff --git a/WeaselUI/WeaselPanel.h b/WeaselUI/WeaselPanel.h index 7ad3af77b..82df11241 100644 --- a/WeaselUI/WeaselPanel.h +++ b/WeaselUI/WeaselPanel.h @@ -113,6 +113,8 @@ class WeaselPanel const bool& m_in_server; CRect m_inputPos; + CPoint m_lastWindowPos = {-1, -1}; + bool m_hasLastWindowPos = false; int m_offsetys[MAX_CANDIDATES_COUNT]; // offset y for candidates when // vertical layout over bottom int m_offsety_preedit; diff --git a/WeaselUI/WeaselUI.cpp b/WeaselUI/WeaselUI.cpp index 53a9b92fe..906a1fa08 100644 --- a/WeaselUI/WeaselUI.cpp +++ b/WeaselUI/WeaselUI.cpp @@ -39,23 +39,29 @@ UINT_PTR UIImpl::timer = 0; void UIImpl::Show() { if (!panel.IsWindow()) return; - panel.ShowWindow(SW_SHOWNA); + bool already_shown = shown && panel.IsWindowVisible(); shown = true; if (timer) { KillTimer(panel.m_hWnd, AUTOHIDE_TIMER); timer = 0; } + if (already_shown) + return; + panel.ShowWindow(SW_SHOWNA); } void UIImpl::Hide() { if (!panel.IsWindow()) return; - panel.ShowWindow(SW_HIDE); + bool already_hidden = !shown && !panel.IsWindowVisible(); shown = false; if (timer) { KillTimer(panel.m_hWnd, AUTOHIDE_TIMER); timer = 0; } + if (already_hidden) + return; + panel.ShowWindow(SW_HIDE); } void UIImpl::ShowWithTimeout(size_t millisec) {