Evaluate the mouse focus upon showing and resizing.

When a dialog is shown or resized and the mouse pointer is above the
widget the engine didn't send and mouse enter event. This partly fixes
bug #12927.
This commit is contained in:
Mark de Wever 2009-02-17 20:41:49 +00:00
parent c0765659a4
commit d184c47fe8
3 changed files with 27 additions and 0 deletions

View File

@ -307,6 +307,22 @@ tpoint tevent_handler::get_mouse() const
return tpoint(mouse_x_, mouse_y_);
}
void tevent_handler::init_mouse_location()
{
// Fix the mouse location by pushing a dummy event.
int x;
int y;
SDL_GetMouseState(&x, &y);
SDL_Event event;
event.type = SDL_MOUSEMOTION;
event.motion.type = SDL_MOUSEMOTION;
event.motion.x = x;
event.motion.y = y;
x = SDL_PushEvent(&event);
}
void tevent_handler::add_to_keyboard_chain(twidget* widget)
{
assert(widget);

View File

@ -96,6 +96,14 @@ public:
/** Return the current mouse position. */
tpoint get_mouse() const;
/**
* Initializes the location of the mouse.
*
* After a layout of the window the mouse location needs to be updated to
* test whether it entered or left a widget.
*/
void init_mouse_location();
/**
* Shows a tooltip.
*

View File

@ -566,6 +566,9 @@ void twindow::layout()
generate_dot_file("layout_finished", LAYOUT);
need_layout_ = false;
// The widgets might have moved so set the mouse location properly.
init_mouse_location();
}
void twindow::do_show_tooltip(const tpoint& location, const t_string& tooltip)