]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/app.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/app.cpp
3 // Purpose: wxApp implementation
4 // Author: Vaclav Slavik
5 // based on MGL implementation
8 // Copyright: (c) 2006 REA Elektronik GmbH
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/evtloop.h"
22 #include "wx/dfb/private.h"
24 //-----------------------------------------------------------------------------
25 // wxApp initialization
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
30 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
31 EVT_IDLE(wxAppBase::OnIdle
)
42 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
44 if ( !wxAppBase::Initialize(argc
, argv
) )
47 if ( !wxDfbCheckReturn(DirectFBInit(&argc
, &argv
)) )
50 if ( !wxIDirectFB::Get() )
60 wxIDirectFB::CleanUp();
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 static wxVideoMode
GetCurrentVideoMode()
71 wxIDirectFBSurfacePtr
surface(wxIDirectFB::Get()->GetPrimarySurface());
75 surface
->GetSize(&m
.w
, &m
.h
);
76 m
.bpp
= surface
->GetDepth();
81 wxVideoMode
wxApp::GetDisplayMode() const
83 if ( !m_videoMode
.IsOk() )
84 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
89 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
91 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
98 //-----------------------------------------------------------------------------
99 // events processing related
100 //-----------------------------------------------------------------------------
102 void wxApp::WakeUpIdle()
105 if (!wxThread::IsMain())
109 wxEventLoop::GetActive()->WakeUp();
112 if (!wxThread::IsMain())
118 bool wxApp::Yield(bool onlyIfNeeded
)
121 if ( !wxThread::IsMain() )
122 return true; // can't process events from other threads
123 #endif // wxUSE_THREADS
125 static bool s_inYield
= false;
131 wxFAIL_MSG( wxT("wxYield called recursively" ) );
141 if ( wxEventLoop::GetActive() )
143 while (wxEventLoop::GetActive()->Pending())
144 wxEventLoop::GetActive()->Dispatch();
147 // it's necessary to call ProcessIdle() to update the frames sizes which
148 // might have been changed (it also will update other things set from
149 // OnUpdateUI() which is a nice (and desired) side effect)
150 while ( ProcessIdle() ) {}