1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/app.cpp
3 // Purpose: wxApp implementation
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
19 #include "wx/evtloop.h"
20 #include "wx/thread.h"
21 #include "wx/dfb/private.h"
22 #include "wx/private/fontmgr.h"
24 //-----------------------------------------------------------------------------
25 // wxApp initialization
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
38 bool wxApp::Initialize(int& argc
, wxChar
**argv
)
40 if ( !wxAppBase::Initialize(argc
, argv
) )
43 // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This
44 // is just a temporary fix to make wxDFB compile in Unicode
45 // build, the real fix is to change Initialize()'s signature
46 // to use char* on Unix.
48 // DirectFBInit() wants UTF-8, not wchar_t, so convert
50 char **argvDFB
= new char *[argc
+ 1];
51 for ( i
= 0; i
< argc
; i
++ )
53 argvDFB
[i
] = strdup(wxConvUTF8
.cWX2MB(argv
[i
]));
60 if ( !wxDfbCheckReturn(DirectFBInit(&argcDFB
, &argvDFB
)) )
63 if ( argcDFB
!= argc
)
65 // we have to drop the parameters which were consumed by DFB+
66 for ( i
= 0; i
< argcDFB
; i
++ )
68 while ( strcmp(wxConvUTF8
.cWX2MB(argv
[i
]), argvDFB
[i
]) != 0 )
70 memmove(argv
+ i
, argv
+ i
+ 1, (argc
- i
)*sizeof(*argv
));
76 //else: DirectFBInit() didn't modify our parameters
79 for ( i
= 0; i
< argcDFB
; i
++ )
88 if ( !wxDfbCheckReturn(DirectFBInit(&argc
, &argv
)) )
91 #endif // Unicode/ANSI
93 // update internal arg[cv] as DFB may have removed processed options:
97 if ( !wxIDirectFB::Get() )
103 void wxApp::CleanUp()
105 wxAppBase::CleanUp();
107 wxFontsManager::CleanUp();
109 wxEventLoop::CleanUp();
110 wxIDirectFB::CleanUp();
113 //-----------------------------------------------------------------------------
115 //-----------------------------------------------------------------------------
117 static wxVideoMode
GetCurrentVideoMode()
119 wxIDirectFBDisplayLayerPtr
layer(wxIDirectFB::Get()->GetDisplayLayer());
121 return wxVideoMode(); // invalid
123 return layer
->GetVideoMode();
126 wxVideoMode
wxApp::GetDisplayMode() const
128 if ( !m_videoMode
.IsOk() )
129 wxConstCast(this, wxApp
)->m_videoMode
= GetCurrentVideoMode();
134 bool wxApp::SetDisplayMode(const wxVideoMode
& mode
)
136 if ( !wxIDirectFB::Get()->SetVideoMode(mode
.w
, mode
.h
, mode
.bpp
) )
143 //-----------------------------------------------------------------------------
144 // events processing related
145 //-----------------------------------------------------------------------------
147 void wxApp::WakeUpIdle()
149 // we don't need a mutex here, since we use the wxConsoleEventLoop
150 // and wxConsoleEventLoop::WakeUp() is thread-safe
151 wxEventLoopBase
* const loop
= wxEventLoop::GetActive();