]>
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 wxEventLoop::CleanUp();
61 wxIDirectFB::CleanUp();
64 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
68 static wxVideoMode
GetCurrentVideoMode()
72 wxIDirectFBSurfacePtr
surface(wxIDirectFB::Get()->GetPrimarySurface());
76 surface
->GetSize(&m
.w
, &m
.h
);
77 m
.bpp
= surface
->GetDepth();
82 wxVideoMode
wxApp::GetDisplayMode() const
84 if ( !m_videoMode
.IsOk() )
85 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
90 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
92 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
99 //-----------------------------------------------------------------------------
100 // events processing related
101 //-----------------------------------------------------------------------------
103 void wxApp::WakeUpIdle()
106 if (!wxThread::IsMain())
110 wxEventLoop::GetActive()->WakeUp();
113 if (!wxThread::IsMain())
119 bool wxApp::Yield(bool onlyIfNeeded
)
122 if ( !wxThread::IsMain() )
123 return true; // can't process events from other threads
124 #endif // wxUSE_THREADS
126 static bool s_inYield
= false;
132 wxFAIL_MSG( wxT("wxYield called recursively" ) );
142 if ( wxEventLoop::GetActive() )
144 while (wxEventLoop::GetActive()->Pending())
145 wxEventLoop::GetActive()->Dispatch();
148 // it's necessary to call ProcessIdle() to update the frames sizes which
149 // might have been changed (it also will update other things set from
150 // OnUpdateUI() which is a nice (and desired) side effect)
151 while ( ProcessIdle() ) {}