sw/source/uibase/docvw/edtwin.cxx | 30 ++++++++++++++++++++++-------- sw/source/uibase/inc/edtwin.hxx | 3 ++- 2 files changed, 24 insertions(+), 9 deletions(-)
New commits: commit e37d5714d6d26ab5a6e83c10c79c33b52d556342 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:21:37 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/+/184746 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index c9de4a1607a2..c6f6347e3165 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -160,6 +160,8 @@ using namespace sw::mark; using namespace ::com::sun::star; +#define SCROLL_TIMER_RETARD_LIMIT 5 + /** * Globals */ @@ -652,6 +654,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() ); @@ -713,8 +716,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; @@ -725,18 +730,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(); @@ -5484,6 +5497,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 ddce03274402..08d3a84ee739 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();