Use accumulator for volume scrolling events

This results in much smoother experience on my touchpad.
This commit is contained in:
Eri the Switch
2024-07-21 13:02:08 +03:00
committed by Jonas Kvinge
parent 37743606a2
commit 3ecf224d91
3 changed files with 26 additions and 10 deletions

View File

@@ -48,6 +48,7 @@ class VolumeSlider : public SliderSlider {
public:
explicit VolumeSlider(QWidget *parent, uint max = 0);
void SetEnabled(const bool enabled);
void HandleWheel(const int delta);
protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
@@ -70,6 +71,9 @@ class VolumeSlider : public SliderSlider {
static const int ANIM_INTERVAL = 18;
static const int ANIM_MAX = 18;
// Units are eighths of a degree
static const int WHEEL_ROTATION_PER_STEP = 30;
VolumeSlider(const VolumeSlider&);
VolumeSlider &operator=(const VolumeSlider&);
@@ -77,6 +81,8 @@ class VolumeSlider : public SliderSlider {
QPixmap drawVolumePixmap() const;
void drawVolumeSliderHandle();
int wheel_accumulator_;
bool anim_enter_;
int anim_count_;
QTimer *timer_anim_;