- wxMouseEvent event2(event);
- wxPoint where2 = g_windowUnderMouse->ScreenToClient(
- wxPoint(e->where_x, e->where_y));
- event2.m_x = where2.x;
- event2.m_y = where2.y;
- event2.SetEventObject(g_windowUnderMouse);
- event2.SetEventType(wxEVT_LEAVE_WINDOW);
- g_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
+ if ( gs_windowUnderMouse )
+ {
+ wxMouseEvent event2(event);
+ MGL_wmCoordGlobalToLocal(gs_windowUnderMouse->GetHandle(),
+ e->where_x, e->where_y,
+ &event2.m_x, &event2.m_y);
+
+ wxPoint orig(gs_windowUnderMouse->GetClientAreaOrigin());
+ event2.m_x -= orig.x;
+ event2.m_y -= orig.y;
+
+ event2.SetEventObject(gs_windowUnderMouse);
+ event2.SetEventType(wxEVT_LEAVE_WINDOW);
+ gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
+ }
+
+ wxMouseEvent event3(event);
+ event3.SetEventType(wxEVT_ENTER_WINDOW);
+ win->GetEventHandler()->ProcessEvent(event3);
+
+ gs_windowUnderMouse = win;
+ }
+ }
+ else // gs_mouseCapture
+ {
+ bool inside = (where.x >= 0 &&
+ where.y >= 0 &&
+ where.x < win->GetSize().x &&
+ where.y < win->GetSize().y);
+ if ( (inside && gs_windowUnderMouse != win) ||
+ (!inside && gs_windowUnderMouse == win) )
+ {
+ wxMouseEvent evt(inside ?
+ wxEVT_ENTER_WINDOW : wxEVT_LEAVE_WINDOW);
+ evt.SetEventObject(win);
+ win->GetEventHandler()->ProcessEvent(evt);
+ gs_windowUnderMouse = inside ? win : NULL;