summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-09-18 13:10:43 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-09-18 21:25:12 +0200
commit1972d0d9d63639ce35096e412f3157a708dbb60a (patch)
tree62c563271ced7746bd628e5cd03dd714544ba650 /vcl/unx
parent35dfb73889a084fc4a428071471429396a7d1287 (diff)
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.mcnamara@collabora.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx11
1 files changed, 11 insertions, 0 deletions
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();
}