[Libreoffice-commits] core.git: sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 15 16:06:28 UTC 2020


 sc/source/ui/inc/gridwin.hxx  |    4 +++-
 sc/source/ui/view/gridwin.cxx |   32 ++++++++++++++++++++++----------
 2 files changed, 25 insertions(+), 11 deletions(-)

New commits:
commit d6533cb372bd75f839674fd36640fa466d496efd
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jun 15 12:17:10 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 15 18:05:46 2020 +0200

    ReleaseMouse so focus can be grabbed by the FilterFloat
    
    otherwise the keyboard events don't get to the dropdown
    
    Change-Id: I6cbaea5e3cef16a39edb12fecdf1d08ab29cbd5c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96366
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index b3439381f702..9dfedd12ade8 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -82,6 +82,8 @@ struct SpellCallbackInfo;
 // predefines
 namespace sdr::overlay { class OverlayObjectList; }
 
+class ScFilterFloatingWindow;
+
 class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSourceHelper
 {
     // ScFilterListBox is always used for selection list
@@ -152,7 +154,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
     std::unique_ptr<ScNoteMarker, o3tl::default_delete<ScNoteMarker>> mpNoteMarker;
 
     VclPtr<ScFilterListBox>          mpFilterBox;
-    VclPtr<FloatingWindow>           mpFilterFloat;
+    VclPtr<ScFilterFloatingWindow>   mpFilterFloat;
     VclPtr<ScCheckListMenuWindow>    mpAutoFilterPopup;
     VclPtr<ScCheckListMenuWindow>    mpDPFieldPopup;
     std::unique_ptr<ScDPFieldButton> mpFilterButton;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1cda62bba554..1f49e48a68c4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -311,21 +311,25 @@ IMPL_LINK_NOARG(ScFilterListBox, AsyncSelectHdl, void*, void)
     pGridWin->ClickExtern();
 }
 
-namespace {
-
 // use a System floating window for the above filter listbox
 class ScFilterFloatingWindow : public FloatingWindow
 {
+private:
+    bool m_bGridHadMouseCaptured;
 public:
     ScFilterFloatingWindow(vcl::Window* pParent);
     virtual ~ScFilterFloatingWindow() override;
     virtual void dispose() override;
-};
 
-}
+    bool MouseWasCaptured() const
+    {
+        return m_bGridHadMouseCaptured;
+    }
+};
 
 ScFilterFloatingWindow::ScFilterFloatingWindow(vcl::Window* pParent)
     : FloatingWindow( pParent, WB_BORDER | WB_SYSTEMWINDOW ) // make it a system floater
+    , m_bGridHadMouseCaptured(pParent->IsMouseCaptured())
 {
 }
 
@@ -540,6 +544,10 @@ IMPL_LINK_NOARG(ScGridWindow, PopupModeEndHdl, FloatingWindow*, void)
 {
     if (mpFilterBox)
         mpFilterBox->SetCancelled();     // cancel select
+    // restore the mouse capture state of the GridWindow to
+    // what it was at initial popup time
+    if (mpFilterFloat->MouseWasCaptured())
+        CaptureMouse();
     GrabFocus();
 }
 
@@ -980,6 +988,9 @@ void ScGridWindow::ShowFilterMenu(const tools::Rectangle& rCellRect, bool bLayou
 
     mpFilterBox->SetSizePixel(aSize);
     mpFilterFloat->SetOutputSizePixel(aSize);
+
+    if (IsMouseCaptured())
+        ReleaseMouse();
     mpFilterFloat->StartPopupMode(aCellRect, FloatWinPopupFlags::Down|FloatWinPopupFlags::GrabFocus);
 }
 
@@ -1070,11 +1081,6 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
         rFilterBox.select(nPos);
     }
     mpFilterBox->EndInit();
-
-    // Scenario selection comes from MouseButtonDown:
-    // The next MouseMove on the FilterBox is like a ButtonDown
-    nMouseStatus = SC_GM_FILTER;
-    CaptureMouse();
 }
 
 void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow )
@@ -1771,7 +1777,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
                 LaunchDataSelectMenu( aListValPos.Col(), aListValPos.Row() );
 
                 nMouseStatus = SC_GM_FILTER;    // not set in DoAutoFilterMenue for bDataSelect
-                CaptureMouse();
                 rState.mbActivatePart = false;
                 return;
             }
@@ -1783,7 +1788,14 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta
     ScRange aScenRange;
     if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) )
     {
+        CaptureMouse();
+
         DoScenarioMenu( aScenRange );
+
+        // Scenario selection comes from MouseButtonDown:
+        // The next MouseMove on the FilterBox is like a ButtonDown
+        nMouseStatus = SC_GM_FILTER;
+
         return;
     }
 


More information about the Libreoffice-commits mailing list