]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/app.cpp
fix building with WXWIN_COMPATIBILITY_2_8 == 0
[wxWidgets.git] / src / gtk1 / app.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/gtk1/app.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
01111366 5// Copyright: (c) 1998 Robert Roebling, Julian Smart
65571936 6// Licence: wxWindows licence
c801d85f
KB
7/////////////////////////////////////////////////////////////////////////////
8
f3858bf5
JJ
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
c801d85f 12#include "wx/app.h"
88a7a4e1
WS
13
14#ifndef WX_PRECOMP
15 #include "wx/intl.h"
e4db172a 16 #include "wx/log.h"
de6185e2 17 #include "wx/utils.h"
fdf565fe 18 #include "wx/dialog.h"
9eddec69 19 #include "wx/settings.h"
246c5004 20 #include "wx/msgdlg.h"
5b56bffb 21 #include "wx/memory.h"
48a1108e 22 #include "wx/font.h"
dd05139a 23 #include "wx/gdicmn.h"
155ecd4c 24 #include "wx/image.h"
02761f6c 25 #include "wx/module.h"
88a7a4e1
WS
26#endif
27
b1ac3b56 28#include "wx/file.h"
2b5f62a0 29#include "wx/filename.h"
fe593cc5 30#include "wx/thread.h"
afb74891 31
62be94e1
RR
32#ifdef __WXGPE__
33#include <gpe/init.h>
34#endif
35
df028524
VS
36#ifdef __WXUNIVERSAL__
37 #include "wx/univ/theme.h"
38 #include "wx/univ/renderer.h"
39#endif
40
91b8de8d 41#if wxUSE_THREADS
a37a5a73 42 #include "wx/thread.h"
91b8de8d 43#endif
afb74891 44
20e05ffb 45#include <unistd.h>
2b5f62a0
VZ
46
47#ifdef HAVE_POLL
48 #if defined(__VMS)
49 #include <poll.h>
50 #else
51 // bug in the OpenBSD headers: at least in 3.1 there is no extern "C"
52 // in neither poll.h nor sys/poll.h which results in link errors later
53 #ifdef __OPENBSD__
54 extern "C"
55 {
56 #endif
57
58 #include <sys/poll.h>
59
60 #ifdef __OPENBSD__
61 };
62 #endif
63 #endif // platform
64#else // !HAVE_POLL
65 // we implement poll() ourselves using select() which is supposed exist in
66 // all modern Unices
67 #include <sys/types.h>
68 #include <sys/time.h>
69 #include <unistd.h>
bc023abb
MW
70 #ifdef HAVE_SYS_SELECT_H
71 #include <sys/select.h>
72 #endif
2b5f62a0
VZ
73#endif // HAVE_POLL/!HAVE_POLL
74
17a1ebd1 75#include "wx/unix/private.h"
3cbab641 76#include "wx/gtk1/win_gtk.h"
c801d85f 77
20e05ffb 78#include <gtk/gtk.h>
24178e4a 79
c801d85f
KB
80//-----------------------------------------------------------------------------
81// global data
82//-----------------------------------------------------------------------------
83
de6185e2 84bool g_mainThreadLocked = false;
96997d65 85gint g_pendingTag = 0;
3ac8d3bc 86
d3b9f782 87static GtkWidget *gs_RootWindow = NULL;
d76fe38b 88
c801d85f 89//-----------------------------------------------------------------------------
3133cb9f 90// idle system
c801d85f
KB
91//-----------------------------------------------------------------------------
92
3133cb9f 93extern bool g_isIdle;
c4fda16b 94
90350682 95void wxapp_install_idle_handler();
bf9e3e73 96
fe593cc5
VS
97#if wxUSE_THREADS
98static wxMutex gs_idleTagsMutex;
99#endif
100
acfd422a 101
bf9e3e73
RR
102//-----------------------------------------------------------------------------
103// wxWakeUpIdle
104//-----------------------------------------------------------------------------
105
19722331
KH
106// RR/KH: The wxMutexGui calls are not needed on GTK2 according to
107// the GTK faq, http://www.gtk.org/faq/#AEN500
108// The calls to gdk_threads_enter() and leave() are specifically noted
109// as not being necessary. The MutexGui calls are still left in for GTK1.
110// Eliminating the MutexGui calls fixes the long-standing "random" lockup
111// when using wxPostEvent (which calls WakeUpIdle) from a thread.
112
e2478fde 113void wxApp::WakeUpIdle()
bf9e3e73 114{
924ef850
RR
115#if wxUSE_THREADS
116 if (!wxThread::IsMain())
ce6d2511 117 wxMutexGuiEnter();
b0f76951 118#endif // wxUSE_THREADS
924ef850 119
c263eb03 120 wxapp_install_idle_handler();
2286341c 121
924ef850
RR
122#if wxUSE_THREADS
123 if (!wxThread::IsMain())
ce6d2511 124 wxMutexGuiLeave();
b0f76951 125#endif // wxUSE_THREADS
bf9e3e73
RR
126}
127
128//-----------------------------------------------------------------------------
129// local functions
130//-----------------------------------------------------------------------------
131
90350682
VZ
132// the callback functions must be extern "C" to comply with GTK+ declarations
133extern "C"
134{
135
3133cb9f 136static gint wxapp_pending_callback( gpointer WXUNUSED(data) )
acfd422a
RR
137{
138 if (!wxTheApp) return TRUE;
c2fa61e8 139
5375a1f5 140 // When getting called from GDK's time-out handler
96997d65 141 // we are no longer within GDK's grab on the GUI
5375a1f5 142 // thread so we must lock it here ourselves.
96997d65
RR
143 gdk_threads_enter();
144
5375a1f5 145 // Sent idle event to all who request them.
96997d65 146 wxTheApp->ProcessPendingEvents();
e90c1d2a 147
fe593cc5
VS
148 {
149#if wxUSE_THREADS
150 wxMutexLocker lock(gs_idleTagsMutex);
151#endif
152 g_pendingTag = 0;
153 }
96997d65 154
5375a1f5 155 // Flush the logged messages if any.
1b2dab34
RR
156#if wxUSE_LOG
157 wxLog::FlushActive();
158#endif // wxUSE_LOG
159
96997d65
RR
160 // Release lock again
161 gdk_threads_leave();
162
163 // Return FALSE to indicate that no more idle events are
164 // to be sent (single shot instead of continuous stream)
165 return FALSE;
166}
167
3133cb9f 168static gint wxapp_idle_callback( gpointer WXUNUSED(data) )
96997d65 169{
a5f1fd3e
VZ
170 if (!wxTheApp)
171 return TRUE;
172
657a8a35 173#if wxDEBUG_LEVEL
6d477bb4
VZ
174 // don't generate the idle events while the assert modal dialog is shown,
175 // this completely confuses the apps which don't expect to be reentered
176 // from some safely-looking functions
a5f1fd3e
VZ
177 if ( wxTheApp->IsInAssert() )
178 {
94a6f0f8
JS
179 // But repaint the assertion message if necessary
180 if (wxTopLevelWindows.GetCount() > 0)
181 {
b1d4dd7a 182 wxWindow* win = (wxWindow*) wxTopLevelWindows.GetLast()->GetData();
94a6f0f8
JS
183 if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog)))
184 win->OnInternalIdle();
185 }
6d477bb4 186 return TRUE;
a5f1fd3e 187 }
657a8a35 188#endif // wxDEBUG_LEVEL
c2fa61e8 189
5375a1f5 190 // When getting called from GDK's time-out handler
924ef850 191 // we are no longer within GDK's grab on the GUI
5375a1f5 192 // thread so we must lock it here ourselves.
924ef850 193 gdk_threads_enter();
094637f6 194
5375a1f5
RR
195 // Indicate that we are now in idle mode and event handlers
196 // will have to reinstall the idle handler again.
fe593cc5
VS
197 {
198#if wxUSE_THREADS
199 wxMutexLocker lock(gs_idleTagsMutex);
200#endif
201 g_isIdle = TRUE;
202 wxTheApp->m_idleTag = 0;
203 }
094637f6 204
3133cb9f 205 // Send idle event to all who request them as long as
5375a1f5
RR
206 // no events have popped up in the event queue.
207 while (wxTheApp->ProcessIdle() && (gtk_events_pending() == 0))
6d477bb4 208 ;
c9e35272 209
96997d65 210 // Release lock again
924ef850 211 gdk_threads_leave();
acfd422a 212
96997d65 213 // Return FALSE to indicate that no more idle events are
5375a1f5 214 // to be sent (single shot instead of continuous stream).
96997d65 215 return FALSE;
acfd422a 216}
8801832d 217
90350682
VZ
218#if wxUSE_THREADS
219
2b5f62a0
VZ
220#ifdef HAVE_POLL
221 #define wxPoll poll
222 #define wxPollFd pollfd
223#else // !HAVE_POLL
224
225typedef GPollFD wxPollFd;
226
227int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout)
228{
229 // convert timeout from ms to struct timeval (s/us)
230 timeval tv_timeout;
231 tv_timeout.tv_sec = timeout/1000;
232 tv_timeout.tv_usec = (timeout%1000)*1000;
233
234 // remember the highest fd used here
235 int fdMax = -1;
236
237 // and fill the sets for select()
238 fd_set readfds;
239 fd_set writefds;
240 fd_set exceptfds;
17a1ebd1
VZ
241 wxFD_ZERO(&readfds);
242 wxFD_ZERO(&writefds);
243 wxFD_ZERO(&exceptfds);
2b5f62a0
VZ
244
245 unsigned int i;
246 for ( i = 0; i < nfds; i++ )
247 {
9a83f860 248 wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, wxT("fd out of range") );
2b5f62a0
VZ
249
250 if ( ufds[i].events & G_IO_IN )
17a1ebd1 251 wxFD_SET(ufds[i].fd, &readfds);
2b5f62a0
VZ
252
253 if ( ufds[i].events & G_IO_PRI )
17a1ebd1 254 wxFD_SET(ufds[i].fd, &exceptfds);
2b5f62a0
VZ
255
256 if ( ufds[i].events & G_IO_OUT )
17a1ebd1 257 wxFD_SET(ufds[i].fd, &writefds);
2b5f62a0
VZ
258
259 if ( ufds[i].fd > fdMax )
260 fdMax = ufds[i].fd;
261 }
262
263 fdMax++;
264 int res = select(fdMax, &readfds, &writefds, &exceptfds, &tv_timeout);
265
266 // translate the results back
267 for ( i = 0; i < nfds; i++ )
268 {
269 ufds[i].revents = 0;
270
17a1ebd1 271 if ( wxFD_ISSET(ufds[i].fd, &readfds ) )
2b5f62a0
VZ
272 ufds[i].revents |= G_IO_IN;
273
17a1ebd1 274 if ( wxFD_ISSET(ufds[i].fd, &exceptfds ) )
2b5f62a0
VZ
275 ufds[i].revents |= G_IO_PRI;
276
17a1ebd1 277 if ( wxFD_ISSET(ufds[i].fd, &writefds ) )
2b5f62a0
VZ
278 ufds[i].revents |= G_IO_OUT;
279 }
280
281 return res;
282}
283
284#endif // HAVE_POLL/!HAVE_POLL
285
3133cb9f 286static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
acfd422a 287{
90350682 288 gdk_threads_enter();
7b90a8f2 289
90350682 290 wxMutexGuiLeave();
de6185e2 291 g_mainThreadLocked = true;
7941ba11 292
2b5f62a0
VZ
293 // we rely on the fact that glib GPollFD struct is really just pollfd but
294 // I wonder how wise is this in the long term (VZ)
295 gint res = wxPoll( (wxPollFd *) ufds, nfds, timeout );
90350682 296
90350682 297 wxMutexGuiEnter();
de6185e2 298 g_mainThreadLocked = false;
90350682 299
90350682
VZ
300 gdk_threads_leave();
301
3133cb9f 302 return res;
ff7b1510 303}
c801d85f 304
90350682
VZ
305#endif // wxUSE_THREADS
306
307} // extern "C"
308
3133cb9f 309void wxapp_install_idle_handler()
b453e1b2 310{
fe593cc5
VS
311#if wxUSE_THREADS
312 wxMutexLocker lock(gs_idleTagsMutex);
313#endif
314
c263eb03
VS
315 // Don't install the handler if it's already installed. This test *MUST*
316 // be done when gs_idleTagsMutex is locked!
317 if (!g_isIdle)
318 return;
319
e8617760
GD
320 // GD: this assert is raised when using the thread sample (which works)
321 // so the test is probably not so easy. Can widget callbacks be
322 // triggered from child threads and, if so, for which widgets?
323 // wxASSERT_MSG( wxThread::IsMain() || gs_WakeUpIdle, wxT("attempt to install idle handler from widget callback in child thread (should be exclusively from wxWakeUpIdle)") );
d5f3e1eb 324
3133cb9f 325 wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") );
c2fa61e8 326
de6185e2 327 g_isIdle = false;
96997d65 328
3133cb9f
RR
329 if (g_pendingTag == 0)
330 g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL );
e90c1d2a 331
3133cb9f
RR
332 // This routine gets called by all event handlers
333 // indicating that the idle is over. It may also
334 // get called from other thread for sending events
335 // to the main thread (and processing these in
336 // idle time). Very low priority.
337 wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL );
b453e1b2
RR
338}
339
960b1f94
VS
340static bool wxOKlibc()
341{
342#if defined(__UNIX__) && defined(__GLIBC__)
343 // glibc 2.0 uses UTF-8 even when it shouldn't
344 wchar_t res = 0;
345 if ((MB_CUR_MAX == 2) &&
346 (wxMB2WC(&res, "\xdd\xa5", 1) == 1) &&
347 (res==0x765))
348 {
349 // this is UTF-8 allright, check whether that's what we want
350 char *cur_locale = setlocale(LC_CTYPE, NULL);
351 if ((strlen(cur_locale) < 4) ||
352 (strcasecmp(cur_locale + strlen(cur_locale) - 4, "utf8")) ||
353 (strcasecmp(cur_locale + strlen(cur_locale) - 5, "utf-8"))) {
354 // nope, don't use libc conversion
355 return false;
356 }
357 }
358#endif
359 return true;
360}
361
005f5d18
RR
362//-----------------------------------------------------------------------------
363// Access to the root window global
364//-----------------------------------------------------------------------------
365
366GtkWidget* wxGetRootWindow()
367{
368 if (gs_RootWindow == NULL)
369 {
370 gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
371 gtk_widget_realize( gs_RootWindow );
372 }
373 return gs_RootWindow;
374}
375
c801d85f
KB
376//-----------------------------------------------------------------------------
377// wxApp
378//-----------------------------------------------------------------------------
379
380IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler)
381
c801d85f
KB
382wxApp::wxApp()
383{
de6185e2 384 m_isInAssert = false;
a5f1fd3e 385
df5ddbca 386 m_idleTag = 0;
c263eb03 387 g_isIdle = TRUE;
df5ddbca 388 wxapp_install_idle_handler();
094637f6 389
6b3eb77a 390#if wxUSE_THREADS
3133cb9f 391 g_main_set_poll_func( wxapp_poll_func );
6b3eb77a 392#endif
60acb947 393
f6fcbb63 394 m_colorCube = (unsigned char*) NULL;
be88a6ad 395
a6f5aa49 396 // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp
d3b9f782
VZ
397 m_glVisualInfo = NULL;
398 m_glFBCInfo = NULL;
ff7b1510 399}
c801d85f 400
60acb947 401wxApp::~wxApp()
c801d85f 402{
acfd422a 403 if (m_idleTag) gtk_idle_remove( m_idleTag );
60acb947 404
f6fcbb63 405 if (m_colorCube) free(m_colorCube);
ff7b1510 406}
c801d85f 407
0d2a2b60 408bool wxApp::OnInitGui()
c801d85f 409{
1e6feb95 410 if ( !wxAppBase::OnInitGui() )
de6185e2 411 return false;
1e6feb95 412
b134516c
RR
413 GdkVisual *visual = gdk_visual_get_system();
414
a6f5aa49
VZ
415 // if this is a wxGLApp (derived from wxApp), and we've already
416 // chosen a specific visual, then derive the GdkVisual from that
005f5d18
RR
417 if (m_glVisualInfo != NULL)
418 {
be88a6ad 419 GdkVisual* vis = gdkx_visual_get(
a6f5aa49
VZ
420 ((XVisualInfo *) m_glVisualInfo) ->visualid );
421 gtk_widget_set_default_visual( vis );
a6f5aa49
VZ
422
423 GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
424 gtk_widget_set_default_colormap( colormap );
425
426 visual = vis;
427 }
be88a6ad 428
005f5d18
RR
429 // On some machines, the default visual is just 256 colours, so
430 // we make sure we get the best. This can sometimes be wasteful.
2286341c 431
005f5d18
RR
432 else
433 if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual))
b134516c
RR
434 {
435 GdkVisual* vis = gdk_visual_get_best();
436 gtk_widget_set_default_visual( vis );
f6fcbb63 437
b134516c
RR
438 GdkColormap *colormap = gdk_colormap_new( vis, FALSE );
439 gtk_widget_set_default_colormap( colormap );
094637f6
VZ
440
441 visual = vis;
b134516c 442 }
d76fe38b 443
005f5d18 444 // Nothing to do for 15, 16, 24, 32 bit displays
f6fcbb63 445 if (visual->depth > 8) return TRUE;
60acb947 446
005f5d18 447 // initialize color cube for 8-bit color reduction dithering
60acb947 448
f6fcbb63 449 GdkColormap *cmap = gtk_widget_get_default_colormap();
60acb947 450
f6fcbb63
RR
451 m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
452
f03fc89f
VZ
453 for (int r = 0; r < 32; r++)
454 {
8801832d
VZ
455 for (int g = 0; g < 32; g++)
456 {
457 for (int b = 0; b < 32; b++)
458 {
459 int rr = (r << 3) | (r >> 2);
460 int gg = (g << 3) | (g >> 2);
461 int bb = (b << 3) | (b >> 2);
60acb947 462
f03fc89f
VZ
463 int index = -1;
464
f6fcbb63 465 GdkColor *colors = cmap->colors;
ca26177c 466 if (colors)
f03fc89f
VZ
467 {
468 int max = 3 * 65536;
469
470 for (int i = 0; i < cmap->size; i++)
471 {
472 int rdiff = ((rr << 8) - colors[i].red);
473 int gdiff = ((gg << 8) - colors[i].green);
474 int bdiff = ((bb << 8) - colors[i].blue);
475 int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
476 if (sum < max)
094637f6 477 {
f03fc89f
VZ
478 index = i; max = sum;
479 }
480 }
f6fcbb63 481 }
094637f6
VZ
482 else
483 {
005f5d18 484 // assume 8-bit true or static colors. this really exists
094637f6
VZ
485 GdkVisual* vis = gdk_colormap_get_visual( cmap );
486 index = (r >> (5 - vis->red_prec)) << vis->red_shift;
487 index |= (g >> (5 - vis->green_prec)) << vis->green_shift;
488 index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift;
094637f6 489 }
8801832d
VZ
490 m_colorCube[ (r*1024) + (g*32) + b ] = index;
491 }
492 }
f6fcbb63 493 }
c801d85f 494
de6185e2 495 return true;
bbe0af5b
RR
496}
497
005f5d18
RR
498GdkVisual *wxApp::GetGdkVisual()
499{
500 GdkVisual *visual = NULL;
be88a6ad 501
005f5d18 502 if (m_glVisualInfo)
7b775074 503 visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid );
005f5d18
RR
504 else
505 visual = gdk_window_get_visual( wxGetRootWindow()->window );
be88a6ad 506
005f5d18 507 wxASSERT( visual );
be88a6ad 508
005f5d18
RR
509 return visual;
510}
511
abca8ebf 512bool wxApp::Initialize(int& argc, wxChar **argv)
c801d85f 513{
c156411a 514 bool init_result;
3cbab641 515
924ef850 516#if wxUSE_THREADS
005f5d18
RR
517 // GTK 1.2 up to version 1.2.3 has broken threads
518 if ((gtk_major_version == 1) &&
8f75cb6c 519 (gtk_minor_version == 2) &&
2286341c 520 (gtk_micro_version < 4))
96997d65 521 {
77ffb593 522 printf( "wxWidgets warning: GUI threading disabled due to outdated GTK version\n" );
8f75cb6c
RR
523 }
524 else
525 {
863136de
RR
526 if (!g_thread_supported())
527 g_thread_init(NULL);
8f75cb6c 528 }
05e2b077 529#endif // wxUSE_THREADS
2286341c 530
0d2a2b60 531 gtk_set_locale();
c801d85f 532
05e2b077 533 if (!wxOKlibc())
960b1f94 534 wxConvCurrent = &wxConvLocal;
002f4218 535
05e2b077
VZ
536#if wxUSE_UNICODE
537 // gtk_init() wants UTF-8, not wchar_t, so convert
538 int i;
0d8dda32 539 char **argvGTK = new char *[argc + 1];
05e2b077 540 for ( i = 0; i < argc; i++ )
924ef850 541 {
05e2b077 542 argvGTK[i] = wxStrdupA(wxConvUTF8.cWX2MB(argv[i]));
924ef850 543 }
0cf2cb36 544
05e2b077 545 argvGTK[argc] = NULL;
954de0f1 546
05e2b077 547 int argcGTK = argc;
3cbab641 548
62be94e1 549#ifdef __WXGPE__
c156411a 550 init_result = true; // is there a _check() version of this?
62be94e1
RR
551 gpe_application_init( &argcGTK, &argvGTK );
552#else
c156411a 553 init_result = gtk_init_check( &argcGTK, &argvGTK );
62be94e1 554#endif
954de0f1 555
05e2b077 556 if ( argcGTK != argc )
924ef850 557 {
05e2b077
VZ
558 // we have to drop the parameters which were consumed by GTK+
559 for ( i = 0; i < argcGTK; i++ )
560 {
0d8dda32 561 while ( strcmp(wxConvUTF8.cWX2MB(argv[i]), argvGTK[i]) != 0 )
05e2b077
VZ
562 {
563 memmove(argv + i, argv + i + 1, argc - i);
564 }
565 }
0cf2cb36 566
05e2b077 567 argc = argcGTK;
2b5f62a0 568 }
05e2b077 569 //else: gtk_init() didn't modify our parameters
e0253070 570
05e2b077
VZ
571 // free our copy
572 for ( i = 0; i < argcGTK; i++ )
0151c3eb 573 {
05e2b077 574 free(argvGTK[i]);
0151c3eb 575 }
0cf2cb36 576
05e2b077
VZ
577 delete [] argvGTK;
578#else // !wxUSE_UNICODE
579 // gtk_init() shouldn't actually change argv itself (just its contents) so
580 // it's ok to pass pointer to it
c156411a 581 init_result = gtk_init_check( &argc, &argv );
05e2b077 582#endif // wxUSE_UNICODE/!wxUSE_UNICODE
0cf2cb36 583
c156411a
RD
584 if (!init_result) {
585 wxLogError(wxT("Unable to initialize gtk, is DISPLAY set properly?"));
586 return false;
587 }
3cbab641 588
4c51a665 589 // we cannot enter threads before gtk_init is done
05e2b077 590 gdk_threads_enter();
0cf2cb36 591
abca8ebf
VZ
592 if ( !wxAppBase::Initialize(argc, argv) )
593 {
594 gdk_threads_leave();
595
596 return false;
597 }
598
05e2b077 599 wxSetDetectableAutoRepeat( TRUE );
be88a6ad 600
05e2b077
VZ
601#if wxUSE_INTL
602 wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
603#endif
be88a6ad 604
05e2b077
VZ
605 return true;
606}
0cf2cb36 607
05e2b077
VZ
608void wxApp::CleanUp()
609{
05e2b077 610 gdk_threads_leave();
abca8ebf
VZ
611
612 wxAppBase::CleanUp();
ff7b1510 613}
1a56f55c 614
657a8a35
VZ
615void wxApp::OnAssertFailure(const wxChar *file,
616 int line,
617 const wxChar* func,
618 const wxChar* cond,
619 const wxChar *msg)
a5f1fd3e 620{
657a8a35
VZ
621 // there is no need to do anything if asserts are disabled in this build
622 // anyhow
623#if wxDEBUG_LEVEL
624 // block wx idle events while assert dialog is showing
de6185e2 625 m_isInAssert = true;
a5f1fd3e 626
657a8a35 627 wxAppBase::OnAssertFailure(file, line, func, cond, msg);
a5f1fd3e 628
de6185e2 629 m_isInAssert = false;
657a8a35
VZ
630#else // !wxDEBUG_LEVEL
631 wxUnusedVar(file);
632 wxUnusedVar(line);
633 wxUnusedVar(func);
634 wxUnusedVar(cond);
635 wxUnusedVar(msg);
636#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
a5f1fd3e
VZ
637}
638
fe593cc5
VS
639void wxApp::RemoveIdleTag()
640{
641#if wxUSE_THREADS
642 wxMutexLocker lock(gs_idleTagsMutex);
643#endif
c263eb03
VS
644 if (!g_isIdle)
645 {
646 gtk_idle_remove( wxTheApp->m_idleTag );
647 wxTheApp->m_idleTag = 0;
de6185e2 648 g_isIdle = true;
c263eb03 649 }
fe593cc5 650}