vcl/unx/gtk3/gtkinst.cxx |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 1972d0d9d63639ce35096e412f3157a708dbb60a
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Sep 18 13:10:43 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Sep 18 21:25:12 2024 +0200

    Resolves: tdf#162538 explicitly make buttons gain focus on activatation
    
    even if by keyboard. So spinbuttons that depend on losing focus to
    update will update before 'ok' is called.
    
    Change-Id: I1eddd4c29c3ffeb06ead058c9efbdfde01418589
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173616
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 2c54e1662e41..4bad56a9544e 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -9914,6 +9914,17 @@ private:
     {
         GtkInstanceButton* pThis = static_cast<GtkInstanceButton*>(widget);
         SolarMutexGuard aGuard;
+        // tdf#162538, SpinButtons update on losing focus, and use of keyboard
+        // short cuts to activate buttons doesn't guarantee the button gains
+        // focus when activated, so ensure that explicitly so spinbuttons are
+        // updated.
+        if (!gtk_widget_has_focus(pThis->m_pWidget))
+        {
+            GtkWindow* pWindow = 
GTK_WINDOW(widget_get_toplevel(pThis->m_pWidget));
+            GtkWidget* pFocus = pWindow ? gtk_window_get_focus(pWindow) : 
nullptr;
+            if (pFocus && GTK_IS_SPIN_BUTTON(pFocus))
+                gtk_widget_grab_focus(pThis->m_pWidget);
+        }
         pThis->signal_clicked();
     }
 

Reply via email to