diff --git a/kitty/mouse.c b/kitty/mouse.c index c38348dc8..0e020df4d 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -795,6 +795,17 @@ scroll_event(double UNUSED xoffset, double yoffset, int flags, int modifiers) { if (t) w = t->windows + t->active_window; } if (!w) return; + // Also update mouse cursor position while kitty OS window is not focused. + // Allows scroll events to be delivered to the child with correct pointer co-ordinates even when + // the window is not focused on macOS + if (!osw->is_focused) { + unsigned int x = 0, y = 0; + bool in_left_half_of_cell; + if (cell_for_pos(w, &x, &y, &in_left_half_of_cell, osw)) { + w->mouse_pos.cell_x = x; w->mouse_pos.cell_y = y; + w->mouse_pos.in_left_half_of_cell = in_left_half_of_cell; + } + } Screen *screen = w->render_data.screen; enum MomentumData { NoMomentumData, MomentumPhaseBegan, MomentumPhaseStationary, MomentumPhaseActive, MomentumPhaseEnded, MomentumPhaseCancelled, MomentumPhaseMayBegin };