git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit09f78600f13cd92d6c7475f32b83e66698d4c265
parent3c229db6cb
authorLucas Galante <[email protected]>
date2026-06-29 21:11
Implement Z-index sorting in propagate_event_impl and registry query fallback in is_coordinate_covered

 src/context.rs               | 20 +++++++++++++++++++-
 src/widget/input/dropdown.rs |  4 ++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/context.rs b/src/context.rs
index e17f520..d8c1bd8 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -259,7 +259,8 @@ impl UiContext {
             }
 
             let mut handled = false;
-            let children = (*root).children(self);
+            let mut children = (*root).children(self);
+            children.sort_by_key(|&child_ptr| (*child_ptr).z_index());
 
             // Determine if we should record a drag target candidate
             let mut check_drag_target = false;
@@ -623,6 +624,23 @@ impl UiContext {
                 }
             }
         }
+        for &ptr in self.widget_registry.values() {
+            let current_data = ptr as *const () as usize;
+            if query_address == current_data {
+                continue;
+            }
+            unsafe {
+                if let Some(w) = ptr.as_ref() {
+                    if w.visible() {
+                        if let Some((x, y, width, height)) = w.popover_rect() {
+                            if px >= x && px <= x + width && py >= y && py <= y + height {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
         false
     }
 
diff --git a/src/widget/input/dropdown.rs b/src/widget/input/dropdown.rs
index 1fc72c0..2441b19 100644
--- a/src/widget/input/dropdown.rs
+++ b/src/widget/input/dropdown.rs
@@ -396,6 +396,10 @@ impl Element for Dropdown {
         Dropdown::render_popover(self, pc);
     }
 
+    fn z_index(&self) -> i32 {
+        if self.open { 100 } else { 0 }
+    }
+
     fn layout_ignore(&self) -> bool {
         true
     }