1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/app.cpp
3 // Purpose: wxApp implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
20 #include "wx/evtloop.h"
21 #include "wx/thread.h"
22 #include "wx/dfb/private.h"
23 #include "wx/private/fontmgr.h"
25 //-----------------------------------------------------------------------------
26 // wxApp initialization
27 //-----------------------------------------------------------------------------
29 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
39 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
41 if ( !wxAppBase::Initialize(argc
, argv
) )
44 // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This
45 // is just a temporary fix to make wxDFB compile in Unicode
46 // build, the real fix is to change Initialize()'s signature
47 // to use char* on Unix.
49 // DirectFBInit() wants UTF-8, not wchar_t, so convert
51 char **argvDFB
= new char *[argc
+ 1];
52 for ( i
= 0; i
< argc
; i
++ )
54 argvDFB
[i
] = strdup(wxConvUTF8
.cWX2MB(argv
[i
]));
61 if ( !wxDfbCheckReturn(DirectFBInit(&argcDFB
, &argvDFB
)) )
64 if ( argcDFB
!= argc
)
66 // we have to drop the parameters which were consumed by DFB+
67 for ( i
= 0; i
< argcDFB
; i
++ )
69 while ( strcmp(wxConvUTF8
.cWX2MB(argv
[i
]), argvDFB
[i
]) != 0 )
71 memmove(argv
+ i
, argv
+ i
+ 1, (argc
- i
)*sizeof(*argv
));
77 //else: DirectFBInit() didn't modify our parameters
80 for ( i
= 0; i
< argcDFB
; i
++ )
89 if ( !wxDfbCheckReturn(DirectFBInit(&argc
, &argv
)) )
92 #endif // Unicode/ANSI
94 // update internal arg[cv] as DFB may have removed processed options:
98 if ( !wxIDirectFB::Get() )
104 void wxApp::CleanUp()
106 wxAppBase::CleanUp();
108 wxFontsManager::CleanUp();
110 wxEventLoop::CleanUp();
111 wxIDirectFB::CleanUp();
114 //-----------------------------------------------------------------------------
116 //-----------------------------------------------------------------------------
118 static wxVideoMode
GetCurrentVideoMode()
120 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
122 return wxVideoMode(); // invalid
124 return layer
->GetVideoMode();
127 wxVideoMode
wxApp::GetDisplayMode() const
129 if ( !m_videoMode
.IsOk() )
130 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
135 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
137 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
144 //-----------------------------------------------------------------------------
145 // events processing related
146 //-----------------------------------------------------------------------------
148 void wxApp::WakeUpIdle()
150 // we don't need a mutex here, since we use the wxConsoleEventLoop
151 // and wxConsoleEventLoop::WakeUp() is thread-safe
152 wxEventLoopBase
* const loop
= wxEventLoop::GetActive();