sd/source/ui/dlg/navigatr.cxx | 42 ++++++++++++++++++------------------------ sd/source/ui/dlg/sdtreelb.cxx | 7 +------ sd/source/ui/inc/sdtreelb.hxx | 1 - 3 files changed, 19 insertions(+), 31 deletions(-)
New commits: commit 6039a47c4eebb1fe1b319d7bbaaabff54477d918 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Mon Sep 23 21:02:20 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Sep 24 14:06:00 2024 +0200 Don't change focus from sd navigator if it will be immediately refocused Instead of grabbing focus away from the treeview, and then grabbing focus back to the treeview (which disrupts the vcl treeview's ability to enter inline editing mode on 2nd click), just don't change focus at all if the focus will end up in the initial location. git show -w is your friend here Change-Id: Idb53fa95495f1819cd121079f3f51c39cc629336 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173830 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index 8741a2c913b4..88ea5d664108 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -415,33 +415,27 @@ IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, weld::TreeView&, bool) pDrawView->MarkObj(pCursorEntryObject, pDrawView->GetSdrPageView(), true); } - // moved here from SetGetFocusHdl. Reset the - // focus only if something has been selected in the - // document. - SfxViewShell* pCurSh = SfxViewShell::Current(); - - if ( pCurSh ) + if (mxTlbObjects->IsNavigationGrabsFocus()) { - vcl::Window* pShellWnd = pCurSh->GetWindow(); - if ( pShellWnd ) - pShellWnd->GrabFocus(); - } + // moved here from SetGetFocusHdl. Reset the + // focus only if something has been selected in the + // document. + SfxViewShell* pCurSh = SfxViewShell::Current(); - // We navigated to an object, but the current shell may be - // still the slide sorter. Explicitly try to grab the draw - // shell focus, so follow-up operations work with the object - // and not with the whole slide. - vcl::Window* pWindow = pViewShell->GetActiveWindow(); - if (pWindow) - pWindow->GrabFocus(); + if ( pCurSh ) + { + vcl::Window* pShellWnd = pCurSh->GetWindow(); + if ( pShellWnd ) + pShellWnd->GrabFocus(); + } - if (!mxTlbObjects->IsNavigationGrabsFocus()) - { - // This is the case when keyboard navigation inside the - // navigator should continue to work. - if (mxNavigatorDlg) - mxNavigatorDlg->GrabFocus(); - mxTlbObjects->grab_focus(); + // We navigated to an object, but the current shell may be + // still the slide sorter. Explicitly try to grab the draw + // shell focus, so follow-up operations work with the object + // and not with the whole slide. + vcl::Window* pWindow = pViewShell->GetActiveWindow(); + if (pWindow) + pWindow->GrabFocus(); } } } diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index ecf2e612051a..abfacd81baea 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -301,7 +301,6 @@ IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent&, rCEvt, bool) if (rCEvt.GetCommand() == CommandEventId::ContextMenu) { - m_bMouseReleased = false; m_xTreeView->grab_focus(); // select clicked entry @@ -316,7 +315,6 @@ IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent&, rCEvt, bool) } bool bRet = m_aPopupMenuHdl.Call(rCEvt); - m_bMouseReleased = true; return bRet; } @@ -357,7 +355,6 @@ IMPL_LINK(SdPageObjsTLV, KeyInputHdl, const KeyEvent&, rKEvt, bool) IMPL_LINK(SdPageObjsTLV, MousePressHdl, const MouseEvent&, rMEvt, bool) { - m_bMouseReleased = false; m_bEditing = false; m_bSelectionHandlerNavigates = rMEvt.GetClicks() == 1; m_bNavigationGrabsFocus = rMEvt.GetClicks() != 1; @@ -366,7 +363,6 @@ IMPL_LINK(SdPageObjsTLV, MousePressHdl, const MouseEvent&, rMEvt, bool) IMPL_LINK_NOARG(SdPageObjsTLV, MouseReleaseHdl, const MouseEvent&, bool) { - m_bMouseReleased = true; if (m_aMouseReleaseHdl.IsSet() && m_aMouseReleaseHdl.Call(MouseEvent())) return false; @@ -845,8 +841,7 @@ void SdPageObjsTLV::Select() { m_nSelectEventId = nullptr; - // m_bMouseReleased is a hack to make inplace editing work for X11 - if (m_bMouseReleased) + if (IsEditingActive()) return; m_bLinkableSelected = true; diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index 1f6026b557d4..ffeda2afb356 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -102,7 +102,6 @@ private: */ bool m_bNavigationGrabsFocus; - bool m_bMouseReleased = true; // hack for x11 inplace editing bool m_bEditing = false; SelectionMode m_eSelectionMode;