diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 8037132640..e9cd02620f 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -2495,6 +2495,7 @@ impl CollabPanel { h_flex() .absolute() .right(rems(0.)) + .z_index(1) .h_full() .child( h_flex() diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rs index 47f2809038..d171cada4e 100644 --- a/crates/gpui/src/view.rs +++ b/crates/gpui/src/view.rs @@ -328,7 +328,13 @@ impl Element for AnyView { element.draw(bounds.origin, bounds.size.into(), cx); } - state.next_stacking_order_id = cx.window.next_frame.next_stacking_order_id; + state.next_stacking_order_id = cx + .window + .next_frame + .next_stacking_order_ids + .last() + .copied() + .unwrap(); state.cache_key = Some(ViewCacheKey { bounds, stacking_order: cx.stacking_order().clone(), diff --git a/crates/gpui/src/window/element_cx.rs b/crates/gpui/src/window/element_cx.rs index 145597b039..c7814fc101 100644 --- a/crates/gpui/src/window/element_cx.rs +++ b/crates/gpui/src/window/element_cx.rs @@ -59,7 +59,7 @@ pub(crate) struct Frame { pub(crate) scene: Scene, pub(crate) depth_map: Vec<(StackingOrder, EntityId, Bounds)>, pub(crate) z_index_stack: StackingOrder, - pub(crate) next_stacking_order_id: u16, + pub(crate) next_stacking_order_ids: Vec, pub(crate) next_root_z_index: u16, pub(crate) content_mask_stack: Vec>, pub(crate) element_offset_stack: Vec>, @@ -85,7 +85,7 @@ impl Frame { scene: Scene::default(), depth_map: Vec::new(), z_index_stack: StackingOrder::default(), - next_stacking_order_id: 0, + next_stacking_order_ids: vec![0], next_root_z_index: 0, content_mask_stack: Vec::new(), element_offset_stack: Vec::new(), @@ -106,7 +106,7 @@ impl Frame { self.mouse_listeners.values_mut().for_each(Vec::clear); self.dispatch_tree.clear(); self.depth_map.clear(); - self.next_stacking_order_id = 0; + self.next_stacking_order_ids = vec![0]; self.next_root_z_index = 0; self.reused_views.clear(); self.scene.clear(); @@ -351,8 +351,22 @@ impl<'a> ElementContext<'a> { } } - debug_assert!(next_stacking_order_id >= self.window.next_frame.next_stacking_order_id); - self.window.next_frame.next_stacking_order_id = next_stacking_order_id; + debug_assert!( + next_stacking_order_id + >= self + .window + .next_frame + .next_stacking_order_ids + .last() + .copied() + .unwrap() + ); + *self + .window + .next_frame + .next_stacking_order_ids + .last_mut() + .unwrap() = next_stacking_order_id; } /// Push a text style onto the stack, and call a function with that style active. @@ -434,8 +448,13 @@ impl<'a> ElementContext<'a> { }; let new_root_z_index = post_inc(&mut self.window_mut().next_frame.next_root_z_index); - let new_stacking_order_id = - post_inc(&mut self.window_mut().next_frame.next_stacking_order_id); + let new_stacking_order_id = post_inc( + self.window_mut() + .next_frame + .next_stacking_order_ids + .last_mut() + .unwrap(), + ); let new_context = StackingContext { z_index: new_root_z_index, id: new_stacking_order_id, @@ -455,8 +474,14 @@ impl<'a> ElementContext<'a> { /// Called during painting to invoke the given closure in a new stacking context. The given /// z-index is interpreted relative to the previous call to `stack`. pub fn with_z_index(&mut self, z_index: u16, f: impl FnOnce(&mut Self) -> R) -> R { - let new_stacking_order_id = - post_inc(&mut self.window_mut().next_frame.next_stacking_order_id); + let new_stacking_order_id = post_inc( + self.window_mut() + .next_frame + .next_stacking_order_ids + .last_mut() + .unwrap(), + ); + self.window_mut().next_frame.next_stacking_order_ids.push(0); let new_context = StackingContext { z_index, id: new_stacking_order_id, @@ -466,6 +491,8 @@ impl<'a> ElementContext<'a> { let result = f(self); self.window_mut().next_frame.z_index_stack.pop(); + self.window_mut().next_frame.next_stacking_order_ids.pop(); + result }