sw/inc/AnnotationWin.hxx                  |    1 +
 sw/source/uibase/docvw/AnnotationWin2.cxx |   13 +++++++++++++
 2 files changed, 14 insertions(+)

New commits:
commit 56f2abbf3f107d849305df507818f00e6f6086df
Author:     Caolán McNamara <[email protected]>
AuthorDate: Tue Mar 3 11:58:45 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Mar 4 09:31:57 2026 +0100

    tdf#170645 During a save the comment can lose focus
    
    During the save the ui is set disabled/insensitive, and the gtk
    widget in the comment will lose focus, and not automatically regain
    it when enabled/sensitive. So manually restore it when enabled and
    it should still have focus.
    
    Change-Id: Icf08d6695cb1d6883636747bb3d70e18f64fb75c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200884
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 70ba4fa42d0c..47b5ab6209f7 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -213,6 +213,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
 
         virtual void    LoseFocus() override;
         virtual void    GetFocus() override;
+        virtual void    StateChanged(StateChangedType nStateChange) override;
 
         virtual void Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect) override;
         void        SetSizePixel( const Size& rNewSize ) override;
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 28fb6d9ff993..801e21892e6f 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -971,6 +971,19 @@ void SwAnnotationWin::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rec
     }
 }
 
+// tdf#170645 During a save the UI is disabled/insensitive so in GTK the
+// widget with focus will lose it, so restore that when enabled/sensitive
+void SwAnnotationWin::StateChanged(StateChangedType nStateChange)
+{
+    InterimItemWindow::StateChanged(nStateChange);
+    if (nStateChange == StateChangedType::Enable && IsEnabled()
+        && mrMgr.GetActiveSidebarWin() == this
+        && mxSidebarTextControl && !mxSidebarTextControl->HasFocus())
+    {
+        mxSidebarTextControl->GrabFocus();
+    }
+}
+
 void SwAnnotationWin::ShowNote()
 {
     SetPosAndSize();

Reply via email to