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>
This commit is contained in:
Caolán McNamara 2024-09-18 13:10:43 +01:00
parent 35dfb73889
commit 1972d0d9d6

View file

@ -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();
}