core: do not scroll viewport if mouse reporting is requested

Fixes #570
This commit is contained in:
Mitchell Hashimoto 2023-09-28 09:50:44 -07:00
parent c987ce785b
commit 28b7782bbe
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC

View File

@ -1150,19 +1150,25 @@ pub fn scrollCallback(
// or have alternate scroll disabled. In this case, we just run
// the normal logic.
// If we're scrolling up or down, then send a mouse event.
if (self.io.terminal.flags.mouse_event != .none) {
if (y.delta != 0) {
const pos = try self.rt_surface.getCursorPos();
try self.mouseReport(if (y.delta < 0) .four else .five, .press, self.mouse.mods, pos);
}
if (x.delta != 0) {
const pos = try self.rt_surface.getCursorPos();
try self.mouseReport(if (x.delta > 0) .six else .seven, .press, self.mouse.mods, pos);
}
// If mouse reporting is on, we do not want to scroll the
// viewport.
return;
}
// Modify our viewport, this requires a lock since it affects rendering
try self.io.terminal.scrollViewport(.{ .delta = y.delta });
// If we're scrolling up or down, then send a mouse event. This requires
// a lock since we read terminal state.
if (y.delta != 0) {
const pos = try self.rt_surface.getCursorPos();
try self.mouseReport(if (y.delta < 0) .four else .five, .press, self.mouse.mods, pos);
}
if (x.delta != 0) {
const pos = try self.rt_surface.getCursorPos();
try self.mouseReport(if (x.delta > 0) .six else .seven, .press, self.mouse.mods, pos);
}
}
try self.queueRender();