diff --git a/docs/changelog.rst b/docs/changelog.rst index 60bbf531a..e2b3ecb6b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -31,6 +31,9 @@ Changelog - Fix using the ``new_tab !neighbor`` action changing the order of the non-neighboring tabs (:iss:`1256`) +- macOS: Fix momentum scrolling continuing when changing the active window/tab + (:iss:`1267`) + 0.13.1 [2018-12-06] ------------------------------ diff --git a/kitty/mouse.c b/kitty/mouse.c index e3cdc3599..54ea72a9e 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -557,6 +557,7 @@ mouse_event(int button, int modifiers, int action) { void scroll_event(double UNUSED xoffset, double yoffset, int flags) { bool in_tab_bar; + static id_type window_for_momentum_scroll = 0; unsigned int window_idx = 0; Window *w = window_for_event(&window_idx, &in_tab_bar); if (!w && !in_tab_bar) { @@ -571,6 +572,15 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags) { int s; bool is_high_resolution = flags & 1; Screen *screen = w->render_data.screen; + int momentum_data = (flags > 1) & 3; + switch(momentum_data) { + case 1: + window_for_momentum_scroll = w->id; break; + case 2: + if (window_for_momentum_scroll != w->id) return; + case 3: + window_for_momentum_scroll = 0; break; + } if (is_high_resolution) { yoffset *= OPT(touch_scroll_multiplier); if (yoffset * global_state.callback_os_window->pending_scroll_pixels < 0) {