Skip to content

Commit

Permalink
Rewrite Fl_Tooltip.cxx for the driver model.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11565 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Apr 9, 2016
1 parent fe624b8 commit 3bc5be7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions FL/Fl_System_Driver.H
Expand Up @@ -118,6 +118,10 @@ public:
virtual int need_menu_handle_part1_extra() {return 0;}
// implement to support fl_open_uri()
virtual int open_uri(const char *uri, char *msg, int msglen) {return 0;}
// the default implementation of use_tooltip_timeout_condition() may be enough
virtual int use_tooltip_timeout_condition() {return 0;}
// the default implementation of use_recent_tooltip_fix() may be enough
virtual int use_recent_tooltip_fix() {return 0;}
};

#endif // FL_SYSTEM_DRIVER_H
Expand Down
12 changes: 5 additions & 7 deletions src/Fl_Tooltip.cxx
Expand Up @@ -19,6 +19,8 @@
#include <FL/Fl_Tooltip.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Menu_Window.H>
#include <FL/Fl.H>
#include <FL/Fl_System_Driver.H>

#include <stdio.h>
#include <string.h> // strdup()
Expand Down Expand Up @@ -151,9 +153,8 @@ static void tooltip_timeout(void*) {
if (window) window->hide();
} else {
int condition = 1;
#if !(defined(__APPLE__) || defined(WIN32)) // bugfix: no need to refactor
condition = (Fl::grab() == NULL);
#endif
// bugfix: no need to refactor
if (Fl::system_driver()->use_tooltip_timeout_condition()) condition = (Fl::grab() == NULL);
if ( condition ) {
if (!window) window = new Fl_TooltipBox;
// this cast bypasses the normal Fl_Window label() code:
Expand Down Expand Up @@ -287,12 +288,9 @@ void Fl_Tooltip::enter_area(Fl_Widget* wid, int x,int y,int w,int h, const char*
if (recent_tooltip) {
if (window) window->hide();
Fl::add_timeout(Fl_Tooltip::hoverdelay(), tooltip_timeout);
} else if (Fl_Tooltip::delay() < .1) {
#ifdef WIN32
// possible fix for the Windows titlebar, it seems to want the
// window to be destroyed, moving it messes up the parenting:
if (window && window->visible()) window->hide();
#endif // WIN32
if (Fl::system_driver()->use_recent_tooltip_fix() && window && window->visible()) window->hide();
tooltip_timeout(0);
} else {
if (window && window->visible()) window->hide();
Expand Down
1 change: 1 addition & 0 deletions src/drivers/Posix/Fl_Posix_System_Driver.H
Expand Up @@ -72,6 +72,7 @@ public:
virtual int need_menu_handle_part2() {return 1;}
virtual int need_menu_handle_part1_extra() {return 1;}
virtual int open_uri(const char *uri, char *msg, int msglen);
virtual int use_tooltip_timeout_condition() {return 1;}
};

#endif // FL_POSIX_SYSTEM_DRIVER_H
Expand Down
1 change: 1 addition & 0 deletions src/drivers/WinAPI/Fl_WinAPI_System_Driver.H
Expand Up @@ -76,6 +76,7 @@ public:
virtual int filename_isdir_quick(const char* n);
virtual const char *filename_ext(const char *buf);
virtual int open_uri(const char *uri, char *msg, int msglen);
virtual int use_recent_tooltip_fix() {return 1;}
};

#endif // FL_WINAPI_SYSTEM_DRIVER_H
Expand Down

0 comments on commit 3bc5be7

Please sign in to comment.