diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-10-18 10:59:33 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-10-18 13:47:35 +0200 |
commit | 680ae3e989c3b665b29f536c2e30dd86bbc3edac (patch) | |
tree | 07c6ea7754fc14b82f17f6ff969af59e5d1b6f58 | |
parent | 25f4ef5aa5488869b3bad045ba203c6b22b2e2f0 (diff) |
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.weghorn@posteo.de>
-rw-r--r-- | sw/source/uibase/uiview/view2.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
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; |