gpui: the topmost window control wins the hit test (Windows caption buttons)

The title bar's drag area is painted before its buttons and was matched
first, so Windows saw a caption over minimize, maximize and close and
started a window drag on every click.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-11 00:30:21 -04:00
1 parent 48a66ca6c1
commit d6ddd3c3e1
2 files changed
+300 -296

No files matched your search

+9 -6
View File
@@ -1993,12 +1993,15 @@ impl Window {
Box::new(move || {
handle
.update(&mut cx, |_, window, _cx| {
for (area, hitbox) in &window.rendered_frame.window_control_hitboxes {
if window.mouse_hit_test.ids.contains(&hitbox.id) {
return Some(*area);
}
}
None
// Topmost first: a button wins over its bar.
let areas = &window.rendered_frame.window_control_hitboxes;
let hit = &window.mouse_hit_test;
hit.ids.iter().take(hit.hover_hitbox_count).find_map(|id| {
areas
.iter()
.find(|(_, hitbox)| hitbox.id == *id)
.map(|(area, _)| *area)
})
})
.log_err()
.unwrap_or(None)