From 24414f6189c87520163825db1d7d7ebbe474c6ad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Mar 2026 05:25:06 +0000 Subject: [PATCH 1/2] Fix scrollbar hit region to account for window margin (issue #9756) Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/eb5869d6-9938-4ff3-87fb-34fe14694d6c Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> --- docs/changelog.rst | 2 ++ kitty/mouse.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 52010cbff..554a1af8c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -188,6 +188,8 @@ Detailed list of changes - Fix a spurious mouse button release event being sent when dragging out of an OS window causes focus loss +- Fix scrollbar hover/interaction not working when the scrollbar is drawn in the window margin area (:iss:`9756`) + 0.46.2 [2026-03-21] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/mouse.c b/kitty/mouse.c index a80375cd1..58da819aa 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -1012,6 +1012,18 @@ mouse_region(bool detect_borders, bool detect_title_bar) { } } } + // If no window was found via contains_mouse, check if the mouse is in any + // window's scrollbar hit area. The scrollbar may be drawn in the margin + // which is outside the area covered by contains_mouse. + if (!ans.window && OPT(scrollbar_interactive)) { + for (unsigned int i = 0; i < t->num_windows; i++) { + Window *win = t->windows + i; + if (!win->visible || !win->render_data.screen) continue; + if (get_scrollbar_hit_type(win, w->mouse_x, w->mouse_y) != SCROLLBAR_HIT_NONE) { + ans.window_idx = i; ans.window = win; break; + } + } + } } return ans; } From df79b8247f23eff0d519e0bf3b8b8dffe8b60682 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Mar 2026 05:48:50 +0000 Subject: [PATCH 2/2] Give hovered scrollbar precedence over window borders to prevent flickering Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/260f17ab-b8d3-4581-ae88-de6f6c011637 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> --- kitty/mouse.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/kitty/mouse.c b/kitty/mouse.c index 58da819aa..f7533a873 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -986,15 +986,32 @@ mouse_region(bool detect_borders, bool detect_title_bar) { window_id = closest_horiz->border_type < 0 ? -closest_horiz->border_type : closest_horiz->border_type; } if (ans.window_border) { - if (window_id) { - for (unsigned int i = 0; i < t->num_windows; i++) - if (t->windows[i].id == window_id) { - ans.window = t->windows + i; - ans.window_idx = i; + // If a hovered scrollbar overlaps this border region, the + // scrollbar takes precedence to avoid flickering when the + // expanded hover-width scrollbar straddles the border. + bool scrollbar_takes_precedence = false; + if (OPT(scrollbar_interactive)) { + for (unsigned int i = 0; i < t->num_windows; i++) { + Window *win = t->windows + i; + if (!win->visible || !win->render_data.screen) continue; + if (win->scrollbar.is_hovering && get_scrollbar_hit_type(win, w->mouse_x, w->mouse_y) != SCROLLBAR_HIT_NONE) { + scrollbar_takes_precedence = true; break; } + } } - return ans; + if (!scrollbar_takes_precedence) { + if (window_id) { + for (unsigned int i = 0; i < t->num_windows; i++) + if (t->windows[i].id == window_id) { + ans.window = t->windows + i; + ans.window_idx = i; + break; + } + } + return ans; + } + ans.window_border = 0; } } for (unsigned int i = 0; i < t->num_windows; i++) {