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 7f6907d545af386f0ed34a7c9409a90b965164a3
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Sep 23 21:02:20 2024 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Sep 25 12:36:16 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 up in the initial location.
    
    git show -w is your friend here
    
    Change-Id: Idb53fa95495f1819cd121079f3f51c39cc629336
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173829
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>
    (cherry picked from commit 6c37d95fbbcc97c2dc824ecee8369140a6442980)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173905
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index 51ad28d89e4b..b1703e111f77 100644
--- a/sd/source/ui/dlg/navigatr.cxx
+++ b/sd/source/ui/dlg/navigatr.cxx
@@ -463,33 +463,27 @@ IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, 
weld::TreeView&, bool)
                 // state update.
                 mpBindings->Update();
 
-                // 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 7eb476cfb48b..69001315e936 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -306,7 +306,6 @@ IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent&, 
rCEvt, bool)
 
     if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
     {
-        m_bMouseReleased = false;
         m_xTreeView->grab_focus();
 
         // select clicked entry
@@ -321,7 +320,6 @@ IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent&, 
rCEvt, bool)
         }
 
         bool bRet = m_aPopupMenuHdl.Call(rCEvt);
-        m_bMouseReleased = true;
         return bRet;
     }
 
@@ -362,7 +360,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;
@@ -371,7 +368,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;
 
@@ -850,8 +846,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 bb09653db584..1ea80f011426 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;

Reply via email to