sw/inc/AnnotationWin.hxx | 5 ++++- sw/source/uibase/docvw/AnnotationMenuButton.cxx | 6 +++++- sw/source/uibase/docvw/AnnotationWin2.cxx | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-)
New commits: commit 091f244d4d68ea9973a502632c6aeee19d702139 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Sep 28 12:32:56 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Sep 28 21:10:34 2020 +0200 Related: tdf#136985 restore focus to doc it wasn't initially in the comment after processing a menu command if we grabbed focus to a comment at the start of the the menu command processing Change-Id: I6cf4b59fc0c5d3e09578cb0466b15ae358cfb0ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103547 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index a11ec583792f..3be381bf3a7c 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -197,7 +197,10 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window bool IsThreadResolved(); // Set this SwAnnotationWin as the currently active one - void SetActiveSidebarWin(); + // return false if it was already active + bool SetActiveSidebarWin(); + // Unset this SwAnnotationWin as the currently active one + void UnsetActiveSidebarWin(); /// Find the first annotation for the thread which this annotation is in. /// This may be the same annotation as this one. diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx b/sw/source/uibase/docvw/AnnotationMenuButton.cxx index 9ee6ac0ec805..663141839d00 100644 --- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx +++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx @@ -72,7 +72,7 @@ void AnnotationMenuButton::Select() // tdf#136682 ensure this is the currently active sidebar win so the command // operates in an active sidebar context - mrSidebarWin.SetActiveSidebarWin(); + bool bSwitchedFocus = mrSidebarWin.SetActiveSidebarWin(); if (sIdent == "reply") mrSidebarWin.ExecuteCommand(FN_REPLY); @@ -90,6 +90,10 @@ void AnnotationMenuButton::Select() mrSidebarWin.ExecuteCommand(FN_DELETE_ALL_NOTES); else if (sIdent == "formatall") mrSidebarWin.ExecuteCommand(FN_FORMAT_ALL_NOTES); + + if (bSwitchedFocus) + mrSidebarWin.UnsetActiveSidebarWin(); + mrSidebarWin.GrabFocusToDocument(); } void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt ) diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index a84d0017a8f9..be1da018506a 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1373,14 +1373,25 @@ IMPL_LINK( SwAnnotationWin, WindowEventListener, VclWindowEvent&, rEvent, void ) } } -void SwAnnotationWin::SetActiveSidebarWin() +bool SwAnnotationWin::SetActiveSidebarWin() { if (mrMgr.GetActiveSidebarWin() == this) - return; + return false; const bool bLockView = mrView.GetWrtShell().IsViewLocked(); mrView.GetWrtShell().LockView( true ); mrMgr.SetActiveSidebarWin(this); mrView.GetWrtShell().LockView( bLockView ); + return true; +} + +void SwAnnotationWin::UnsetActiveSidebarWin() +{ + if (mrMgr.GetActiveSidebarWin() != this) + return; + const bool bLockView = mrView.GetWrtShell().IsViewLocked(); + mrView.GetWrtShell().LockView( true ); + mrMgr.SetActiveSidebarWin(nullptr); + mrView.GetWrtShell().LockView( bLockView ); } IMPL_LINK(SwAnnotationWin, ScrollHdl, ScrollBar*, pScroll, void) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits