Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if natural-scroll is enabled, invert scroll inputs #113

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class MprisLabel extends PanelMenu.Button {
const EXTENSION_PLACE = this.settings.get_string('extension-place');
const REPOSITION_DELAY = this.settings.get_int('reposition-delay');

this.mouseSettings = new Gio.Settings({ schema: 'org.gnome.desktop.peripherals.mouse' });
this.touchpadSettings = new Gio.Settings({ schema: 'org.gnome.desktop.peripherals.touchpad' });

this.box = new St.BoxLayout({
x_align: Clutter.ActorAlign.FILL
});
Expand Down Expand Up @@ -172,7 +175,7 @@ class MprisLabel extends PanelMenu.Button {
return Clutter.EVENT_STOP

if (event.is_pointer_emulated())
return Clutter.EVENT_PROPAGATE;
return Clutter.EVENT_STOP;

let delta = 0;
const time_delta = Date.now() - this.last_scroll;
Expand All @@ -198,6 +201,22 @@ class MprisLabel extends PanelMenu.Button {
return Clutter.EVENT_PROPAGATE;
}

// If natural-scroll is enabled, the scroll event we get is inverted.
// We need to invert it back.
switch (event.get_source_device().get_device_type()) {
case Clutter.InputDeviceType.POINTER_DEVICE:
// mouse
if(this.mouseSettings.get_boolean('natural-scroll'))
delta = -delta;
break;

case Clutter.InputDeviceType.TOUCHPAD_DEVICE:
// touchpad
if(this.touchpadSettings.get_boolean('natural-scroll'))
delta = -delta;
break;
}

if(!delta == 0)
switch(SCROLL_ACTION) {
case "volume-controls":
Expand Down