From c8fe2cf860b4ad3a3e82786c43a7c1a31e2f1027 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 03:02:28 +0000 Subject: [PATCH] A modal cover shows and absorbs from its first pass The cover's egui area had no size on its first show, so egui made that pass a hidden sizing pass: no scrim and no absorbed hits. The discard pass every container layer used to ask on its first show hid this; without it the opening frame published no cover, and a modal's drag strips over the title bar came a frame late. The cover area is seeded at its screen rect before its first pass, as container layers are. --- crates/ui-contract/src/runtime/egui/areas.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/areas.rs b/crates/ui-contract/src/runtime/egui/areas.rs index de412613f..0f8a761d9 100644 --- a/crates/ui-contract/src/runtime/egui/areas.rs +++ b/crates/ui-contract/src/runtime/egui/areas.rs @@ -254,6 +254,11 @@ pub(crate) struct CoverLayer { /// left unpainted and unabsorbed, and the four bands around it paint and absorb. pub(crate) fn show_cover_layer(ctx: &Context, cover: CoverLayer) { let CoverLayer { id, tier, screen, scrim, through, absorbs } = cover; + // A cover shows over its whole screen from its first pass: with no size egui would make that pass a hidden sizing + // pass, which paints no scrim and absorbs nothing. + if layer_rect(ctx, id).is_none() { + seed_area(ctx, layer_of(tier, id), screen.min, screen.size()); + } let covered: Vec = match through.map(|through| through.intersect(screen)).filter(|through| through.is_positive()) { Some(clear) => bands(screen, clear).into_iter().filter(|band| band.is_positive()).collect(), None => vec![screen], @@ -388,9 +393,8 @@ pub fn layer_order() -> LayerOrder { } } -/// Gives a container layer's area a size before its first pass, so egui runs no hidden sizing pass for it. That pass -/// shows no body, so nothing would be measured in it; the layer's first pass is a real one that records the sizes -/// the discard pass places by. +/// Gives a layer's area a size before its first pass, so egui runs no hidden sizing pass for it. That pass shows and +/// absorbs nothing, so nothing would be measured in it; the layer's first pass is a real one. pub(crate) fn seed_area(ctx: &Context, layer: LayerId, at: Pos2, room: Vec2) { let state = egui::AreaState { pivot_pos: Some(at), pivot: egui::Align2::LEFT_TOP, size: Some(room), interactable: false, last_became_visible_at: None };