aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2011-07-27 10:06:39 -0400
committerJorge Arellano Cid <jcid@dillo.org>2011-07-27 10:06:39 -0400
commit6f2e86c52fbf90d5efaef55fc9757b23bb27a80f (patch)
tree2e16dd5cb8b5a798b961ad5680912becd291e2fa
parent2527eb3a43e4e433cacf8db65265b7195904891f (diff)
Layout::moveToWidget(): send crossing events (part 2)
This patch fixes 3f74e4d60ac1 (which is partly wrong). The idea is to avoid spurious leave/enter events, and thus prevent bugs. * avoid issuing spurious leave/enter events, and send the necessary ones. * remove the need for a workaround linkEnter() call in Textblock::leaveNotifyImpl().
-rw-r--r--dw/layout.cc15
-rw-r--r--dw/textblock.cc20
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;