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
Notes: sideshowbarker 2024-07-19 14:46:59 +09:00

View file

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