tdf#149823 follow MouseWheelBehaviour for GtkSpinButton
so with FocusOnly set when it doesn't have focus don't react to scroll-events
Change-Id: I520550590c7102ad823b677dfcce184b8b4ca377
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137268
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 4aacd397..6f04f18 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -16639,6 +16639,28 @@ private:
return FRound(fValue * Power10(get_digits()));
}
#if !GTK_CHECK_VERSION(4, 0, 0)
static gboolean signalScroll(GtkWidget* pWidget, GdkEventScroll* /*pEvent*/, gpointer /*widget*/)
{
// tdf#149823 follow WheelBehavior setting, so if we don't have focus
// we don't react to the scroll-event.
MouseWheelBehaviour nWheelBehavior(Application::GetSettings().GetMouseSettings().GetWheelBehavior());
switch (nWheelBehavior)
{
case MouseWheelBehaviour::ALWAYS:
break;
case MouseWheelBehaviour::Disable:
g_signal_stop_emission_by_name(pWidget, "scroll-event");
break;
case MouseWheelBehaviour::FocusOnly:
if (!gtk_widget_has_focus(pWidget))
g_signal_stop_emission_by_name(pWidget, "scroll-event");
break;
}
return false;
}
#endif
public:
GtkInstanceSpinButton(GtkSpinButton* pButton, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
: GtkInstanceEditable(GTK_WIDGET(pButton), pBuilder, bTakeOwnership)
@@ -16653,6 +16675,9 @@ public:
#if GTK_CHECK_VERSION(4, 0, 0)
gtk_text_set_activates_default(GTK_TEXT(m_pDelegate), true);
#endif
#if !GTK_CHECK_VERSION(4, 0, 0)
g_signal_connect(pButton, "scroll-event", G_CALLBACK(signalScroll), this);
#endif
}
virtual sal_Int64 get_value() const override