From 5ea45919d7090a1fd3f77fe75eaddd97fd54f3bd Mon Sep 17 00:00:00 2001 From: 00jciv00 Date: Thu, 7 May 2026 15:11:33 -0400 Subject: [PATCH 1/2] config: add gtk-horizontal-tab-scroll option Add a boolean config option to enable/disable two-finger horizontal touchpad scrolling for switching tabs. Defaults to true to preserve existing behavior. When tab scrolling is disabled or the scroll source is not a touchpad, forward horizontal scroll events to the terminal so applications like neovim can handle them. Co-Authored-By: Claude Opus 4.6 --- src/apprt/gtk/class/surface.zig | 63 +++++++++++++++++++++------------ src/config/Config.zig | 6 ++++ 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/apprt/gtk/class/surface.zig b/src/apprt/gtk/class/surface.zig index 179c779d7..c101892de 100644 --- a/src/apprt/gtk/class/surface.zig +++ b/src/apprt/gtk/class/surface.zig @@ -2984,37 +2984,56 @@ pub const Surface = extern struct { ) callconv(.c) c_int { const priv: *Private = self.private(); - switch (ec.getUnit()) { - .surface => {}, - .wheel => return @intFromBool(false), - else => return @intFromBool(false), - } + // Check if horizontal tab scrolling is enabled and this is a + // touchpad surface scroll. If not, forward to the terminal. + const tab_scroll_enabled = if (priv.config) |config| + config.get().@"gtk-horizontal-tab-scroll" + else + true; - priv.pending_horizontal_scroll += x; + const is_surface_scroll = ec.getUnit() == .surface; + + if (tab_scroll_enabled and is_surface_scroll) { + priv.pending_horizontal_scroll += x; + + if (@abs(priv.pending_horizontal_scroll) < 120) { + if (priv.pending_horizontal_scroll_reset) |v| { + _ = glib.Source.remove(v); + priv.pending_horizontal_scroll_reset = null; + } + priv.pending_horizontal_scroll_reset = glib.timeoutAdd(500, ecMouseScrollHorizontalReset, self); + return @intFromBool(true); + } + + _ = self.as(gtk.Widget).activateAction( + if (priv.pending_horizontal_scroll < 0.0) + "tab.next-page" + else + "tab.previous-page", + null, + ); - if (@abs(priv.pending_horizontal_scroll) < 120) { if (priv.pending_horizontal_scroll_reset) |v| { _ = glib.Source.remove(v); priv.pending_horizontal_scroll_reset = null; } - priv.pending_horizontal_scroll_reset = glib.timeoutAdd(500, ecMouseScrollHorizontalReset, self); + + priv.pending_horizontal_scroll = 0.0; + return @intFromBool(true); } - _ = self.as(gtk.Widget).activateAction( - if (priv.pending_horizontal_scroll < 0.0) - "tab.next-page" - else - "tab.previous-page", - null, - ); - - if (priv.pending_horizontal_scroll_reset) |v| { - _ = glib.Source.remove(v); - priv.pending_horizontal_scroll_reset = null; - } - - priv.pending_horizontal_scroll = 0.0; + // Forward horizontal scroll to the terminal (e.g. for neovim). + const surface = priv.core_surface orelse return @intFromBool(false); + const scaled = self.scaledCoordinates(x, 0); + surface.scrollCallback( + scaled.x * -1, + 0, + .{}, + ) catch |err| { + log.warn("error in scroll callback err={}", .{err}); + return @intFromBool(false); + }; return @intFromBool(true); } diff --git a/src/config/Config.zig b/src/config/Config.zig index 5b1d73deb..f803ca12d 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -3649,6 +3649,12 @@ else /// which is the old style. @"gtk-wide-tabs": bool = true, +/// If `true` (default), then two-finger horizontal scrolling on a touchpad +/// will switch between tabs. Scrolling left goes to the next tab and +/// scrolling right goes to the previous tab. Set this to `false` to +/// disable this behavior. +@"gtk-horizontal-tab-scroll": bool = true, + /// Custom CSS files to be loaded. /// /// GTK CSS documentation can be found at the following links: From b5f5ca07892f4df799bcc4645f80e441640b5946 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 17 May 2026 21:12:51 -0500 Subject: [PATCH 2/2] Add "available since" --- src/config/Config.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config/Config.zig b/src/config/Config.zig index f803ca12d..cb1964010 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -3653,6 +3653,8 @@ else /// will switch between tabs. Scrolling left goes to the next tab and /// scrolling right goes to the previous tab. Set this to `false` to /// disable this behavior. +/// +/// Available since 1.4.0. @"gtk-horizontal-tab-scroll": bool = true, /// Custom CSS files to be loaded.