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 wxEventLoop::CleanUp();
61 wxIDirectFB::CleanUp();
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
68 static wxVideoMode
GetCurrentVideoMode()
70 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
72 return wxVideoMode(); // invalid
74 return layer
->GetVideoMode();
77 wxVideoMode
wxApp::GetDisplayMode() const
79 if ( !m_videoMode
.IsOk() )
80 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
85 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
87 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
94 //-----------------------------------------------------------------------------
95 // events processing related
96 //-----------------------------------------------------------------------------
98 void wxApp::WakeUpIdle()
101 if (!wxThread::IsMain())
105 wxEventLoop::GetActive()->WakeUp();
108 if (!wxThread::IsMain())
114 bool wxApp::Yield(bool onlyIfNeeded
)
117 if ( !wxThread::IsMain() )
118 return true; // can't process events from other threads
119 #endif // wxUSE_THREADS
121 static bool s_inYield
= false;
127 wxFAIL_MSG( wxT("wxYield called recursively" ) );
137 if ( wxEventLoop::GetActive() )
139 while (wxEventLoop::GetActive()->Pending())
140 wxEventLoop::GetActive()->Dispatch();
143 // it's necessary to call ProcessIdle() to update the frames sizes which
144 // might have been changed (it also will update other things set from
145 // OnUpdateUI() which is a nice (and desired) side effect)
146 while ( ProcessIdle() ) {}