MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / HandleMouseOver

Function HandleMouseOver

src/window.cpp:1984–2004  ·  view source on GitHub ↗

Report position of the mouse to the underlying window. */

Source from the content-addressed store, hash-verified

1982
1983/** Report position of the mouse to the underlying window. */
1984static void HandleMouseOver()
1985{
1986 Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
1987
1988 /* We changed window, put an OnMouseOver event to the last window */
1989 if (_mouseover_last_w != nullptr && _mouseover_last_w != w) {
1990 /* Reset mouse-over coordinates of previous window */
1991 Point pt = { -1, -1 };
1992 _mouseover_last_w->OnMouseOver(pt, 0);
1993 }
1994
1995 /* _mouseover_last_w will get reset when the window is deleted, see DeleteWindow() */
1996 _mouseover_last_w = w;
1997
1998 if (w != nullptr) {
1999 /* send an event in client coordinates. */
2000 Point pt = { _cursor.pos.x - w->left, _cursor.pos.y - w->top };
2001 const NWidgetCore *widget = w->nested_root->GetWidgetFromPos(pt.x, pt.y);
2002 if (widget != nullptr) w->OnMouseOver(pt, widget->GetIndex());
2003 }
2004}
2005
2006/** Direction for moving the window. */
2007enum PreventHideDirection : uint8_t {

Callers 1

MouseLoopFunction · 0.85

Calls 4

FindWindowFromPtFunction · 0.85
OnMouseOverMethod · 0.45
GetWidgetFromPosMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected