Skip to content

Commit

Permalink
Fixed natural scrolling bug (#9)
Browse files Browse the repository at this point in the history
* Fixed natural scrolling bug

* Moved ternary out of the switch statement

* Update [email protected]/extension.js

* Update [email protected]/extension.js

---------

Co-authored-by: Francis Lavoie <[email protected]>
  • Loading branch information
salihefee and francislavoie authored Apr 1, 2024
1 parent 4534e23 commit c9e28b0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c9e28b0

Please sign in to comment.