X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe593cc504195a3c91281eae4edf5e852a51a59c..81f6ea4a29eb815dbed0adea369efdc8fece0269:/src/gtk/app.cpp diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 5aa26126a7..aaf7989b30 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -7,10 +7,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "app.h" -#endif - #ifdef __VMS // vms_jackets.h should for proper working be included before anything else # include @@ -76,11 +72,11 @@ #include #endif // HAVE_POLL/!HAVE_POLL +#include "wx/unix/private.h" #include "wx/gtk/win_gtk.h" #include - //----------------------------------------------------------------------------- // global data //----------------------------------------------------------------------------- @@ -133,17 +129,15 @@ bool wxApp::Yield(bool onlyIfNeeded) wxIsInsideYield = TRUE; - if (!g_isIdle) - { - // We need to remove idle callbacks or the loop will - // never finish. - wxTheApp->RemoveIdleTag(); - g_isIdle = TRUE; - } + // We need to remove idle callbacks or the loop will + // never finish. + wxTheApp->RemoveIdleTag(); +#if wxUSE_LOG // disable log flushing from here because a call to wxYield() shouldn't // normally result in message boxes popping up &c wxLog::Suspend(); +#endif while (gtk_events_pending()) gtk_main_iteration(); @@ -156,8 +150,10 @@ bool wxApp::Yield(bool onlyIfNeeded) // return value of Processidle(). ProcessIdle(); +#if wxUSE_LOG // let the logs be flashed again wxLog::Resume(); +#endif wxIsInsideYield = FALSE; @@ -184,8 +180,7 @@ void wxApp::WakeUpIdle() #endif // wxUSE_THREADS_ #endif // __WXGTK2__ - if (g_isIdle) - wxapp_install_idle_handler(); + wxapp_install_idle_handler(); #ifndef __WXGTK20__ #if wxUSE_THREADS @@ -312,23 +307,23 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) fd_set readfds; fd_set writefds; fd_set exceptfds; - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); + wxFD_ZERO(&readfds); + wxFD_ZERO(&writefds); + wxFD_ZERO(&exceptfds); unsigned int i; for ( i = 0; i < nfds; i++ ) { - wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") ); + wxASSERT_MSG( ufds[i].fd < wxFD_SETSIZE, _T("fd out of range") ); if ( ufds[i].events & G_IO_IN ) - FD_SET(ufds[i].fd, &readfds); + wxFD_SET(ufds[i].fd, &readfds); if ( ufds[i].events & G_IO_PRI ) - FD_SET(ufds[i].fd, &exceptfds); + wxFD_SET(ufds[i].fd, &exceptfds); if ( ufds[i].events & G_IO_OUT ) - FD_SET(ufds[i].fd, &writefds); + wxFD_SET(ufds[i].fd, &writefds); if ( ufds[i].fd > fdMax ) fdMax = ufds[i].fd; @@ -342,13 +337,13 @@ int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) { ufds[i].revents = 0; - if ( FD_ISSET(ufds[i].fd, &readfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &readfds ) ) ufds[i].revents |= G_IO_IN; - if ( FD_ISSET(ufds[i].fd, &exceptfds ) ) + if ( wxFD_ISSET(ufds[i].fd, &exceptfds ) ) ufds[i].revents |= G_IO_PRI; - if ( FD_ISSET(ufds[i].fd, &writefds ) ) + if ( wxFD_ISSET(ufds[i].fd, &writefds ) ) ufds[i].revents |= G_IO_OUT; } @@ -386,6 +381,11 @@ void wxapp_install_idle_handler() wxMutexLocker lock(gs_idleTagsMutex); #endif + // Don't install the handler if it's already installed. This test *MUST* + // be done when gs_idleTagsMutex is locked! + if (!g_isIdle) + return; + // GD: this assert is raised when using the thread sample (which works) // so the test is probably not so easy. Can widget callbacks be // triggered from child threads and, if so, for which widgets? @@ -437,6 +437,7 @@ wxApp::wxApp() #endif // __WXDEBUG__ m_idleTag = 0; + g_isIdle = TRUE; wxapp_install_idle_handler(); #if wxUSE_THREADS @@ -447,6 +448,7 @@ wxApp::wxApp() // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp m_glVisualInfo = (void *) NULL; + m_glFBCInfo = (void *) NULL; } wxApp::~wxApp() @@ -605,6 +607,35 @@ bool wxApp::Initialize(int& argc, wxChar **argv) wxConvCurrent = (wxMBConv*) NULL; #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T +#ifdef __WXGTK20__ + // decide which conversion to use for the file names + + // (1) this variable exists for the sole purpose of specifying the encoding + // of the filenames for GTK+ programs, so use it if it is set + wxString encName(wxGetenv(_T("G_FILENAME_ENCODING"))); + encName = encName.BeforeFirst(_T(',')); + if (encName == _T("@locale")) + encName.clear(); + encName.MakeUpper(); +#if wxUSE_INTL + if (encName.empty()) + { + // (2) if a non default locale is set, assume that the user wants his + // filenames in this locale too + encName = wxLocale::GetSystemEncodingName().Upper(); + // (3) finally use UTF-8 by default + if (encName.empty() || encName == _T("US-ASCII")) + encName = _T("UTF-8"); + wxSetEnv(_T("G_FILENAME_ENCODING"), encName); + } +#else + if (encName.empty()) + encName = _T("UTF-8"); +#endif // wxUSE_INTL + static wxConvBrokenFileNames fileconv(encName); + wxConvFileName = &fileconv; +#endif // __WXGTK20__ + #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert int i; @@ -702,6 +733,10 @@ void wxApp::RemoveIdleTag() #if wxUSE_THREADS wxMutexLocker lock(gs_idleTagsMutex); #endif - gtk_idle_remove( wxTheApp->m_idleTag ); - wxTheApp->m_idleTag = 0; + if (!g_isIdle) + { + gtk_idle_remove( wxTheApp->m_idleTag ); + wxTheApp->m_idleTag = 0; + g_isIdle = TRUE; + } }