summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Tooltip.cxx31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/Fl_Tooltip.cxx b/src/Fl_Tooltip.cxx
index b05e036f0..5d572ac72 100644
--- a/src/Fl_Tooltip.cxx
+++ b/src/Fl_Tooltip.cxx
@@ -26,6 +26,7 @@
#include <string.h> // strdup()
float Fl_Tooltip::delay_ = 1.0f;
+float Fl_Tooltip::hidedelay_ = 12.0f;
float Fl_Tooltip::hoverdelay_ = 0.2f;
Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
FL_NUM_GREEN - 1,
@@ -40,6 +41,8 @@ const int Fl_Tooltip::draw_symbols_ = 1;
static const char* tip;
+static void tooltip_hide_timeout(void*);
+
/**
This widget creates a tooltip box window, with no caption.
*/
@@ -63,6 +66,7 @@ public:
int handle(int e) {
if (e == FL_PUSH || e == FL_KEYDOWN) {
hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
return 1;
}
return Fl_Menu_Window::handle(e);
@@ -139,6 +143,11 @@ static int top_win_iconified_() {
return !topwin->visible() ? 1 : 0;
}
+static void tooltip_hide_timeout(void*) {
+ if (window) window->hide();
+ recent_tooltip = 0;
+}
+
static void tooltip_timeout(void*) {
#ifdef DEBUG
puts("tooltip_timeout();");
@@ -149,6 +158,7 @@ static void tooltip_timeout(void*) {
if (!top_win_iconified_()) { // no tooltip if top win iconified (STR #3157)
if (!tip || !*tip) {
if (window) window->hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
} else {
int condition = 1;
// bugfix: no need to refactor
@@ -162,6 +172,7 @@ static void tooltip_timeout(void*) {
// printf("tooltip_timeout: Showing window %p with tooltip \"%s\"...\n",
// window, tip ? tip : "(null)");
window->show();
+ Fl::add_timeout(Fl_Tooltip::hidedelay(), tooltip_hide_timeout);
}
}
}
@@ -238,7 +249,10 @@ void Fl_Tooltip::exit_(Fl_Widget *w) {
widget_ = 0;
Fl::remove_timeout(tooltip_timeout);
Fl::remove_timeout(recent_timeout);
- if (window && window->visible()) window->hide();
+ if (window && window->visible()) {
+ window->hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
+ }
if (recent_tooltip) {
if (Fl::event_state() & FL_BUTTONS) recent_tooltip = 0;
else Fl::add_timeout(Fl_Tooltip::hoverdelay(), recent_timeout);
@@ -284,14 +298,23 @@ void Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char*
widget_ = wid; currentTooltipY = y; currentTooltipH = h; tip = t;
// popup the tooltip immediately if it was recently up:
if (recent_tooltip) {
- if (window) window->hide();
+ if (window) {
+ window->hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
+ }
Fl::add_timeout(Fl_Tooltip::hoverdelay(), tooltip_timeout);
// possible fix for the Windows titlebar, it seems to want the
// window to be destroyed, moving it messes up the parenting:
- if (Fl::system_driver()->use_recent_tooltip_fix() && window && window->visible()) window->hide();
+ if (Fl::system_driver()->use_recent_tooltip_fix() && window && window->visible()) {
+ window->hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
+ }
tooltip_timeout(0);
} else {
- if (window && window->visible()) window->hide();
+ if (window && window->visible()) {
+ window->hide();
+ Fl::remove_timeout(tooltip_hide_timeout);
+ }
Fl::add_timeout(Fl_Tooltip::delay(), tooltip_timeout);
}