From c9e28b05574e1feed9a4d2971f7805b5c9c4ba2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salih=20Efe=20Erg=C3=BCr?= <61908056+salihefee@users.noreply.github.com> Date: Mon, 1 Apr 2024 18:12:18 +0300 Subject: [PATCH] Fixed natural scrolling bug (#9) * Fixed natural scrolling bug * Moved ternary out of the switch statement * Update volume_scroller@francislavoie.github.io/extension.js * Update volume_scroller@francislavoie.github.io/extension.js --------- Co-authored-by: Francis Lavoie --- .../extension.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/volume_scroller@francislavoie.github.io/extension.js b/volume_scroller@francislavoie.github.io/extension.js index 7ec0601..930673f 100644 --- a/volume_scroller@francislavoie.github.io/extension.js +++ b/volume_scroller@francislavoie.github.io/extension.js @@ -15,7 +15,7 @@ export default class VolumeScrollerExtension extends Extension { enable() { this.settings = this.getSettings(); const setGranularity = () => { - this.volume_granularity = this.settings.get_int("granularity") / 100.0; + this.volume_granularity = this.settings.get_int("granularity") / 100.0; }; this.controller = Volume.getMixerControl(); @@ -62,13 +62,21 @@ export default class VolumeScrollerExtension extends Extension { _handle_scroll(_actor, event) { let volume = this.sink.volume; - switch (event.get_scroll_direction()) { + const settings = new Gio.Settings({ + schema_id: "org.gnome.desktop.peripherals.touchpad", + }); + + const naturalScroll = settings.get_boolean("natural-scroll"); + const multiplier = naturalScroll ? -1 : 1; + + const scrollDirection = event.get_scroll_direction(); + switch (scrollDirection) { case Clutter.ScrollDirection.UP: - volume += this._get_step(); + volume += this._get_step() * multiplier; break; case Clutter.ScrollDirection.DOWN: - volume -= this._get_step(); + volume -= this._get_step() * multiplier; break; default: