summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-10 02:08:32 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-10 02:08:32 +0200
commit931116443984f7dc606af828651cec59cb8086b5 (patch)
tree7710ddbd9e2423388140d07cf0da04253ef9748f
parentb8f150457e803c624e85d336cfcd22efc1581e09 (diff)
downloadserenity-931116443984f7dc606af828651cec59cb8086b5.zip
GWidget: Make hit testing respect child z-order.
This was as simple as iterating the children in reverse order. Duh. :^)
-rw-r--r--LibGUI/GWidget.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp
index b02bf059f2..b8c52cd6b9 100644
--- a/LibGUI/GWidget.cpp
+++ b/LibGUI/GWidget.cpp
@@ -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))