summaryrefslogtreecommitdiff
path: root/dw/stackingcontextmgr.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-09-25 11:39:53 +0200
committerSebastian Geerken <devnull@localhost>2014-09-25 11:39:53 +0200
commita3486120edf86a0248f0162e5cae2ab7250c9848 (patch)
tree98a079b7125debaf44e62111ac64668f2e05c8a7 /dw/stackingcontextmgr.cc
parentbcebc40e56a88fac5fbdd4cc04d74d53ac6ec3ff (diff)
Some work on mouse events (getWidgetAtPoint).
Diffstat (limited to 'dw/stackingcontextmgr.cc')
-rw-r--r--dw/stackingcontextmgr.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/dw/stackingcontextmgr.cc b/dw/stackingcontextmgr.cc
index b3573a3f..e57c73f0 100644
--- a/dw/stackingcontextmgr.cc
+++ b/dw/stackingcontextmgr.cc
@@ -101,6 +101,53 @@ void StackingContextMgr::draw (View *view, Rectangle *area, int startZIndex,
DBG_OBJ_LEAVE ();
}
+Widget *StackingContextMgr::getTopWidgetAtPoint (int x, int y)
+{
+ DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointTop", "%d, %d", x, y);
+ Widget *widget = getWidgetAtPoint (x, y, 0, INT_MAX);
+ DBG_OBJ_MSGF ("events", 0, "=> %p", widget);
+ DBG_OBJ_LEAVE ();
+ return widget;
+}
+
+Widget *StackingContextMgr::getBottomWidgetAtPoint (int x, int y)
+{
+ DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointBottom", "%d, %d", x, y);
+ Widget *widget = getWidgetAtPoint (x, y, INT_MIN, -1);
+ DBG_OBJ_MSGF ("events", 0, "=> %p", widget);
+ DBG_OBJ_LEAVE ();
+ return widget;
+}
+
+Widget *StackingContextMgr::getWidgetAtPoint (int x, int y, int startZIndex,
+ int endZIndex)
+{
+ DBG_OBJ_ENTER ("events", 0, "getWidgetAtPointBottom", "%d, %d", x, y);
+
+ Widget *widgetAtPoint = NULL;
+
+ for (int zIndex = min (maxZIndex, endZIndex);
+ zIndex >= max (minZIndex, startZIndex) && widgetAtPoint == NULL;
+ zIndex--) {
+ DBG_OBJ_MSGF ("events", 1, "searching zIndex = %d", zIndex);
+ DBG_OBJ_MSG_START ();
+
+ for (int i = 0; i < scWidgets->size () && widgetAtPoint == NULL; i++) {
+ Widget *child = scWidgets->get (i);
+ DBG_OBJ_MSGF ("events", 2, "widget %p has zIndex = %d",
+ child, child->getStyle()->zIndex);
+ if (child->getStyle()->zIndex == zIndex && child->wasAllocated ())
+ widgetAtPoint = scWidgets->get(i)->getWidgetAtPoint (x, y);
+ }
+
+ DBG_OBJ_MSG_END ();
+ }
+
+ DBG_OBJ_MSGF ("events", 0, "=> %p", widgetAtPoint);
+ DBG_OBJ_LEAVE ();
+ return widgetAtPoint;
+}
+
} // namespace core