sw/source/uibase/uiview/view2.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 16940dc248068133363153a1c2d41cd2d0102460 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 18 10:59:33 2023 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Oct 18 22:26:15 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> (cherry picked from commit 680ae3e989c3b665b29f536c2e30dd86bbc3edac) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158045 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index f7cfb6563803..585f38b7cae1 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;