X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a43c3ed05748f609f03d72142aa961dce19da41e..b2b4f8c0ca2884f99a923d30b4b37b12c76e936b:/src/dfb/toplevel.cpp diff --git a/src/dfb/toplevel.cpp b/src/dfb/toplevel.cpp index c7f23b52df..bb1620b49a 100644 --- a/src/dfb/toplevel.cpp +++ b/src/dfb/toplevel.cpp @@ -138,7 +138,7 @@ bool wxTopLevelWindowDFB::Create(wxWindow *parent, desc.width = size.x; desc.height = size.y; m_dfbwin = layer->CreateWindow(&desc); - if ( !layer ) + if ( !m_dfbwin ) return false; // add the new TLW to DFBWindowID->wxTLW map: @@ -176,22 +176,23 @@ wxTopLevelWindowDFB::~wxTopLevelWindowDFB() { m_isBeingDeleted = true; - wxTopLevelWindows.DeleteObject(this); - - if ( wxTheApp->GetTopWindow() == this ) - wxTheApp->SetTopWindow(NULL); - - if ( wxTopLevelWindows.empty() && wxTheApp->GetExitOnFrameDelete() ) - { - wxTheApp->ExitMainLoop(); - } + // destroy all children before we destroy the underlying DirectFB window, + // so that if any of them does something with the TLW, it will still work: + DestroyChildren(); + // it's safe to delete the underlying DirectFB window now: wxDELETE(m_toPaint); + if ( !m_dfbwin ) + return; + // remove the TLW from DFBWindowID->wxTLW map: DFBWindowID winid; if ( m_dfbwin->GetID(&winid) ) gs_dfbWindowsMap.erase(winid); + + m_dfbwin->Destroy(); + m_dfbwin.Reset(); } // ---------------------------------------------------------------------------- @@ -269,12 +270,11 @@ bool wxTopLevelWindowDFB::ShowFullScreen(bool show, long style) bool wxTopLevelWindowDFB::Show(bool show) { + // NB: this calls wxWindow::Show() and so ensures DoRefreshWindow() is + // called on the window -- we'll need that below if ( !wxTopLevelWindowBase::Show(show) ) return false; - // hide/show the window by setting its opacity to 0/full: - m_dfbwin->SetOpacity(show ? m_opacity : 0); - // If this is the first time Show was called, send size event, // so that the frame can adjust itself (think auto layout or single child) if ( !m_sizeSet ) @@ -285,6 +285,17 @@ bool wxTopLevelWindowDFB::Show(bool show) GetEventHandler()->ProcessEvent(event); } + // make sure the window is fully painted, with all pending updates, before + // DFB WM shows it, otherwise it would attempt to show either empty (= + // black) window surface (if shown for the first time) or it would show + // window with outdated content; note that the window was already refreshed + // in the wxTopLevelWindowBase::Show() call above: + if ( show ) + Update(); + + // hide/show the window by setting its opacity to 0/full: + m_dfbwin->SetOpacity(show ? m_opacity : 0); + if ( show ) { wxWindow *focused = wxWindow::FindFocus();