sd/source/ui/dlg/sdtreelb.cxx |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

New commits:
commit f504b90b046be0a4d8ba703f093cb68cc657b03f
Author:     Jim Raykowski <[email protected]>
AuthorDate: Tue Oct 7 00:28:10 2025 -0800
Commit:     Jim Raykowski <[email protected]>
CommitDate: Fri Oct 17 21:49:51 2025 +0200

    tdf#167573 sd_navigator: fix deleting an object deletes the whole page
    
    This patch uses a trick from commit
    f3c68cdf8f6a0273c62b493552f78af0138a44e8
    
    "An additional trick is to make sure that the current shell is the draw
    shell (and not the slide sorter) after navigation, so follow-up
    operations work with the selected object and not with the whole slide."
    
    Change-Id: I0d9a7ef0b532abc8cbec286f4b9b401e8acb699c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192007
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>

diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 6c5a1dc3ea33..bf30a390c259 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -65,6 +65,8 @@
 
 #include <unordered_set>
 
+#include <Window.hxx>
+
 using namespace com::sun::star;
 
 namespace {
@@ -324,6 +326,35 @@ IMPL_LINK(SdPageObjsTLV, KeyInputHdl, const KeyEvent&, 
rKEvt, bool)
         return false;
 
     const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
+
+    // tdf#167573 - Deleting an object using Navigator deletes the whole page
+    if (rKeyCode.GetCode() == KEY_DELETE)
+    {
+        // Seems this is needed for Gtk3 with Wayland but not with X11. Other 
VCL plugins seem not
+        // to need this before explicitly trying to grab the draw shell focus.
+        if (SfxViewShell* pCurSh = SfxViewShell::Current())
+        {
+            if (vcl::Window* pShellWnd = pCurSh->GetWindow())
+            {
+                pShellWnd->GrabFocus();
+            }
+        }
+        // The current shell may be the slide sorter. Explicitly try to grab 
the draw
+        // shell focus so delete works with the selected object(s) and not 
with the whole slide.
+        if (sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh())
+        {
+            if (sd::ViewShell* pViewShell = pDocShell->GetViewShell())
+            {
+                if (vcl::Window* pWindow = pViewShell->GetActiveWindow())
+                {
+                    pWindow->GrabFocus();
+                    // now grab focus back to the tree
+                    m_xTreeView->grab_focus();
+                }
+            }
+        }
+    }
+
     if (m_xAccel->execute(rKeyCode))
     {
         // the accelerator consumed the event

Reply via email to