vcl/source/control/InterimItemWindow.cxx |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 31ba0aa5968525deb9b3f7164b34ada495b13d6d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Jun 29 21:43:04 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Jun 30 00:20:38 2025 +0200

    Resolves: tdf#157738 don't break mouse capture by grabbing focus
    
    if the parent has captured the mouse, then don't grab focus to
    another widget hierarchy
    
    Change-Id: Ide0bee2e34f5ff519d2c10162d88dbaa2be7a6e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187159
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/source/control/InterimItemWindow.cxx 
b/vcl/source/control/InterimItemWindow.cxx
index 0769245eb477..4ecb503a8ae6 100644
--- a/vcl/source/control/InterimItemWindow.cxx
+++ b/vcl/source/control/InterimItemWindow.cxx
@@ -10,6 +10,7 @@
 #include <vcl/InterimItemWindow.hxx>
 #include <vcl/layout.hxx>
 #include <salobj.hxx>
+#include <svdata.hxx>
 #include <window.h>
 
 InterimItemWindow::InterimItemWindow(vcl::Window* pParent, const OUString& 
rUIXMLDescription,
@@ -131,7 +132,12 @@ void InterimItemWindow::InitControlBase(weld::Widget* 
pWidget) { m_pWidget = pWi
 
 void InterimItemWindow::GetFocus()
 {
-    if (m_pWidget)
+    // tdf#157738 Don't grab focus to the other widget hierarchy if the parent 
has
+    // captured the mouse in order to avoid breaking the capture.
+    ImplSVWinData* pWinData = ImplGetSVData()->mpWinData;
+    const bool bParentHasCapturedMouse
+        = pWinData->mpCaptureWin && pWinData->mpCaptureWin->ImplIsChild(this);
+    if (m_pWidget && !bParentHasCapturedMouse)
         m_pWidget->grab_focus();
 
     /* let toolbox know this item window has focus so it updates its 
mnHighItemId to point

Reply via email to