mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-12 14:41:51 +00:00
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:
parent
c0765659a4
commit
d184c47fe8
@ -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);
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user