diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-16 23:28:05 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-07-16 23:29:28 +0300 |
| commit | 4a3302d19a2baa3a33e910e0088c24e780905b90 (patch) | |
| tree | dcaf76fae1c82102d933c9225b17ca7ac5d3a847 /vendor/libghostty-vt/src/apprt/gtk/class/surface.zig | |
| parent | 550e9f8cc085f428429f5cf2da0bb2dba897e8b8 (diff) | |
chore: update vendored libghostty-vt
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/apprt/gtk/class/surface.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/apprt/gtk/class/surface.zig | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/vendor/libghostty-vt/src/apprt/gtk/class/surface.zig b/vendor/libghostty-vt/src/apprt/gtk/class/surface.zig index 629866dc..54825ce0 100644 --- a/vendor/libghostty-vt/src/apprt/gtk/class/surface.zig +++ b/vendor/libghostty-vt/src/apprt/gtk/class/surface.zig @@ -3030,37 +3030,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; + + 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); + } - priv.pending_horizontal_scroll += x; + _ = 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); - return @intFromBool(true); - } - _ = self.as(gtk.Widget).activateAction( - if (priv.pending_horizontal_scroll < 0.0) - "tab.next-page" - else - "tab.previous-page", - null, - ); + priv.pending_horizontal_scroll = 0.0; - if (priv.pending_horizontal_scroll_reset) |v| { - _ = glib.Source.remove(v); - priv.pending_horizontal_scroll_reset = null; + return @intFromBool(true); } - 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); } |
