X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/385e8575dd1f9219fb0e3f7fa26ffe4c24d2fdbb..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/common/popupcmn.cpp diff --git a/src/common/popupcmn.cpp b/src/common/popupcmn.cpp index 9bad6ac633..4d94eaa688 100644 --- a/src/common/popupcmn.cpp +++ b/src/common/popupcmn.cpp @@ -44,7 +44,11 @@ #ifdef __WXGTK__ #include - #include "wx/gtk/private/gtk2-compat.h" + #if GTK_CHECK_VERSION(2,0,0) + #include "wx/gtk/private/gtk2-compat.h" + #else + #define gtk_widget_get_window(x) x->window + #endif #elif defined(__WXMSW__) #include "wx/msw/private.h" #elif defined(__WXX11__) @@ -72,6 +76,7 @@ public: protected: // event handlers void OnLeftDown(wxMouseEvent& event); + void OnCaptureLost(wxMouseCaptureLostEvent& event); private: wxPopupTransientWindow *m_popup; @@ -102,6 +107,7 @@ private: BEGIN_EVENT_TABLE(wxPopupWindowHandler, wxEvtHandler) EVT_LEFT_DOWN(wxPopupWindowHandler::OnLeftDown) + EVT_MOUSE_CAPTURE_LOST(wxPopupWindowHandler::OnCaptureLost) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler) @@ -110,7 +116,7 @@ BEGIN_EVENT_TABLE(wxPopupFocusHandler, wxEvtHandler) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxPopupTransientWindow, wxPopupWindow) -#if defined( __WXMSW__ ) || ( defined( __WXMAC__ ) && wxOSX_USE_CARBON ) +#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_CARBON) EVT_IDLE(wxPopupTransientWindow::OnIdle) #endif END_EVENT_TABLE() @@ -383,6 +389,20 @@ bool wxPopupTransientWindow::Show( bool show ) return ret; } +bool wxPopupTransientWindow::Destroy() +{ + // The popup window can be deleted at any moment, even while some events + // are still being processed for it, so delay its real destruction until + // the next idle time when we're sure that it's safe to really destroy it. + + wxCHECK_MSG( !wxPendingDelete.Member(this), false, + wxS("Shouldn't destroy the popup twice.") ); + + wxPendingDelete.Append(this); + + return true; +} + void wxPopupTransientWindow::Dismiss() { Hide(); @@ -406,7 +426,7 @@ bool wxPopupTransientWindow::ProcessLeftDown(wxMouseEvent& WXUNUSED(event)) return false; } -#if defined( __WXMSW__ ) || ( defined( __WXMAC__ ) && wxOSX_USE_CARBON ) +#if defined(__WXMSW__) ||(defined(__WXMAC__) && wxOSX_USE_CARBON) void wxPopupTransientWindow::OnIdle(wxIdleEvent& event) { event.Skip(); @@ -432,7 +452,7 @@ void wxPopupTransientWindow::OnIdle(wxIdleEvent& event) } } } -#endif // __WXMSW__ +#endif // wxOSX/Carbon #if wxUSE_COMBOBOX && defined(__WXUNIVERSAL__) @@ -582,6 +602,15 @@ void wxPopupWindowHandler::OnLeftDown(wxMouseEvent& event) #endif // __WXUNIVERSAL__ && wxUSE_SCROLLBAR } +void +wxPopupWindowHandler::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) +{ + m_popup->DismissAndNotify(); + + // There is no need to skip the event here, normally we've already dealt + // with the focus loss. +} + // ---------------------------------------------------------------------------- // wxPopupFocusHandler // ----------------------------------------------------------------------------