From 5ae2406a035ab28c2c6dfedd1103cf33ecc418a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 18 Jul 2018 10:34:36 +0530 Subject: [PATCH] macOS: Allow scrolling window contents using mouse wheel/trackbar even when the window is not the active window Fixes #729 --- docs/changelog.rst | 3 +++ kitty/mouse.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index ba83b6c32..4b8503423 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,9 @@ Changelog - Add an option :opt:`env` to set environment variables in child processes from kitty.conf +- macOS: Allow scrolling window contents using mouse wheel/trackbar even when the + window is not the active window (:iss:`729`) + 0.11.3 [2018-07-10] ------------------------------ diff --git a/kitty/mouse.c b/kitty/mouse.c index e14a33d2a..4ebb562f1 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -501,6 +501,13 @@ scroll_event(double UNUSED xoffset, double yoffset) { bool in_tab_bar; unsigned int window_idx = 0; Window *w = window_for_event(&window_idx, &in_tab_bar); + if (!w && !in_tab_bar) { + // allow scroll events even if window is not currently focused (in + // which case on some platforms such as macOS the mouse location is zeroed so + // window_for_event() does not work). + Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab; + if (t) w = t->windows + t->active_window; + } if (w) { Screen *screen = w->render_data.screen; if (screen->linebuf == screen->main_linebuf) {