Skip to content

Commit

Permalink
Fix STR #2462.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7935 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Dec 1, 2010
1 parent 2f8b7e4 commit 17963c0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
4 changes: 4 additions & 0 deletions FL/Fl_Tooltip.H
Expand Up @@ -83,6 +83,10 @@ public:
static Fl_Color textcolor() { return textcolor_; }
/** Sets the color of the text in the tooltip. The default is black. */
static void textcolor(Fl_Color c) { textcolor_ = c; }
#ifdef __APPLE__
// the unique tooltip window
static Fl_Window* current_window(void);
#endif

// These should not be public, but Fl_Widget::tooltip() needs them...
// fabien: made it private with only a friend function access
Expand Down
22 changes: 19 additions & 3 deletions src/Fl.cxx
Expand Up @@ -1042,9 +1042,25 @@ int Fl::handle(int e, Fl_Window* window)
}
if (modal() && wi != modal()) wi = 0;
if (grab()) wi = grab();
{Fl_Widget* pbm = belowmouse();
int ret = (wi && send(e, wi, window));
if (pbm != belowmouse()) {
{ int ret;
Fl_Widget* pbm = belowmouse();
#ifdef __APPLE__
if (fl_mac_os_version < 0x1050) {
// before 10.5, mouse moved events aren't sent to borderless windows such as tooltips
Fl_Window *tooltip = Fl_Tooltip::current_window();
int inside = 0;
if (tooltip && tooltip->shown() ) { // check if a tooltip window is currently opened
// check if mouse is inside the tooltip
inside = (Fl::event_x_root() >= tooltip->x() && Fl::event_x_root() < tooltip->x() + tooltip->w() &&
Fl::event_y_root() >= tooltip->y() && Fl::event_y_root() < tooltip->y() + tooltip->h() );
}
// if inside, send event to tooltip window instead of background window
if (inside) ret = send(e, tooltip, window);
else ret = (wi && send(e, wi, window));
} else
#endif
ret = (wi && send(e, wi, window));
if (pbm != belowmouse()) {
#ifdef DEBUG
printf("Fl::handle(e=%d, window=%p);\n", e, window);
#endif // DEBUG
Expand Down
8 changes: 8 additions & 0 deletions src/Fl_Tooltip.cxx
Expand Up @@ -67,6 +67,14 @@ Fl_Widget* Fl_Tooltip::widget_ = 0;
static Fl_TooltipBox *window = 0;
static int Y,H;

#ifdef __APPLE__
// returns the unique tooltip window
Fl_Window *Fl_Tooltip::current_window(void)
{
return (Fl_Window*)window;
}
#endif

void Fl_TooltipBox::layout() {
fl_font(Fl_Tooltip::font(), Fl_Tooltip::size());
int ww, hh;
Expand Down
12 changes: 1 addition & 11 deletions src/Fl_cocoa.mm
Expand Up @@ -614,7 +614,6 @@ - (Fl_Window *)getFl_Window;
- (BOOL)windowShouldClose:(FLWindow *)w;
- (BOOL)containsGLsubwindow;
- (void)setContainsGLsubwindow:(BOOL)contains;
- (BOOL)canBecomeKeyWindow;
@end

@implementation FLWindow
Expand Down Expand Up @@ -651,16 +650,6 @@ - (void)setContainsGLsubwindow:(BOOL)contains
{
containsGLsubwindow = contains;
}
- (BOOL)canBecomeKeyWindow
{
// before 10.5, the default impl of canBecomeKeyWindow is not OK for tooltip windows
// we return YES for these windows
BOOL retval;
Fl_Window *flw = (Fl_Window*)[self getFl_Window];
if(fl_mac_os_version < 0x1050 && flw->tooltip_window()) retval = YES;
else retval = [super canBecomeKeyWindow];
return retval;
}
@end

/*
Expand Down Expand Up @@ -1666,6 +1655,7 @@ - (void)otherMouseUp:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)mouseMoved:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
Expand Down

0 comments on commit 17963c0

Please sign in to comment.