sw/source/uibase/docvw/edtwin.cxx | 30 ++++++++++++++++++++++-------- sw/source/uibase/inc/edtwin.hxx | 3 ++- 2 files changed, 24 insertions(+), 9 deletions(-)
New commits: commit 7fc7dc679d61f7d5313733005c244c87d25f32fd Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue Apr 29 09:21:30 2025 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue May 6 02:18:13 2025 +0200 tdf#50743 improve scrolling with selection Delay calculation of scrolling timeout for the first 5 calls to make it easier to scroll even if you put the mouse cursor too far outside of the document window. Change-Id: If370f87cc439e7e3321078c1334c0a17e6ec6046 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184745 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index bac056f7ae9d..efd153131ff4 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -159,6 +159,8 @@ using namespace sw::mark; using namespace ::com::sun::star; +#define SCROLL_TIMER_RETARD_LIMIT 5 + /** * Globals */ @@ -654,6 +656,7 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) */ IMPL_LINK_NOARG(SwEditWin, TimerHandler, Timer *, void) { + ++m_nTimerCalls; SwWrtShell &rSh = m_rView.GetWrtShell(); Point aModPt( m_aMovePos ); const SwRect aOldVis( rSh.VisArea() ); @@ -715,8 +718,10 @@ IMPL_LINK_NOARG(SwEditWin, TimerHandler, Timer *, void) JustifyAreaTimer(); } -void SwEditWin::JustifyAreaTimer() +void SwEditWin::JustifyAreaTimer(bool bStart) { + if (bStart) + m_nTimerCalls = 0; const tools::Rectangle &rVisArea = GetView().GetVisArea(); #ifdef UNX const tools::Long coMinLen = 40; @@ -727,18 +732,26 @@ void SwEditWin::JustifyAreaTimer() nDiff = std::max( std::max( m_aMovePos.Y() - rVisArea.Bottom(), rVisArea.Top() - m_aMovePos.Y() ), std::max( m_aMovePos.X() - rVisArea.Right(), rVisArea.Left() - m_aMovePos.X())); - m_aTimer.SetTimeout( std::max( coMinLen, nTimeout - nDiff) ); - m_eScrollSizeMode = m_aTimer.GetTimeout() < 100 ? - ScrollSizeMode::ScrollSizeTimer2 : - m_aTimer.GetTimeout() < 400 ? - ScrollSizeMode::ScrollSizeTimer : - ScrollSizeMode::ScrollSizeMouseSelection; + if (m_nTimerCalls < SCROLL_TIMER_RETARD_LIMIT) + { + m_aTimer.SetTimeout(nTimeout); + m_eScrollSizeMode = ScrollSizeMode::ScrollSizeMouseSelection; + } + else + { + m_aTimer.SetTimeout( std::max( coMinLen, nTimeout - nDiff) ); + m_eScrollSizeMode = m_aTimer.GetTimeout() < 100 ? + ScrollSizeMode::ScrollSizeTimer2 : + m_aTimer.GetTimeout() < 400 ? + ScrollSizeMode::ScrollSizeTimer : + ScrollSizeMode::ScrollSizeMouseSelection; + } } void SwEditWin::LeaveArea(const Point &rPos) { m_aMovePos = rPos; - JustifyAreaTimer(); + JustifyAreaTimer(true); if( !m_aTimer.IsActive() ) m_aTimer.Start(); m_pShadCursor.reset(); @@ -5526,6 +5539,7 @@ SwEditWin::SwEditWin(vcl::Window *pParent, SwView &rMyView): DragSourceHelper( this ), m_aTimer("SwEditWin"), + m_nTimerCalls(0), m_aKeyInputFlushTimer("SwEditWin m_aKeyInputFlushTimer"), m_eBufferLanguage(LANGUAGE_DONTKNOW), m_eScrollSizeMode(ScrollSizeMode::ScrollSizeMouseSelection), diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx index bb87a61a39ca..bd227cc0b661 100644 --- a/sw/source/uibase/inc/edtwin.hxx +++ b/sw/source/uibase/inc/edtwin.hxx @@ -75,6 +75,7 @@ class SAL_DLLPUBLIC_RTTI SwEditWin final : public vcl::DocWindow, * regularly. */ AutoTimer m_aTimer; + sal_uInt32 m_nTimerCalls; // timer for ANY-KeyInput question without a following KeyInputEvent Timer m_aKeyInputFlushTimer; @@ -136,7 +137,7 @@ class SAL_DLLPUBLIC_RTTI SwEditWin final : public vcl::DocWindow, SwTextFrame* m_pSavedOutlineFrame = nullptr; void LeaveArea(const Point &); - void JustifyAreaTimer(); + void JustifyAreaTimer(bool bStart = false); inline void EnterArea(); void ResetMouseButtonDownFlags();