]>
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 IDirectFBPtr
wxApp::GetDirectFBInterface()
47 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
49 if ( !wxAppBase::Initialize(argc
, argv
) )
52 if ( !DFB_CALL( DirectFBInit(&argc
, &argv
) ) )
55 if ( !DFB_CALL( DirectFBCreate(&m_dfb
) ) )
58 #warning "FIXME: theme override is temporary"
59 wxTheme::Set(wxTheme::Create(_T("gtk")));
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
75 static wxVideoMode
GetCurrentVideoMode()
79 IDirectFBSurfacePtr
surface(wxDfbGetPrimarySurface());
83 DFB_CALL( surface
->GetSize(surface
, &m
.w
, &m
.h
) );
84 m
.bpp
= wxDfbGetSurfaceDepth(surface
);
89 wxVideoMode
wxApp::GetDisplayMode() const
91 if ( !m_videoMode
.IsOk() )
92 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
97 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
99 if ( !DFB_CALL( m_dfb
->SetVideoMode(m_dfb
, mode
.w
, mode
.h
, mode
.bpp
) ) )
106 //-----------------------------------------------------------------------------
107 // events processing related
108 //-----------------------------------------------------------------------------
110 void wxApp::WakeUpIdle()
113 if (!wxThread::IsMain())
117 wxEventLoop::GetActive()->WakeUp();
120 if (!wxThread::IsMain())
126 bool wxApp::Yield(bool onlyIfNeeded
)
129 if ( !wxThread::IsMain() )
130 return true; // can't process events from other threads
131 #endif // wxUSE_THREADS
133 static bool s_inYield
= false;
139 wxFAIL_MSG( wxT("wxYield called recursively" ) );
149 if ( wxEventLoop::GetActive() )
151 while (wxEventLoop::GetActive()->Pending())
152 wxEventLoop::GetActive()->Dispatch();
155 // it's necessary to call ProcessIdle() to update the frames sizes which
156 // might have been changed (it also will update other things set from
157 // OnUpdateUI() which is a nice (and desired) side effect)
158 while ( ProcessIdle() ) {}