Merge branch 'copilot/fix-scrollbar-margin-issue' of https://github.com/kovidgoyal/kitty

This commit is contained in:
Kovid Goyal 2026-03-27 11:36:57 +05:30
commit 99d986c821
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 37 additions and 6 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -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++) {
@ -1012,6 +1029,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;
}