]>
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() )
53 #warning "FIXME: theme override is temporary"
54 wxTheme::Set(wxTheme::Create(_T("gtk")));
63 wxIDirectFB::CleanUp();
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 static wxVideoMode
GetCurrentVideoMode()
74 wxIDirectFBSurfacePtr
surface(wxIDirectFB::Get()->GetPrimarySurface());
78 surface
->GetSize(&m
.w
, &m
.h
);
79 m
.bpp
= surface
->GetDepth();
84 wxVideoMode
wxApp::GetDisplayMode() const
86 if ( !m_videoMode
.IsOk() )
87 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
92 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
94 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
101 //-----------------------------------------------------------------------------
102 // events processing related
103 //-----------------------------------------------------------------------------
105 void wxApp::WakeUpIdle()
108 if (!wxThread::IsMain())
112 wxEventLoop::GetActive()->WakeUp();
115 if (!wxThread::IsMain())
121 bool wxApp::Yield(bool onlyIfNeeded
)
124 if ( !wxThread::IsMain() )
125 return true; // can't process events from other threads
126 #endif // wxUSE_THREADS
128 static bool s_inYield
= false;
134 wxFAIL_MSG( wxT("wxYield called recursively" ) );
144 if ( wxEventLoop::GetActive() )
146 while (wxEventLoop::GetActive()->Pending())
147 wxEventLoop::GetActive()->Dispatch();
150 // it's necessary to call ProcessIdle() to update the frames sizes which
151 // might have been changed (it also will update other things set from
152 // OnUpdateUI() which is a nice (and desired) side effect)
153 while ( ProcessIdle() ) {}