sw/source/uibase/uiview/view2.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 680ae3e989c3b665b29f536c2e30dd86bbc3edac Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 18 10:59:33 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Oct 18 13:47:35 2023 +0200 tdf#156033 sw: Don't capture mouse when executing file dlg When the mouse is captured in `SwView::InsertGraphicDlg`, temporarily release it while executing the file dialog, so the user can use the mouse to interact with the file dialog. At least with qt5/qt6/kf5, this would otherwise not work in the file dialog shown after clicking on a previously inserted Picture Content Control, because `QWidget::grabMouse()`'s "other widgets get no mouse events at all" [1] apparently applies for the file dialog and other running applications as well. [1] https://doc.qt.io/qt-6/qwidget.html#grabMouse Change-Id: I80a81c57c80debc716a1b111a9c07eef0c005c65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158109 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index 143472a83042..8d6239497eb6 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -441,11 +441,22 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) const SfxStringItem* pName = rReq.GetArg<SfxStringItem>(SID_INSERT_GRAPHIC); bool bShowError = !pName; - if( pName + + bool bHaveName = pName != nullptr; #if HAVE_FEATURE_DESKTOP - || (!Application::IsHeadlessModeEnabled() && ERRCODE_NONE == pFileDlg->Execute()) + if (!bHaveName && !Application::IsHeadlessModeEnabled()) + { + // execute file dialog, without capturing mouse (tdf#156033) + vcl::Window* pWin = GetWindow(); + const bool bMouseCaptured = pWin && pWin->IsMouseCaptured(); + if (bMouseCaptured) + pWin->ReleaseMouse(); + bHaveName = ERRCODE_NONE == pFileDlg->Execute(); + if (bMouseCaptured) + pWin->CaptureMouse(); + } #endif - ) + if (bHaveName) { OUString aFileName, aFilterName;