mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
Use the precision calculation to determine when to send mouse events
This commit is contained in:
@ -1337,6 +1337,7 @@ pub fn scrollCallback(
|
|||||||
self.mouse.pending_scroll_y = poff - (amount * cell_size);
|
self.mouse.pending_scroll_y = poff - (amount * cell_size);
|
||||||
|
|
||||||
break :y .{
|
break :y .{
|
||||||
|
.sign = if (yoff > 0) 1 else -1,
|
||||||
.delta_unsigned = @intFromFloat(@fabs(amount)),
|
.delta_unsigned = @intFromFloat(@fabs(amount)),
|
||||||
.delta = @intFromFloat(amount),
|
.delta = @intFromFloat(amount),
|
||||||
};
|
};
|
||||||
@ -1420,13 +1421,13 @@ pub fn scrollCallback(
|
|||||||
|
|
||||||
// If we're scrolling up or down, then send a mouse event. This requires
|
// If we're scrolling up or down, then send a mouse event. This requires
|
||||||
// a lock since we read terminal state.
|
// a lock since we read terminal state.
|
||||||
if (yoff != 0) {
|
if (y.delta != 0) {
|
||||||
const pos = try self.rt_surface.getCursorPos();
|
const pos = try self.rt_surface.getCursorPos();
|
||||||
try self.mouseReport(if (yoff < 0) .five else .four, .press, self.mouse.mods, pos);
|
try self.mouseReport(if (y.sign < 0) .five else .four, .press, self.mouse.mods, pos);
|
||||||
}
|
}
|
||||||
if (xoff != 0) {
|
if (x.delta != 0) {
|
||||||
const pos = try self.rt_surface.getCursorPos();
|
const pos = try self.rt_surface.getCursorPos();
|
||||||
try self.mouseReport(if (xoff > 0) .six else .seven, .press, self.mouse.mods, pos);
|
try self.mouseReport(if (x.delta > 0) .six else .seven, .press, self.mouse.mods, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user