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:
Mark de Wever 2009-10-16 19:42:49 +00:00
parent a6430e08f6
commit ee61765f0f
5 changed files with 22 additions and 29 deletions

View File

@ -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);

View File

@ -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.
*

View File

@ -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);

View File

@ -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

View File

@ -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
}