From e9fde0051fb5b9d0596fd05558dc0bef42bc9e39 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Fri, 24 May 2024 18:56:47 -0400 Subject: [PATCH] Don't let CaptureCursor fight modal dialog --- common/view/wx_view_controls.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index c12cd8f729..fca447c4c9 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -45,7 +45,7 @@ #include #ifdef __WXMSW__ - #define USE_MOUSE_CAPTURE + #define USE_MOUSE_CAPTURE #endif using namespace KIGFX; @@ -691,7 +691,11 @@ void WX_VIEW_CONTROLS::CaptureCursor( bool aEnabled ) // Note: for some reason, m_parentPanel->HasCapture() can be false even if CaptureMouse() // was called (i.e. mouse was captured, so when need to test m_MouseCapturedLost to be // sure a wxEVT_MOUSE_CAPTURE_LOST event was fired before. Otherwise wxMSW complains - if( aEnabled && !m_parentPanel->HasCapture() && m_parentPanel->m_MouseCapturedLost ) + // The IsModalDialogFocused is checked because it's possible to start a capture + // due to event ordering while a modal dialog was just opened, the mouse capture steels focus + // from the modal and causes odd behavior + if( aEnabled && !m_parentPanel->HasCapture() && m_parentPanel->m_MouseCapturedLost + && !KIUI::IsModalDialogFocused() ) { m_parentPanel->CaptureMouse();