1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

GWidget: Make hit testing respect child z-order.

This was as simple as iterating the children in reverse order. Duh. :^)
This commit is contained in:
Andreas Kling 2019-04-10 02:08:32 +02:00
parent b8f150457e
commit 9311164439

View file

@ -282,11 +282,10 @@ Rect GWidget::screen_relative_rect() const
GWidget::HitTestResult GWidget::hit_test(int x, int y) GWidget::HitTestResult GWidget::hit_test(int x, int y)
{ {
// FIXME: Care about z-order. for (int i = children().size() - 1; i >= 0; --i) {
for (auto* ch : children()) { if (!children()[i]->is_widget())
if (!ch->is_widget())
continue; continue;
auto& child = *(GWidget*)ch; auto& child = *(GWidget*)children()[i];
if (!child.is_visible()) if (!child.is_visible())
continue; continue;
if (child.relative_rect().contains(x, y)) if (child.relative_rect().contains(x, y))