Skip to content

Commit 0ec1c90

Browse files
committed
Ignore pixels scrolled by past the top or bottom
1 parent 6f7ea34 commit 0ec1c90

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kitty/mouse.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,12 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) {
600600
int s;
601601
bool is_high_resolution = flags & 1;
602602

603+
double pixels = screen->pending_scroll_pixels;
603604
if (is_high_resolution) {
604605
yoffset *= OPT(touch_scroll_multiplier);
605-
double pixels = screen->pending_scroll_pixels + yoffset;
606+
pixels += yoffset;
606607
s = (int)round(pixels) / (int)global_state.callback_os_window->fonts_data->cell_height;
607-
screen->pending_scroll_pixels = pixels - s * (int) global_state.callback_os_window->fonts_data->cell_height;
608+
pixels = pixels - s * (int) global_state.callback_os_window->fonts_data->cell_height;
608609
} else {
609610
if (screen->linebuf == screen->main_linebuf || !screen->modes.mouse_tracking_mode) {
610611
// Only use wheel_scroll_multiplier if we are scrolling kitty scrollback or in mouse
@@ -621,14 +622,15 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) {
621622
if (s == 0 && yoffset != 0) s = yoffset > 0 ? 1 : -1;
622623
}
623624
bool upwards = s > 0;
624-
int pixels = screen->pending_scroll_pixels;
625625
//printf("asdf %f\n", pixels);
626626
if (screen->linebuf == screen->main_linebuf) {
627627
screen_history_scroll(screen, abs(s), upwards);
628628
if (screen->scrolled_by == 0 && pixels < 0) pixels = 0;
629629
if (screen->scrolled_by == screen->historybuf->count && pixels > 0) pixels = 0;
630-
pixel_scroll(screen, pixels);
630+
screen->pending_scroll_pixels = pixels;
631+
pixel_scroll(screen, (int)pixels);
631632
} else {
633+
screen->pending_scroll_pixels = 0.0;
632634
pixel_scroll(screen, 0);
633635
if (screen->modes.mouse_tracking_mode) {
634636
int sz = encode_mouse_event(w, upwards ? GLFW_MOUSE_BUTTON_4 : GLFW_MOUSE_BUTTON_5, PRESS, 0);

0 commit comments

Comments
 (0)