diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2011-08-11 16:10:33 -0400 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2011-08-11 16:10:33 -0400 |
commit | 6c678ca4b67ec5991e75e3de176c4c7ff89968d4 (patch) | |
tree | cbe10a1c64f4a658f9e9aff59231944e7e35dc20 | |
parent | 422c01e42e09209d26b0baa1820a8b36bbdccbd6 (diff) |
crossing-events-part5: fix hoverTooltip accuracy for a corner case
This is not a bug in the event dispatcher but a problem with "hoverTooltip",
which doesn't hold accurate data in some cases. Making it static solves
the problem.
-rw-r--r-- | dw/textblock.cc | 24 | ||||
-rw-r--r-- | dw/textblock.hh | 4 |
2 files changed, 18 insertions, 10 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc index 312cb238..d2207b82 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -26,6 +26,15 @@ #include <stdio.h> #include <limits.h> +/* + * Local variables + */ + /* The tooltip under mouse pointer in current textblock. No ref. hold. + * (having one per view looks not worth the extra clutter). */ +static dw::core::style::Tooltip *hoverTooltip = NULL; + + + using namespace lout; namespace dw { @@ -80,8 +89,6 @@ Textblock::Textblock (bool limitTextWidth) availAscent = 100; availDescent = 0; - hoverTooltip = NULL; - this->limitTextWidth = limitTextWidth; for (int layer = 0; layer < core::HIGHLIGHT_NUM_LAYERS; layer++) { @@ -95,7 +102,10 @@ Textblock::Textblock (bool limitTextWidth) Textblock::~Textblock () { - //_MSG ("Textblock::~Textblock\n"); + _MSG("Textblock::~Textblock\n"); + + /* make sure not to call a free'd tooltip (very fast overkill) */ + hoverTooltip = NULL; for (int i = 0; i < words->size(); i++) { Word *word = words->getRef (i); @@ -572,8 +582,8 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) } else if (hoverTooltip) hoverTooltip->onMotion (); - _MSG("MN tb=%p word=%p linkOld=%d hoverLink=%d\n", - this, word, linkOld, hoverLink); + _MSG("MN tb=%p tooltipOld=%p hoverTooltip=%p\n", + this, tooltipOld, hoverTooltip); if (hoverLink != linkOld) { /* LinkEnter with hoverLink == -1 is the same as LinkLeave */ return layout->emitLinkEnter (this, hoverLink, -1, -1, -1); @@ -585,14 +595,14 @@ bool Textblock::motionNotifyImpl (core::EventMotion *event) void Textblock::enterNotifyImpl (core::EventCrossing *event) { - _MSG(" tb=%p, ENTER NotifyImpl\n", this); + _MSG(" tb=%p, ENTER NotifyImpl hoverTooltip=%p\n", this, hoverTooltip); /* reset hoverLink so linkEnter is detected */ hoverLink = -2; } void Textblock::leaveNotifyImpl (core::EventCrossing *event) { - _MSG(" tb=%p, LEAVE NotifyImpl: hoverLink=%d\n", this, hoverLink); + _MSG(" tb=%p, LEAVE NotifyImpl: hoverTooltip=%p\n", this, hoverTooltip); /* leaving the viewport can't be handled by motionNotifyImpl() */ if (hoverLink >= 0) diff --git a/dw/textblock.hh b/dw/textblock.hh index d05c87e2..96cb40e5 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -251,9 +251,7 @@ protected: struct {int index, nChar;} hlStart[core::HIGHLIGHT_NUM_LAYERS], hlEnd[core::HIGHLIGHT_NUM_LAYERS]; - int hoverLink; /* The link under the button. */ - core::style::Tooltip *hoverTooltip; /* The tooltip under the button. No ref - * hold. */ + int hoverLink; /* The link under the mouse pointer */ void queueDrawRange (int index1, int index2); |