From cc88bff1ff6d378429a61fa34bcd36caed05214e Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 5 Jul 2023 15:25:33 +0200 Subject: [PATCH] Fix click-through behaviour of git panel Co-authored-by: Antonio --- crates/gpui/src/app/window.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rs index 23fbb33fe1..a04aaf8a28 100644 --- a/crates/gpui/src/app/window.rs +++ b/crates/gpui/src/app/window.rs @@ -482,20 +482,19 @@ impl<'a> WindowContext<'a> { // If there is already clicked_button stored, don't replace it. if self.window.clicked_button.is_none() { - self.window.clicked_region_ids = self - .window - .mouse_regions - .iter() - .filter_map(|(region, _)| { - if region.bounds.contains_point(e.position) { - Some(region.id()) - } else { - None - } - }) - .collect(); + let window = &mut *self.window; + window.clicked_region_ids.clear(); - self.window.clicked_button = Some(e.button); + let mut highest_z_index = 0; + for (region, z_index) in window.mouse_regions.iter() { + if region.bounds.contains_point(e.position) && *z_index >= highest_z_index { + highest_z_index = *z_index; + window.clicked_region_ids.clear(); + window.clicked_region_ids.insert(region.id()); + } + } + + window.clicked_button = Some(e.button); } mouse_events.push(MouseEvent::Down(MouseDown {