From 51ba4763f0a728818ec7b5d6dba37907b03c7ed6 Mon Sep 17 00:00:00 2001 From: Mark Roszko Date: Sat, 25 May 2024 01:17:17 +0000 Subject: [PATCH] Don't let CaptureCursor fight modal dialog (cherry picked from commit e9fde0051fb5b9d0596fd05558dc0bef42bc9e39) Co-authored-by: Marek Roszko --- 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 13443eaab0..1d86fca538 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; @@ -694,7 +694,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();