sc/source/ui/view/gridwin.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
New commits: commit 64fbd90158f5248636490237e23325c90683d9be Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jun 23 16:16:15 2022 +0100 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Thu Aug 18 19:18:17 2022 +0200 tdf#149609 release mouse before showing popups from calc grid window If we capture the mouse in the course of the mouse down handler, then release it before showing a popup to undo any unhelpful seleng capture. Change-Id: I94ead6b516c2b2a019030e0e04760f8e07ff35d9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136329 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2e4fcf0bc38d..f41d7b580a01 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -475,6 +475,7 @@ IMPL_LINK_NOARG(ScGridWindow, PopupModeEndHdl, weld::Popover&, void) mpFilterBox->SetCancelled(); // cancel select // restore the mouse capture state of the GridWindow to // what it was at initial popup time + SAL_WARN_IF(bMouseWasCaptured, "sc.ui", "Is there a scenario where the mouse was captured before mouse down?"); if (bMouseWasCaptured) CaptureMouse(); } @@ -1797,6 +1798,9 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta if (pScMod->IsModalMode(mrViewData.GetSfxDocShell())) return; + const bool bWasMouseCaptured = IsMouseCaptured(); + SAL_WARN_IF(bWasMouseCaptured, "sc.ui", "Is there a scenario where the mouse is captured before mouse down?"); + pScActiveViewShell = mrViewData.GetViewShell(); // if left is clicked nScClickMouseModifier = rMEvt.GetModifier(); // to always catch a control click @@ -2053,9 +2057,11 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta tools::Rectangle aButtonRect = GetListValButtonRect( aListValPos ); if ( aButtonRect.Contains( aPos ) ) { - // tdf#125917 typically we have the mouse captured already, except if are editing the cell. - // Ensure its captured before the menu is launched even in the cell editing case - CaptureMouse(); + // tdf#149609 if we captured the mouse in the course of this function + // release it before showing the data select menu to undo any unhelpful + // seleng capture + if (!bWasMouseCaptured && IsMouseCaptured()) + ReleaseMouse(); LaunchDataSelectMenu( aListValPos.Col(), aListValPos.Row() ); @@ -2071,7 +2077,11 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta ScRange aScenRange; if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) ) { - CaptureMouse(); + // tdf#149609 if we captured the mouse in the course of this function + // release it before showing the data scenario menu to undo any unhelpful + // seleng capture + if (!bWasMouseCaptured && IsMouseCaptured()) + ReleaseMouse(); DoScenarioMenu( aScenRange );