From 133d2fa5f6ea222f8f604de4e06f0ef635feacdf Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 2 Jan 2026 22:33:10 -0800 Subject: [PATCH] Reset tool dispatcher state when GAL canvas loses focus When the GAL canvas loses focus while a mouse button is pressed, the button-up event may be delivered to another window, leaving the tool dispatcher in an inconsistent state where it thinks the button is still pressed. This can cause selection and drag operations to stop working until the application is restarted. Call ResetState() on the tool dispatcher when focus is lost to ensure the button tracking state is properly cleared. This complements the existing CancelDrag() call which only resets the view-level panning/zooming state. Fixes https://gitlab.com/kicad/code/kicad/-/issues/22317 (cherry picked from commit f5731f69b19b636e94d1921fd1a545912c37a987) --- common/draw_panel_gal.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 936a5bcf01..dd319143b4 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -626,6 +626,12 @@ void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent ) m_viewControls->CancelDrag(); + // Reset the tool dispatcher's button state when focus is lost. This prevents + // the dispatcher from thinking the button is still pressed when focus returns, + // which can cause selection and drag operations to stop working. + if( m_eventDispatcher ) + m_eventDispatcher->ResetState(); + aEvent.Skip(); }