+#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON)
+void wxPopupTransientWindow::OnIdle(wxIdleEvent& event)
+{
+ event.Skip();
+
+ if (IsShown() && m_child)
+ {
+ // Store the last mouse position to minimize the number of calls to
+ // wxFindWindowAtPoint() which are quite expensive.
+ static wxPoint s_posLast;
+ const wxPoint pos = wxGetMousePosition();
+ if ( pos != s_posLast )
+ {
+ s_posLast = pos;
+
+ wxWindow* const winUnderMouse = wxFindWindowAtPoint(pos);
+
+ // We release the mouse capture while the mouse is inside the popup
+ // itself to allow using it normally with the controls inside it.
+ if ( wxGetTopLevelParent(winUnderMouse) == this )
+ {
+ if ( m_child->HasCapture() )
+ {
+ m_child->ReleaseMouse();
+ }
+ }
+ else // And we reacquire it as soon as the mouse goes outside.
+ {
+ if ( !m_child->HasCapture() )
+ {
+ m_child->CaptureMouse();
+ }
+ }
+ }
+ }
+}
+#endif // wxOSX/Carbon
+
+