[Libreoffice-commits] core.git: sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Dec 16 19:38:44 UTC 2020
sw/source/uibase/docvw/AnnotationWin2.cxx | 11 ++++++++++-
sw/source/uibase/docvw/SidebarTxtControl.cxx | 25 +++++++++++++++++++------
sw/source/uibase/docvw/SidebarTxtControl.hxx | 5 +++++
3 files changed, 34 insertions(+), 7 deletions(-)
New commits:
commit 7206249249a72aad803f5534c694ee68e0ee6693
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Dec 16 17:29:01 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Dec 16 20:38:01 2020 +0100
don't scroll the document between mouse down and mouse up in an annotation
because that causes the editview to get a mousedown, then the window is
scolled under it, then a mouseup so it selects the text between the
location it was at mouse down and the new pos at mouse up which is
infuriating
Change-Id: Ie8d88f851ebe090eb2b1968f1ef6577183586506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107850
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index edcdf448d7b8..99c69edf0059 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1378,7 +1378,16 @@ IMPL_LINK( SwAnnotationWin, WindowEventListener, VclWindowEvent&, rEvent, void )
rEvent.GetWindow() == mpSidebarTextControl )
{
SetActiveSidebarWin();
- mrMgr.MakeVisible( this );
+ /* We want this SwAnnotationWin to become visible on activation,
+ but if we are activating because the mouse is pressed in the
+ annotation and SidebarTextControl::MouseButtonDown is calling
+ 'GrabFocus' then leave the MakeVisible to
+ SidebarTextControl::MouseButtonUp instead. That way a mouse down
+ doesn't scroll the writer window while the mouse is pressed, and so
+ doesn't select random text as the editview is scrolled under the
+ mouse */
+ if (!mpSidebarTextControl->MouseDownGainingFocus())
+ mrMgr.MakeVisible( this );
}
}
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx
index 26c45868bd89..bf3601cbe893 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.cxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx
@@ -67,6 +67,7 @@ SidebarTextControl::SidebarTextControl( sw::annotation::SwAnnotationWin& rSideba
, mrSidebarWin( rSidebarWin )
, mrDocView( rDocView )
, mrPostItMgr( rPostItMgr )
+ , mbMouseDownGainingFocus(false)
{
AddEventListener( LINK( &mrSidebarWin, sw::annotation::SwAnnotationWin, WindowEventListener ) );
}
@@ -215,6 +216,16 @@ void SidebarTextControl::LogicInvalidate(const tools::Rectangle* pRectangle)
SfxLokHelper::notifyInvalidation(rWrtShell.GetSfxViewShell(), sRectangle);
}
+void SidebarTextControl::MakeVisible()
+{
+ // PostItMgr::MakeVisible can lose our MapMode, save it.
+ auto oldMapMode = GetMapMode();
+ //let's make sure we see our note
+ mrPostItMgr.MakeVisible(&mrSidebarWin);
+ if (comphelper::LibreOfficeKit::isActive())
+ SetMapMode(oldMapMode);
+}
+
void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt )
{
if (getenv("SW_DEBUG") && rKeyEvt.GetKeyCode().GetCode() == KEY_F12)
@@ -246,12 +257,7 @@ void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt )
}
else
{
- // MakeVisible can lose our MapMode, save it.
- auto oldMapMode = GetMapMode();
- //let's make sure we see our note
- mrPostItMgr.MakeVisible(&mrSidebarWin);
- if (comphelper::LibreOfficeKit::isActive())
- SetMapMode(oldMapMode);
+ MakeVisible();
tools::Long aOldHeight = mrSidebarWin.GetPostItTextHeight();
bool bDone = false;
@@ -340,7 +346,9 @@ void SidebarTextControl::MouseButtonDown( const MouseEvent& rMEvt )
}
}
+ mbMouseDownGainingFocus = !HasFocus();
GrabFocus();
+
if ( GetTextView() )
{
GetTextView()->MouseButtonDown( rMEvt );
@@ -352,6 +360,11 @@ void SidebarTextControl::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( GetTextView() )
GetTextView()->MouseButtonUp( rMEvt );
+ if (mbMouseDownGainingFocus)
+ {
+ MakeVisible();
+ mbMouseDownGainingFocus = false;
+ }
}
IMPL_LINK( SidebarTextControl, OnlineSpellCallback, SpellCallbackInfo&, rInfo, void )
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
index 456aac4ef989..3460ba660ecd 100644
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
@@ -35,6 +35,9 @@ class SidebarTextControl : public Control
sw::annotation::SwAnnotationWin& mrSidebarWin;
SwView& mrDocView;
SwPostItMgr& mrPostItMgr;
+ bool mbMouseDownGainingFocus;
+
+ void MakeVisible();
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
@@ -61,6 +64,8 @@ class SidebarTextControl : public Control
virtual void MouseButtonUp(const MouseEvent& rMEvt) override;
virtual void MouseMove(const MouseEvent& rMEvt) override;
+ bool MouseDownGainingFocus() const { return mbMouseDownGainingFocus; }
+
OutlinerView* GetTextView() const;
DECL_LINK( OnlineSpellCallback, SpellCallbackInfo&, void );
More information about the Libreoffice-commits
mailing list