summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-09-25 13:07:52 +0200
committerSebastian Geerken <devnull@localhost>2014-09-25 13:07:52 +0200
commita170867c7b7db49e0d52a51f7321b86348fa9ae7 (patch)
tree885b4493958383af1e6abcfaf14e035c479b8c53
parenta3486120edf86a0248f0162e5cae2ab7250c9848 (diff)
RTFL.
-rw-r--r--dw/textblock.cc80
1 files changed, 39 insertions, 41 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index e914c316..eb412b3d 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -2644,60 +2644,58 @@ void Textblock::breakAdded ()
*/
core::Widget *Textblock::getWidgetAtPoint (int x, int y)
{
- int lineIndex, wordIndex;
- Line *line;
+ DBG_OBJ_ENTER ("events", 0, "getWidgetAtPoint", "%d, %d", x, y);
+ Widget *childAtPoint = NULL;
if (x < allocation.x ||
y < allocation.y ||
x > allocation.x + allocation.width ||
y > allocation.y + getHeight ()) {
- return NULL;
- }
-
- // First, ...
- if (stackingContextMgr) {
- Widget *scmWidget = stackingContextMgr->getTopWidgetAtPoint (x, y);
- if (scmWidget)
- return scmWidget;
- }
+ DBG_OBJ_MSG ("events", 1, "outside allocation");
+ } else {
+ // First, ...
+ if (childAtPoint == NULL && stackingContextMgr)
+ childAtPoint = stackingContextMgr->getTopWidgetAtPoint (x, y);
- // Then, search for widgets out of flow, notably floats, since
- // there are cases where they overlap child textblocks.
- Widget *oofWidget = getWidgetOOFAtPoint (x, y);
- if (oofWidget)
- return oofWidget;
-
- lineIndex = findLineIndexWhenAllocated (y - allocation.y);
-
- if (lineIndex < 0 || lineIndex >= lines->size ()) {
- return this;
- }
-
- line = lines->getRef (lineIndex);
+ // Then, search for widgets out of flow, notably floats, since
+ // there are cases where they overlap child textblocks.
+ if (childAtPoint == NULL)
+ childAtPoint = getWidgetOOFAtPoint (x, y);
- for (wordIndex = line->firstWord; wordIndex <= line->lastWord;wordIndex++) {
- Word *word = words->getRef (wordIndex);
-
- if (word->content.type == core::Content::WIDGET_IN_FLOW) {
- core::Widget * childAtPoint;
- if (!core::StackingContextMgr::handledByStackingContextMgr
- (word->content.widget) &&
- word->content.widget->wasAllocated ()) {
- childAtPoint = word->content.widget->getWidgetAtPoint (x, y);
- if (childAtPoint) {
- return childAtPoint;
+ if (childAtPoint == NULL) {
+ int lineIndex = findLineIndexWhenAllocated (y - allocation.y);
+
+ if (lineIndex < 0 || lineIndex >= lines->size ())
+ childAtPoint = this;
+ else {
+ Line *line = lines->getRef (lineIndex);
+
+ for (int wordIndex = line->firstWord;
+ wordIndex <= line->lastWord && childAtPoint == NULL;
+ wordIndex++) {
+ Word *word = words->getRef (wordIndex);
+ if (word->content.type == core::Content::WIDGET_IN_FLOW) {
+ core::Widget * child = word->content.widget;
+ if (!core::StackingContextMgr::handledByStackingContextMgr
+ (child) &&
+ child->wasAllocated ()) {
+ childAtPoint = child->getWidgetAtPoint (x, y);
+ }
+ }
}
}
}
- }
- if (stackingContextMgr) {
- Widget *scmWidget = stackingContextMgr->getBottomWidgetAtPoint (x, y);
- if (scmWidget)
- return scmWidget;
+ if (childAtPoint == NULL && stackingContextMgr)
+ childAtPoint = stackingContextMgr->getBottomWidgetAtPoint (x, y);
+
+ if (childAtPoint == NULL)
+ childAtPoint = this;
}
- return this;
+ DBG_OBJ_MSGF ("events", 0, "=> %p", childAtPoint);
+ DBG_OBJ_LEAVE ();
+ return childAtPoint;
}