changeset 2117:3f74e4d60ac1

Layout::moveToWidget(): send crossing events considering border cases i.e. when the source or target widget is NULL (This patch doesn't fix a *known* bug ATM, but it could be doing it, or may avoid one in the future).
author Jorge Arellano Cid <jcid@dillo.org>
date Fr, 08 Jul 2011 11:56:44 -0400
parents ba36a5bcf8c8
children 0b39c3255490
files dw/layout.cc
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dw/layout.cc	Fr Jul 08 11:56:42 2011 -0400
+++ b/dw/layout.cc	Fr Jul 08 11:56:44 2011 -0400
@@ -850,9 +850,10 @@
 {
    Widget *ancestor, *w;
    Widget **track;
-   int trackLen, i;
+   int trackLen, i, i_a;
    EventCrossing crossingEvent;
 
+   _MSG("moveToWidget: wap=%p nwap=%p\n",widgetAtPoint,newWidgetAtPoint);
    if (newWidgetAtPoint != widgetAtPoint) {
       // The mouse pointer has been moved into another widget.
       if (newWidgetAtPoint && widgetAtPoint)
@@ -881,6 +882,7 @@
          /* first part */
          for (w = widgetAtPoint; w != ancestor; w = w->getParent ())
             track[i++] = w;
+      i_a = i;
       track[i++] = ancestor;
       if (newWidgetAtPoint) {
          /* second part */
@@ -889,16 +891,21 @@
             track[i--] = w;
       }
 
-      /* Send events to all events on the track */
+      /* Send events to the widgets on the track */
       for (i = 0; i < trackLen; i++) {
          crossingEvent.state = state;
          crossingEvent.currentWidget = widgetAtPoint; // ???
          crossingEvent.lastWidget = widgetAtPoint; // ???
-
-         if (i != 0)
+         if (i < i_a) {
+            track[i]->leaveNotify (&crossingEvent);
+         } else if (i == i_a) { /* ancestor */
+            if (!widgetAtPoint)
+               track[i]->enterNotify (&crossingEvent);
+            else if (!newWidgetAtPoint)
+               track[i]->leaveNotify (&crossingEvent);
+         } else {
             track[i]->enterNotify (&crossingEvent);
-         if (i != trackLen - 1)
-            track[i]->leaveNotify (&crossingEvent);
+         }
       }
 
       delete[] track;