sc/source/ui/view/gridwin.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
New commits: commit a60aaaf4bfcc2700af3ced4fd2de0ce3ecb8dfc6 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jun 23 16:16:15 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Jun 24 16:00:22 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/+/136328 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 0a5a8454c8ec..8a7dd8b82bdc 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -478,6 +478,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(); } @@ -1817,6 +1818,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 @@ -2073,9 +2077,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() ); @@ -2091,7 +2097,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 );