sc/source/ui/inc/hdrcont.hxx  |    6 +++++
 sc/source/ui/view/hdrcont.cxx |   44 +++++++++++++++++++++++++++++++-----------
 2 files changed, 39 insertions(+), 11 deletions(-)

New commits:
commit f410d6826e86d55314dfbd4bcf6b0e78ef0ef2a2
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Mar 6 21:34:22 2021 +0000
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Mon Mar 8 22:35:53 2021 +0100

    tdf#140833 show ScHeaderControl help tip after double click time has expired
    
    so under gtk the popover isn't active when the double click is processed
    by gtk because under load on wayland the double click is getting handled
    by something else and getting sent to the the window underneath our
    window
    
    Change-Id: Ie3afcf45c69b7b947b1aeb787478f947deca9307
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112135
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx
index 3bb0e4223ce5..03b14af70c98 100644
--- a/sc/source/ui/inc/hdrcont.hxx
+++ b/sc/source/ui/inc/hdrcont.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_SOURCE_UI_INC_HDRCONT_HXX
 
 #include <vcl/window.hxx>
+#include <vcl/timer.hxx>
 #include <scdllapi.h>
 #include <types.hxx>
 
@@ -36,6 +37,7 @@ class ScHeaderControl : public vcl::Window
 {
 private:
     SelectionEngine*    pSelEngine;
+    Timer               aShowHelpTimer;
     vcl::Font           aNormFont;
     vcl::Font           aBoldFont;
     bool                bBoldSet;
@@ -67,9 +69,12 @@ private:
     SCCOLROW        GetMousePos( const MouseEvent& rMEvt, bool& rBorder ) 
const;
     bool            IsSelectionAllowed(SCCOLROW nPos) const;
     void            ShowDragHelp();
+    void            HideDragHelp();
 
     void            DoPaint( SCCOLROW nStart, SCCOLROW nEnd );
 
+    DECL_LINK(ShowDragHelpHdl, Timer*, void);
+
 protected:
     ScTabView*      pTabView;
 
@@ -105,6 +110,7 @@ protected:
 
     virtual void    DrawInvert( tools::Long nDragPos );
     virtual void    Command( const CommandEvent& rCEvt ) override;
+    virtual void    dispose() override;
 
 public:
             ScHeaderControl( vcl::Window* pParent, SelectionEngine* 
pSelectionEngine,
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 12f4ad7c0a4b..78214cb9be68 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -48,6 +48,7 @@ ScHeaderControl::ScHeaderControl( vcl::Window* pParent, 
SelectionEngine* pSelect
                                   SCCOLROW nNewSize, bool bNewVertical, 
ScTabView* pTab ) :
             Window      ( pParent ),
             pSelEngine  ( pSelectionEngine ),
+            aShowHelpTimer("sc HeaderControl Popover Timer"),
             bVertical   ( bNewVertical ),
             nSize       ( nNewSize ),
             nMarkStart  ( 0 ),
@@ -88,9 +89,18 @@ ScHeaderControl::ScHeaderControl( vcl::Window* pParent, 
SelectionEngine* pSelect
     nWidth = nSmallWidth = aSize.Width();
     nBigWidth = LogicToPixel( Size( GetTextWidth("8888888"), 0 ) ).Width() + 5;
 
+    aShowHelpTimer.SetInvokeHandler(LINK(this, ScHeaderControl, 
ShowDragHelpHdl));
+    
aShowHelpTimer.SetTimeout(GetSettings().GetMouseSettings().GetDoubleClickTime());
+
     SetBackground();
 }
 
+void ScHeaderControl::dispose()
+{
+    aShowHelpTimer.Stop();
+    vcl::Window::dispose();
+}
+
 void ScHeaderControl::SetWidth( tools::Long nNew )
 {
     OSL_ENSURE( bVertical, "SetWidth works only on row headers" );
@@ -652,7 +662,11 @@ void ScHeaderControl::MouseButtonDown( const MouseEvent& 
rMEvt )
             else
                 nDragStart = rMEvt.GetPosPixel().X();
             nDragPos = nDragStart;
-            ShowDragHelp();
+            // tdf#140833 launch help tip to show after the double click time 
has expired
+            // so under gtk the popover isn't active when the double click is 
processed
+            // by gtk because under load on wayland the double click is 
getting handled
+            // by something else and getting sent to the the window underneath 
our window
+            aShowHelpTimer.Start();
             DrawInvert( nDragPos );
 
             StartTracking();
@@ -713,11 +727,7 @@ void ScHeaderControl::MouseButtonUp( const MouseEvent& 
rMEvt )
     {
         DrawInvert( nDragPos );
         ReleaseMouse();
-        if (nTipVisible)
-        {
-            Help::HidePopover(this, nTipVisible);
-            nTipVisible = nullptr;
-        }
+        HideDragHelp();
         bDragging = false;
 
         tools::Long nScrPos    = GetScrPos( nDragNo );
@@ -885,11 +895,7 @@ void ScHeaderControl::StopMarking()
     if ( bDragging )
     {
         DrawInvert( nDragPos );
-        if (nTipVisible)
-        {
-            Help::HidePopover(this, nTipVisible);
-            nTipVisible = nullptr;
-        }
+        HideDragHelp();
         bDragging = false;
     }
 
@@ -902,8 +908,14 @@ void ScHeaderControl::StopMarking()
         ReleaseMouse();
 }
 
+IMPL_LINK_NOARG(ScHeaderControl, ShowDragHelpHdl, Timer*, void)
+{
+    ShowDragHelp();
+}
+
 void ScHeaderControl::ShowDragHelp()
 {
+    aShowHelpTimer.Stop();
     if (!Help::IsQuickHelpEnabled())
         return;
 
@@ -943,6 +955,16 @@ void ScHeaderControl::ShowDragHelp()
     nTipVisible = Help::ShowPopover(this, aRect, aHelpStr, nAlign);
 }
 
+void ScHeaderControl::HideDragHelp()
+{
+    aShowHelpTimer.Stop();
+    if (nTipVisible)
+    {
+        Help::HidePopover(this, nTipVisible);
+        nTipVisible = nullptr;
+    }
+}
+
 void ScHeaderControl::RequestHelp( const HelpEvent& rHEvt )
 {
     //  If the own QuickHelp is displayed, don't let RequestHelp remove it
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to