From 5b415043eb93fde51db3bf9e57f26cd30b1b4a2b Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Wed, 1 Jul 2026 15:00:01 +0900
Subject: kicker: add config option to set the taskbar's mouse wheel scrolling
 speed.

The speed and algorithm of the scrolling using the buttons has been preserved, while the new option allows to set a specific speed for scrolling using the mouse wheel. This relates to issue #758.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 kcontrol/taskbar/kcmtaskbar.cpp  |  31 ++++++++----
 kcontrol/taskbar/kcmtaskbar.h    |   1 +
 kcontrol/taskbar/kcmtaskbarui.ui | 107 +++++++++++++++++++++++++++++++++++++--
 kicker/taskbar/taskbar.cpp       |  11 ++--
 kicker/taskbar/taskbar.h         |   1 +
 kicker/taskbar/taskbar.kcfg      |   7 +++
 6 files changed, 143 insertions(+), 15 deletions(-)

diff --git a/kcontrol/taskbar/kcmtaskbar.cpp b/kcontrol/taskbar/kcmtaskbar.cpp
index d241055d6..0c1af6069 100644
--- a/kcontrol/taskbar/kcmtaskbar.cpp
+++ b/kcontrol/taskbar/kcmtaskbar.cpp
@@ -19,6 +19,7 @@
 #include <tqcheckbox.h>
 #include <tqcombobox.h>
 #include <tqlayout.h>
+#include <tqslider.h>
 #include <tqtimer.h>
 #include <tqvaluelist.h>
 #include <tqfile.h>
@@ -28,15 +29,16 @@
 
 #include <dcopclient.h>
 
+#include <kcolorbutton.h>
+#include <kdialog.h>
+#include <kgenericfactory.h>
+#include <kiconloader.h>
+#include <knuminput.h>
 #include <tdeaboutdata.h>
 #include <tdeapplication.h>
 #include <tdeconfig.h>
-#include <kdialog.h>
-#include <kgenericfactory.h>
-#include <twin.h>
-#include <kcolorbutton.h>
 #include <tdestandarddirs.h>
-#include <kiconloader.h>
+#include <twin.h>
 
 #define protected public
 #include "kcmtaskbarui.h"
@@ -244,10 +246,6 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
     }
     m_widget->appearance->insertItem(i18n("Custom"));
 
-    connect(m_widget->appearance, TQ_SIGNAL(activated(int)),
-            this, TQ_SLOT(appearanceChanged(int)));
-    connect(m_widget->kcfg_DisplayIconsNText, TQ_SIGNAL(activated(int)),
-            this, TQ_SLOT(displayIconsNTextChanged(int)));
     addConfig(m_settingsObject, m_widget);
 
     setQuickHelp(i18n("<h1>Taskbar</h1> You can configure the taskbar here."
@@ -266,8 +264,14 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
     m_widget->kcfg_GroupTasks->insertStringList(i18nGroupModeList());
     m_widget->kcfg_ShowTaskStates->insertStringList(i18nShowTaskStatesList());
 
+    connect(m_widget->appearance, TQ_SIGNAL(activated(int)),
+            this, TQ_SLOT(appearanceChanged(int)));
+    connect(m_widget->kcfg_DisplayIconsNText, TQ_SIGNAL(activated(int)),
+            this, TQ_SLOT(displayIconsNTextChanged(int)));
     connect(m_widget->kcfg_GroupTasks, TQ_SIGNAL(activated(int)),
             this, TQ_SLOT(slotUpdateComboBox()));
+    connect(m_widget->kcfg_ScrollTaskbarWAction, TQ_SIGNAL(activated(int)),
+            this, TQ_SLOT(slotScrollTaskbarActionChanged(int)));
     connect(m_widget->kcfg_UseCustomColors, TQ_SIGNAL(stateChanged(int)), this, TQ_SLOT(slotUpdateCustomColors()));
 
     slotUpdateCustomColors();
@@ -379,6 +383,13 @@ void TaskbarConfig::slotUpdateCustomColors()
     m_widget->taskBackgroundColorLabel->setEnabled(m_widget->kcfg_UseCustomColors->isChecked());
 }
 
+void TaskbarConfig::slotScrollTaskbarActionChanged(int index)
+{
+    m_widget->wheelScrollSpeedLabel->setEnabled(index != 0);
+    m_widget->wheelScrollStepSlider->setEnabled(index != 0);
+    m_widget->kcfg_WheelScrollStep->setEnabled(index != 0);
+}
+
 void TaskbarConfig::slotUpdateComboBox()
 {
     int pos = TaskBarSettings::ActivateRaiseOrMinimize;
@@ -467,6 +478,7 @@ void TaskbarConfig::load()
     slotUpdateComboBox();
     updateAppearanceCombo();
     updateIconsTextCombo();
+    slotScrollTaskbarActionChanged(m_settingsObject->wAction(TaskBarSettings::ScrollTaskbar));
     m_widget->showAllScreens->setChecked(!m_settingsObject->showCurrentScreenOnly());
 
     int iconSize = m_settingsObject->iconSize();
@@ -508,6 +520,7 @@ void TaskbarConfig::defaults()
     slotUpdateComboBox();
     updateAppearanceCombo();
     updateIconsTextCombo();
+    slotScrollTaskbarActionChanged(m_settingsObject->wAction(TaskBarSettings::ScrollTaskbar));
 }
 
 void TaskbarConfig::notChanged()
diff --git a/kcontrol/taskbar/kcmtaskbar.h b/kcontrol/taskbar/kcmtaskbar.h
index 7a16aa738..c1b57c30c 100644
--- a/kcontrol/taskbar/kcmtaskbar.h
+++ b/kcontrol/taskbar/kcmtaskbar.h
@@ -68,6 +68,7 @@ protected slots:
     void slotUpdateComboBox();
     void appearanceChanged(int);
     void displayIconsNTextChanged(int);
+    void slotScrollTaskbarActionChanged(int);
     void notChanged();
     void slotUpdateCustomColors();
 
diff --git a/kcontrol/taskbar/kcmtaskbarui.ui b/kcontrol/taskbar/kcmtaskbarui.ui
index c50bcd1f3..04273d1bc 100644
--- a/kcontrol/taskbar/kcmtaskbarui.ui
+++ b/kcontrol/taskbar/kcmtaskbarui.ui
@@ -1069,7 +1069,7 @@
                                     <cstring>kcfg_CycleWindowsWAction</cstring>
                                 </property>
                             </widget>
-                            <widget class="TQComboBox" row="0" column="1">
+                            <widget class="TQComboBox" row="0" column="1" colspan="2">
                                 <property name="name">
                                     <cstring>kcfg_CycleWindowsWAction</cstring>
                                 </property>
@@ -1096,7 +1096,7 @@
                                     <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
                             </widget>
-                            <widget class="TQComboBox" row="1" column="1">
+                            <widget class="TQComboBox" row="1" column="1" colspan="2">
                                 <property name="name">
                                     <cstring>kcfg_ScrollTaskbarWAction</cstring>
                                 </property>
@@ -1112,6 +1112,94 @@
                                   <string>If this option is enabled (with or without a keyboard modifier) and if the taskbar is holding more buttons than what could be displayed (the two arrows for scrolling are visible), you can scroll the taskbar by using the mouse wheel.</string>
                                 </property>
                             </widget>
+                            <spacer row="2" column="0" colspan="2">
+                                <property name="name">
+                                    <cstring>scrollStepSpacer</cstring>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Horizontal</enum>
+                                </property>
+                                <property name="sizeHint">
+                                    <size>
+                                        <width>30</width>
+                                        <height>40</height>
+                                    </size>
+                                </property>
+                            </spacer>
+                            <widget class="TQLayoutWidget" row="2" column="2">
+                                <property name="name">
+                                    <cstring>scrollStepLayout</cstring>
+                                </property>
+                                <hbox>
+                                    <property name="name">
+                                        <cstring>unnamed</cstring>
+                                    </property>
+                                    <spacer>
+                                        <property name="name">
+                                            <cstring>spacer36</cstring>
+                                        </property>
+                                        <property name="orientation">
+                                            <enum>Horizontal</enum>
+                                        </property>
+                                        <property name="sizeType">
+                                            <enum>Fixed</enum>
+                                        </property>
+                                        <property name="sizeHint">
+                                            <size>
+                                                <width>30</width>
+                                            </size>
+                                        </property>
+                                    </spacer>
+                                    <widget class="TQLabel">
+                                        <property name="name">
+                                            <cstring>wheelScrollSpeedLabel</cstring>
+                                        </property>
+                                        <property name="text">
+                                            <string>Scrolling speed</string>
+                                        </property>
+                                    </widget>
+                                    <widget class="TQSlider">
+                                        <property name="name">
+                                            <cstring>wheelScrollStepSlider</cstring>
+                                        </property>
+                                        <property name="minValue">
+                                            <number>1</number>
+                                        </property>
+                                        <property name="maxValue">
+                                            <number>128</number>
+                                        </property>
+                                        <property name="pageStep">
+                                            <number>8</number>
+                                        </property>
+                                        <property name="value">
+                                            <number>16</number>
+                                        </property>
+                                        <property name="orientation">
+                                            <enum>Horizontal</enum>
+                                        </property>
+                                        <property name="tickmarks">
+                                            <enum>NoMarks</enum>
+                                        </property>
+                                    </widget>
+                                    <widget class="KIntNumInput">
+                                        <property name="name">
+                                            <cstring>kcfg_WheelScrollStep</cstring>
+                                        </property>
+                                        <property name="value">
+                                            <number>16</number>
+                                        </property>
+                                        <property name="minValue">
+                                            <number>1</number>
+                                        </property>
+                                        <property name="maxValue">
+                                            <number>128</number>
+                                        </property>
+                                        <property name="suffix">
+                                            <string> pixels</string>
+                                        </property>
+                                    </widget>
+                                </hbox>
+                            </widget>
                         </grid>
                     </widget>
                     <spacer>
@@ -1193,13 +1281,26 @@
         <receiver>kcfg_SortByDesktop</receiver>
         <slot>setEnabled(bool)</slot>
     </connection>
+    <connection>
+        <sender>wheelScrollStepSlider</sender>
+        <signal>valueChanged(int)</signal>
+        <receiver>kcfg_WheelScrollStep</receiver>
+        <slot>setValue(int)</slot>
+    </connection>
+    <connection>
+        <sender>kcfg_WheelScrollStep</sender>
+        <signal>valueChanged(int)</signal>
+        <receiver>wheelScrollStepSlider</receiver>
+        <slot>setValue(int)</slot>
+    </connection>
 </connections>
 <includes>
     <include location="global" impldecl="in implementation">kcolorbutton.h</include>
     <include location="global" impldecl="in implementation">kdialog.h</include>
+    <include location="global" impldecl="in implementation">klineedit.h</include>
+    <include location="global" impldecl="in implementation">knuminput.h</include>
     <include location="global" impldecl="in implementation">kseparator.h</include>
     <include location="global" impldecl="in implementation">tdefontcombo.h</include>
-    <include location="global" impldecl="in implementation">klineedit.h</include>
     <include location="global" impldecl="in implementation">tdefontrequester.h</include>
     <include location="global" impldecl="in implementation">tqtabwidget.h</include>
 </includes>
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index 896c4ae5b..e2486e348 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -255,6 +255,7 @@ void TaskBar::configure()
     m_scrollTaskbarAction = READ_MERGED_TASKBAR_WACTION(TaskBarSettings::ScrollTaskbar);
     m_showTaskStates = READ_MERGED_TASKBAR_SETTING(showTaskStates);
     m_iconSize = READ_MERGED_TASKBAR_SETTING(iconSize);
+    m_wheelScrollStep = READ_MERGED_TASKBAR_SETTING(wheelScrollStep);
 
     m_currentScreen = -1;    // Show all screens or re-get our screen
     m_showOnlyCurrentScreen = (READ_MERGED_TASKBAR_SETTING(showCurrentScreenOnly) &&
@@ -1206,13 +1207,17 @@ void TaskBar::wheelEvent(TQWheelEvent* e)
         (scrollAction == m_settingsObject->ModCtrl && ctrlPressed) ||
         (scrollAction == m_settingsObject->ModShift && shiftPressed))
     {
-        if (e->delta() > 0)
+        // the delta is defined as multiples of WHEEL_DELTA,
+        // which is set to 120. See TQETWidget::translateMouseEvent()
+        // in tqapplication_x11.cpp for more details.
+        int step = e->delta() * m_wheelScrollStep / 120;
+        if ( orientation() == TQt::Horizontal )
         {
-            scrollLeftUp();
+            scrollBy( -step, 0 );
         }
         else
         {
-            scrollRightDown();
+            scrollBy( 0, -step );
         }
     }
 }
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index 205418f71..1f2e04b1f 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -155,6 +155,7 @@ private:
     bool                m_showOnlyIconified;
     int                 m_showTaskStates;
     int                 m_iconSize;
+    int                 m_wheelScrollStep;
     ArrowType           arrowType;
     TaskContainer::List containers;
     TaskContainer::List m_hiddenContainers;
diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg
index 1ec3abaa1..57a018467 100644
--- a/kicker/taskbar/taskbar.kcfg
+++ b/kicker/taskbar/taskbar.kcfg
@@ -176,6 +176,13 @@
             <label>Wheel actions</label>
             <whatsthis></whatsthis>
         </entry>
+        <entry key="WheelScrollStep" type="Int">
+            <default>16</default>
+            <min>1</min>
+            <max>128</max>
+            <label>Scroll step size</label>
+            <whatsthis>Sets the number of pixels the taskbar scrolls with each step when using the mouse wheel.<br/>Scrolling with the buttons will used a fixed scrolling pattern, starting slow and accelerating over time.</whatsthis>
+        </entry>
     </group>
 
     <group name="Appearance">
-- 
cgit v1.2.3

