sw/source/uibase/uiview/viewport.cxx |   51 +++++++++++++++++++----------------
 vcl/source/app/help.cxx              |   21 ++++++++++----
 2 files changed, 43 insertions(+), 29 deletions(-)

New commits:
commit 1652fe3ece911af37b6d3a65d452cbcf86513c42
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jul 7 07:52:34 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jul 7 09:32:10 2023 +0200

    Some refactor to combine code deciding bNoDelay value
    
    Change-Id: Ie04288c14801dfc8090ed8bd92a85e426a66d654
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154153
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 9f92a46b856c..8336a5b1c20f 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -529,10 +529,6 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 
nHelpWinStyle, QuickHe
     if (rHelpText.isEmpty())
         return;
 
-    sal_uInt64 nCurTime = tools::Time::GetSystemTicks();
-    if ( ( nCurTime - aHelpData.mnLastHelpHideTime ) < 
o3tl::make_unsigned(HelpSettings::GetTipDelay()) )
-        bNoDelay = true;
-
     VclPtr<HelpTextWindow> pHelpWin = VclPtr<HelpTextWindow>::Create( pParent, 
rHelpText, nHelpWinStyle, nStyle );
     aHelpData.mpHelpWin = pHelpWin;
     pHelpWin->SetHelpArea( rHelpArea );
@@ -542,8 +538,19 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 
nHelpWinStyle, QuickHe
     pHelpWin->SetOutputSizePixel( aSz );
     ImplSetHelpWindowPos( pHelpWin, nHelpWinStyle, nStyle, rScreenPos, 
rHelpArea );
     // if not called from Window::RequestHelp, then without delay...
-    if ( !aHelpData.mbRequestingHelp )
-        bNoDelay = true;
+    if (!bNoDelay)
+    {
+        if ( !aHelpData.mbRequestingHelp )
+        {
+            bNoDelay = true;
+        }
+        else
+        {
+            sal_uInt64 nCurTime = tools::Time::GetSystemTicks();
+            if ( ( nCurTime - aHelpData.mnLastHelpHideTime ) < 
o3tl::make_unsigned(HelpSettings::GetTipDelay()) )
+                bNoDelay = true;
+        }
+    }
     pHelpWin->ShowHelp(bNoDelay);
 }
 
commit a6b8c40d26c023cf8936017b92821f2b0df7ec58
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jul 7 07:42:13 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jul 7 09:32:04 2023 +0200

    Related: tdf#155462 Repaint changed tooltip text immediately
    
    When moving scrollbar thumb, its tooltip is constantly updated. This
    changes the window position and size, which appear immediately; but
    the text wasn't repainted, until events with higher priorities were
    processed, which gave visible discrepancies between the window size
    and its contents. When tooltip window size decreased, the old text
    could become cropped; or the window could become much larger.
    
    Also, not updating the text broke the idea that the tooltip helps
    user to see where they are in the document in real time.
    
    Change-Id: Ibdc7cc15bd40896428004ef70bbe8c8c5a0858ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154152
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 2c6d020537e4..9f92a46b856c 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -363,6 +363,8 @@ void HelpTextWindow::SetHelpText( const OUString& rHelpText 
)
 
     Size aSize( CalcOutSize() );
     SetOutputSizePixel( aSize );
+    if (IsVisible())
+        PaintImmediately();
 }
 
 void HelpTextWindow::ImplShow()
commit b4a0680d6cf059aef5b274e8ce5a0453cf376655
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Jul 7 07:28:55 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jul 7 09:31:57 2023 +0200

    Related: tdf#155462 Avoid tooltip window hide before showing again
    
    SwView::EndScrollHdl calls Help::ShowQuickHelp with empty text when
    nPgNum is not 0, which hides and destroys the window immediately.
    When moving the scrollbar thumb, tooltip should just move to the new
    position (and update text), which happens in ImplShowHelpWindow, if
    the window exist, and its parent is unchanged.
    
    So avoid hiding/destroying the tooltip window before checking if it
    should be updated, and only do that when necessary.
    
    Additionally, I noticed that the guarding condition around the code
    showing tooltip, 'if( !nPgNum || nPgNum != nPhNum )', was always
    true, because SwView::EndScrollHdl called previously makes sure that
    nPgNum is 0 unconditionally.
    
    Change-Id: Id10dd6236379660ab0b1d6f14159cfd4f9c61256
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154151
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/uibase/uiview/viewport.cxx 
b/sw/source/uibase/uiview/viewport.cxx
index e12c6adeda51..651a4abcf4c8 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -668,6 +668,8 @@ bool SwView::PageDownCursor(bool bSelect)
     return false;
 }
 
+static void HideQuickHelp(vcl::Window* pParent) { Help::ShowQuickHelp(pParent, 
{}, {}); }
+
 // Handler of the scrollbars
 IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, rScrollbar, void)
 {
@@ -677,6 +679,8 @@ IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, 
rScrollbar, void)
     if (rScrollbar.get_scroll_type() == ScrollType::Drag)
         m_pWrtShell->EnableSmooth( false );
 
+    bool bHidePending = nPgNum != 0;
+    nPgNum = 0; // avoid flicker from hiding then showing help window again
     EndScrollHdl(rScrollbar, false);
 
     if (!m_pWrtShell->GetViewOptions()->getBrowseMode() &&
@@ -698,36 +702,37 @@ IMPL_LINK(SwView, VertScrollHdl, weld::Scrollbar&, 
rScrollbar, void)
                 //QuickHelp:
                 if( m_pWrtShell->GetPageCnt() > 1 )
                 {
-                    if( !nPgNum || nPgNum != nPhNum )
+                    tools::Rectangle aRect;
+                    aRect.SetLeft( 
m_pVScrollbar->GetParent()->OutputToScreenPixel(
+                                        m_pVScrollbar->GetPosPixel() ).X() -8 
);
+                    aRect.SetTop( m_pVScrollbar->OutputToScreenPixel(
+                                    m_pVScrollbar->GetPointerPosPixel() ).Y() 
);
+                    aRect.SetRight( aRect.Left() );
+                    aRect.SetBottom( aRect.Top() );
+
+                    OUString sPageStr( GetPageStr( nPhNum, nVirtNum, sDisplay 
));
+                    SwContentAtPos aCnt(IsAttrAtPos::Outline | 
IsAttrAtPos::AllowContaining);
+                    bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, aCnt);
+                    if (bSuccess && !aCnt.sStr.isEmpty())
                     {
-                        tools::Rectangle aRect;
-                        aRect.SetLeft( 
m_pVScrollbar->GetParent()->OutputToScreenPixel(
-                                            m_pVScrollbar->GetPosPixel() ).X() 
-8 );
-                        aRect.SetTop( m_pVScrollbar->OutputToScreenPixel(
-                                        m_pVScrollbar->GetPointerPosPixel() 
).Y() );
-                        aRect.SetRight( aRect.Left() );
-                        aRect.SetBottom( aRect.Top() );
-
-                        OUString sPageStr( GetPageStr( nPhNum, nVirtNum, 
sDisplay ));
-                        SwContentAtPos aCnt(IsAttrAtPos::Outline | 
IsAttrAtPos::AllowContaining);
-                        bool bSuccess = m_pWrtShell->GetContentAtPos(aPos, 
aCnt);
-                        if (bSuccess && !aCnt.sStr.isEmpty())
-                        {
-                            sal_Int32 nChunkLen = 
std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
-                            std::u16string_view sChunk = aCnt.sStr.subView(0, 
nChunkLen);
-                            sPageStr = sPageStr + "  - " + sChunk;
-                            sPageStr = sPageStr.replace('\t', ' 
').replace(0x0a, ' ');
-                        }
-
-                        Help::ShowQuickHelp(m_pVScrollbar, aRect, sPageStr,
-                                        
QuickHelpFlags::Right|QuickHelpFlags::VCenter);
+                        sal_Int32 nChunkLen = 
std::min<sal_Int32>(aCnt.sStr.getLength(), 80);
+                        std::u16string_view sChunk = aCnt.sStr.subView(0, 
nChunkLen);
+                        sPageStr = sPageStr + "  - " + sChunk;
+                        sPageStr = sPageStr.replace('\t', ' ').replace(0x0a, ' 
');
                     }
+
+                    Help::ShowQuickHelp(m_pVScrollbar, aRect, sPageStr,
+                                    
QuickHelpFlags::Right|QuickHelpFlags::VCenter);
+                    bHidePending = false;
                     nPgNum = nPhNum;
                 }
             }
         }
     }
 
+    if (bHidePending)
+        HideQuickHelp(m_pVScrollbar);
+
     if (rScrollbar.get_scroll_type() == ScrollType::Drag)
         m_pWrtShell->EnableSmooth( true );
 }
@@ -741,7 +746,7 @@ void SwView::EndScrollHdl(weld::Scrollbar& rScrollbar, bool 
bHorizontal)
     if(nPgNum)
     {
         nPgNum = 0;
-        Help::ShowQuickHelp(bHorizontal ? m_pHScrollbar : m_pVScrollbar, 
tools::Rectangle(), OUString());
+        HideQuickHelp(bHorizontal ? m_pHScrollbar : m_pVScrollbar);
     }
     Point aPos( m_aVisArea.TopLeft() );
     bool bBorder = IsDocumentBorder();

Reply via email to