apprt: plumb through scroll mods to core, don't handle them yet

This commit is contained in:
Mitchell Hashimoto
2023-06-29 10:41:42 -07:00
parent 20f46d5c08
commit 68631a1ccd
4 changed files with 29 additions and 7 deletions

View File

@ -1268,7 +1268,14 @@ pub fn refreshCallback(self: *Surface) !void {
try self.queueRender(); try self.queueRender();
} }
pub fn scrollCallback(self: *Surface, xoff: f64, yoff: f64) !void { pub fn scrollCallback(
self: *Surface,
xoff: f64,
yoff: f64,
scroll_mods: input.ScrollMods,
) !void {
_ = scroll_mods;
const tracy = trace(@src()); const tracy = trace(@src());
defer tracy.end(); defer tracy.end();

View File

@ -299,8 +299,13 @@ pub const Surface = struct {
}; };
} }
pub fn scrollCallback(self: *Surface, xoff: f64, yoff: f64) void { pub fn scrollCallback(
self.core_surface.scrollCallback(xoff, yoff) catch |err| { self: *Surface,
xoff: f64,
yoff: f64,
mods: input.ScrollMods,
) void {
self.core_surface.scrollCallback(xoff, yoff, mods) catch |err| {
log.err("error in scroll callback err={}", .{err}); log.err("error in scroll callback err={}", .{err});
return; return;
}; };
@ -508,8 +513,11 @@ pub const CAPI = struct {
y: f64, y: f64,
scroll_mods: c_int, scroll_mods: c_int,
) void { ) void {
_ = scroll_mods; surface.scrollCallback(
surface.scrollCallback(x, y); x,
y,
@bitCast(input.ScrollMods, @truncate(u8, @bitCast(c_uint, scroll_mods))),
);
} }
export fn ghostty_surface_ime_point(surface: *Surface, x: *f64, y: *f64) void { export fn ghostty_surface_ime_point(surface: *Surface, x: *f64, y: *f64) void {

View File

@ -731,8 +731,11 @@ pub const Surface = struct {
const tracy = trace(@src()); const tracy = trace(@src());
defer tracy.end(); defer tracy.end();
// Glfw doesn't support any of the scroll mods.
const scroll_mods: input.ScrollMods = .{};
const core_win = window.getUserPointer(CoreSurface) orelse return; const core_win = window.getUserPointer(CoreSurface) orelse return;
core_win.scrollCallback(xoff, yoff) catch |err| { core_win.scrollCallback(xoff, yoff, scroll_mods) catch |err| {
log.err("error in scroll callback err={}", .{err}); log.err("error in scroll callback err={}", .{err});
return; return;
}; };

View File

@ -1049,7 +1049,11 @@ pub const Surface = struct {
ud: ?*anyopaque, ud: ?*anyopaque,
) callconv(.C) void { ) callconv(.C) void {
const self = userdataSelf(ud.?); const self = userdataSelf(ud.?);
self.core_surface.scrollCallback(x, y * -1) catch |err| {
// GTK doesn't support any of the scroll mods.
const scroll_mods: input.ScrollMods = .{};
self.core_surface.scrollCallback(x, y * -1, scroll_mods) catch |err| {
log.err("error in scroll callback err={}", .{err}); log.err("error in scroll callback err={}", .{err});
return; return;
}; };