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

New commits:
commit e3f5bf99ab7b558d867449e7142c982d667fc2a0
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Jul 20 16:33:20 2022 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Jul 21 14:02:46 2022 +0200

    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 <[email protected]>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 4aacd3979b4e..6f04f18f730a 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)
@@ -16652,6 +16674,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
     }
 

Reply via email to