Skip to content

feat: add touchpad scroll speed settings slider#338

Open
PavelStoyan0v wants to merge 1 commit into
imputnet:mainfrom
PavelStoyan0v:feature-touchpad-scroll-speed
Open

feat: add touchpad scroll speed settings slider#338
PavelStoyan0v wants to merge 1 commit into
imputnet:mainfrom
PavelStoyan0v:feature-touchpad-scroll-speed

Conversation

@PavelStoyan0v

Copy link
Copy Markdown

For your pull request to not get closed without review, please confirm that:

  • An issue exists where the maintainers agreed that this should be implemented.
    Resolves [FR]: Customizable (Touchpad) Scroll Speed on Linux #307.
  • I tested that my contribution works locally, and does not break anything,
    otherwise I have marked my PR as draft.
  • If my contribution is non-trivial, I did not use AI to write most of it.
  • I understand that I will be permanently banned from interacting with this
    organization if I lied by checking any of these checkboxes.
  • The pull request contents are only relevant to the Linux platform, and can in
    no way be applied to other platforms.

This PR adds a "Touchpad scroll speed" settings slider (ranging from 5% to 300%, defaulting to 100%) in chrome://settings -> "Appearance and behavior".

Implementation:

  • Exposes a new double preference: helium.browser.touchpad_scroll_speed_multiplier.
  • Integrates a <settings-slider> in the settings WebUI.
  • Bridges the preference to the browser process via a delegate on ContentBrowserClient.
  • Intercepts and scales touchpad scroll events in Aura (RenderWidgetHostViewAura::OnScrollEvent).

Why this approach:

Scaling the resolved logical scroll delta inside Aura ensures that both main-thread and compositor-thread (smooth) touchpad scrolling are correctly adjusted. This avoids having to intercept events inside Blink's main thread (which bypasses smooth compositor scrolls) or low-level Ozone-Wayland event pollution (which risks breaking absolute hit-testing and pinch-to-zoom gestures).

Testing:

  • Verified compiling on host container.
  • Installed and tested locally on Ubuntu 26.04 LTS; the settings slider updates the scroll speed instantly on-the-fly.

(Note: I used an AI coding assistant to help generate the boilerplate C++/WebUI preference registrations, but verified and tested the changes manually).

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "feat: add touchpad scroll speed settings..." | Re-trigger Greptile

Comment on lines +163 to +169
+ if (event->type() == ui::EventType::kScroll) {
+ double multiplier = GetContentClient()->browser()->GetTouchpadScrollSpeedMultiplier(
+ host()->GetProcess()->GetBrowserContext());
+ if (multiplier != 1.0) {
+ event->Scale(static_cast<float>(multiplier));
+ }
+ }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 kScroll intercept is not limited to touchpad input

ui::EventType::kScroll covers both touchpad two-finger scroll events and, on Wayland, mouse wheel axis events (wl_pointer::axis). The Ozone/Wayland backend converts both sources to ui::ScrollEvent with type kScroll, so users with a physical mouse attached will find their wheel scroll speed scaled by this preference as well, contradicting the "Touchpad scroll speed" label. A finger_count() > 0 guard (which libinput/Ozone sets for genuine touchpad contact) would restrict scaling to touchpad input only.

Comment on lines +132 to +133
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 #include directives placed mid-file

chrome/common/pref_names.h and components/prefs/pref_service.h are inserted at source line 3723 of chrome_content_browser_client.cc, after the body of an existing function. Chromium's style guide and clang-format require all #include directives to appear at the top of the translation unit. Because this file heavily uses Profile and PrefService, these headers are almost certainly already present via transitive includes, but the mid-file placement will be flagged by Chrome's PRESUBMIT checks and is confusing to readers. They should be added in the file's existing include block at the top.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +164 to +165
+ double multiplier = GetContentClient()->browser()->GetTouchpadScrollSpeedMultiplier(
+ host()->GetProcess()->GetBrowserContext());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Pref lookup on every scroll event in a hot path

GetTouchpadScrollSpeedMultiplier is called on every single kScroll event, incurring two virtual dispatches (GetContentClient()->browser() and GetTouchpadScrollSpeedMultiplier()) plus a PrefService map lookup. While the pref lookup is O(1), touchpad scroll events fire continuously at the OS report rate (often 60–240 Hz). Caching the multiplier value (e.g. via a PrefChangeRegistrar observer on RenderWidgetHostViewAura or a process-level cache) would eliminate this overhead on the hot path.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR]: Customizable (Touchpad) Scroll Speed on Linux

1 participant