mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 15:36:06 +00:00
Make init_mouse_location() a free function.
No need to keep it as member since it uses nothing of the class. Moved it to the handler file since I'll need it there as well.
This commit is contained in:
parent
a6430e08f6
commit
ee61765f0f
@ -556,22 +556,6 @@ void tdistributor::keyboard_capture(twidget* widget)
|
||||
}
|
||||
}
|
||||
|
||||
void tdistributor::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;
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
void tdistributor::keyboard_add_to_chain(twidget* widget)
|
||||
{
|
||||
assert(widget);
|
||||
|
@ -232,16 +232,6 @@ public:
|
||||
*/
|
||||
void keyboard_remove_from_chain(twidget* widget);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @todo move to the tmouse_motion class or make a free function...
|
||||
*/
|
||||
void init_mouse_location();
|
||||
|
||||
/**
|
||||
* Shows a tooltip.
|
||||
*
|
||||
|
@ -546,6 +546,19 @@ void disconnect_dispatcher(tdispatcher* dispatcher)
|
||||
handler->disconnect(dispatcher);
|
||||
}
|
||||
|
||||
void init_mouse_location()
|
||||
{
|
||||
tpoint mouse = get_mouse_position();
|
||||
|
||||
SDL_Event event;
|
||||
event.type = SDL_MOUSEMOTION;
|
||||
event.motion.type = SDL_MOUSEMOTION;
|
||||
event.motion.x = mouse.x;
|
||||
event.motion.y = mouse.y;
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
void capture_mouse(tdispatcher* dispatcher)
|
||||
{
|
||||
assert(handler);
|
||||
|
@ -197,6 +197,14 @@ void connect_dispatcher(tdispatcher* dispatcher);
|
||||
*/
|
||||
void disconnect_dispatcher(tdispatcher* dispatcher);
|
||||
|
||||
/**
|
||||
* 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. Also after closing a window it's
|
||||
* needed to send a dummy mouse move.
|
||||
*/
|
||||
void init_mouse_location();
|
||||
|
||||
/**
|
||||
* Captures the mouse.
|
||||
@ -217,7 +225,6 @@ void capture_mouse(tdispatcher* dispatcher);
|
||||
*/
|
||||
void release_mouse(tdispatcher* dispatcher);
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, const tevent event);
|
||||
|
||||
} // namespace event
|
||||
|
@ -894,8 +894,7 @@ void twindow::layout()
|
||||
// The widgets might have moved so set the mouse location properly.
|
||||
init_mouse_location();
|
||||
#else
|
||||
assert(event_distributor_);
|
||||
event_distributor_->init_mouse_location();
|
||||
event::init_mouse_location();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user