From 075fa2b764497738e890ef0a47b91fd65cd3eba2 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Tue, 6 Aug 2019 18:19:58 -0500 Subject: [PATCH] Record wxSTCPopupWindow position every time its set The position of wxSTCPopupWindow is currently recorded the first time it is set so that it can be used to reposition the popup when its parent window is moved. However Scintilla apparently positions the popup at least twice when icons are used and the first set position is slightly wrong. Instead just record the position every time its set by Scintilla. --- src/stc/PlatWX.cpp | 10 ++++------ src/stc/PlatWX.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 11795fe591..03b33aaadc 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2224,7 +2224,7 @@ PRectangle Window::GetMonitorRect(Point pt) { #endif // __WXOSX_COCOA__ wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent) - :wxSTCPopupBase(parent), m_initialPosition(wxDefaultPosition) + :wxSTCPopupBase(parent), m_lastKnownPosition(wxDefaultPosition) { #if !wxSTC_POPUP_IS_CUSTOM Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this); @@ -2275,9 +2275,7 @@ bool wxSTCPopupWindow::AcceptsFocus() const void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) { - if ( m_initialPosition == wxDefaultPosition - && x != wxDefaultCoord && y != wxDefaultCoord ) - m_initialPosition = wxPoint(x, y); + m_lastKnownPosition = wxPoint(x, y); // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) @@ -2291,8 +2289,8 @@ void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) void wxSTCPopupWindow::OnParentMove(wxMoveEvent& event) { - if ( m_initialPosition != wxDefaultPosition ) - SetPosition(m_initialPosition); + if ( m_lastKnownPosition.IsFullySpecified() ) + SetPosition(m_lastKnownPosition); event.Skip(); } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 714f5e4180..31a11dbf4d 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -150,7 +150,7 @@ protected: #endif private: - wxPoint m_initialPosition; + wxPoint m_lastKnownPosition; wxWindow* m_tlw; };