diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/layout.cc | 15 | ||||
-rw-r--r-- | dw/textblock.cc | 20 |
2 files changed, 27 insertions, 8 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index e6aebc62..cf19df37 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -844,7 +844,7 @@ Widget *Layout::getWidgetAtPoint (int x, int y) /* * Emit the necessary crossing events, when the mouse pointer has moved to - * the given widget. + * the given widget (by mouse or scrolling). */ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) { @@ -890,6 +890,12 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) for (w = newWidgetAtPoint; w != ancestor; w = w->getParent ()) track[i--] = w; } +#if 0 + MSG("Track: %s[ ", widgetAtPoint ? "" : "nil "); + for (i = 0; i < trackLen; i++) + MSG("%s%p ", i == i_a ? ">" : "", track[i]); + MSG("] %s\n", newWidgetAtPoint ? "" : "nil"); +#endif /* Send events to the widgets on the track */ for (i = 0; i < trackLen; i++) { @@ -899,10 +905,11 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) if (i < i_a) { track[i]->leaveNotify (&crossingEvent); } else if (i == i_a) { /* ancestor */ - if (!widgetAtPoint) - track[i]->enterNotify (&crossingEvent); - else if (!newWidgetAtPoint) + /* don't touch ancestor unless moving into/from NULL */ + if (i_a == trackLen-1 && !newWidgetAtPoint) track[i]->leaveNotify (&crossingEvent); + else if (i_a == 0 && !widgetAtPoint) + track[i]->enterNotify (&crossingEvent); } else { track[i]->enterNotify (&crossingEvent); } diff --git a/dw/textblock.cc b/dw/textblock.cc index 045ab729..e1689ea5 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -536,6 +536,11 @@ bool Textblock::buttonReleaseImpl (core::EventButton *event) return sendSelectionEvent (core::SelectionState::BUTTON_RELEASE, event); } +/* + * Handle motion inside the widget + * (special care is necessary when switching from another widget, + * because hoverLink and hoverTooltip are meaningless then). + */ bool Textblock::motionNotifyImpl (core::EventMotion *event) { if (event->state & core::BUTTON1_MASK) @@ -557,6 +562,7 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) hoverLink = style->x_link; hoverTooltip = style->x_tooltip; } + // Show/hide tooltip if (tooltipOld != hoverTooltip) { if (tooltipOld) @@ -566,21 +572,27 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) } else if (hoverTooltip) hoverTooltip->onMotion (); - if (hoverLink != linkOld) + _MSG("tb=%p word=%p linkOld=%d hoverLink=%d\n", + this, word, linkOld, hoverLink); + if (hoverLink != linkOld) { + /* LinkEnter with hoverLink == -1 is the same as LinkLeave */ return layout->emitLinkEnter (this, hoverLink, -1, -1, -1); - else + } else { return hoverLink != -1; + } } } void Textblock::enterNotifyImpl (core::EventCrossing *event) { + _MSG(" tb=%p, ENTER NotifyImpl\n", this); + /* reset hoverLink so linkEnter is detected */ + hoverLink = -2; } void Textblock::leaveNotifyImpl (core::EventCrossing *event) { - hoverLink = -1; - (void) layout->emitLinkEnter (this, hoverLink, -1, -1, -1); + _MSG(" tb=%p, LEAVE NotifyImpl\n", this); if (hoverTooltip) { hoverTooltip->onLeave(); hoverTooltip = NULL; |