GUI thread update and event corrections.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5141 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -109,8 +109,18 @@ bool wxYield()
|
||||
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
gdk_threads_enter();
|
||||
#endif
|
||||
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
gdk_threads_leave();
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -121,12 +131,10 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||
{
|
||||
if (!wxTheApp) return TRUE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
/* when getting called from GDK's idle handler we
|
||||
are no longer within GDK's grab on the GUI
|
||||
thread so we must lock it here ourselves */
|
||||
GDK_THREADS_ENTER ();
|
||||
#endif
|
||||
// when getting called from GDK's time-out handler
|
||||
// we are no longer within GDK's grab on the GUI
|
||||
// thread so we must lock it here ourselves
|
||||
gdk_threads_enter();
|
||||
|
||||
/* sent idle event to all who request them */
|
||||
while (wxTheApp->ProcessIdle()) { }
|
||||
@@ -143,10 +151,8 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||
emptied */
|
||||
g_isIdle = TRUE;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
/* release lock again */
|
||||
GDK_THREADS_LEAVE ();
|
||||
#endif
|
||||
// release lock again
|
||||
gdk_threads_leave();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -161,19 +167,9 @@ void wxapp_install_idle_handler()
|
||||
to the main thread (and processing these in
|
||||
idle time). */
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
GDK_THREADS_ENTER ();
|
||||
#endif
|
||||
|
||||
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
|
||||
|
||||
g_isIdle = FALSE;
|
||||
|
||||
#if wxUSE_THREADS
|
||||
if (!wxThread::IsMain())
|
||||
GDK_THREADS_LEAVE ();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if wxUSE_THREADS
|
||||
@@ -182,7 +178,7 @@ void wxapp_install_thread_wakeup()
|
||||
{
|
||||
if (wxTheApp->m_wakeUpTimerTag) return;
|
||||
|
||||
wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 100, wxapp_wakeup_timerout_callback, (gpointer) NULL );
|
||||
wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL );
|
||||
}
|
||||
|
||||
void wxapp_uninstall_thread_wakeup()
|
||||
@@ -195,14 +191,13 @@ void wxapp_uninstall_thread_wakeup()
|
||||
|
||||
gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
|
||||
{
|
||||
wxapp_uninstall_thread_wakeup();
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
// when getting called from GDK's time-out handler
|
||||
// we are no longer within GDK's grab on the GUI
|
||||
// thread so we must lock it here ourselves
|
||||
GDK_THREADS_ENTER ();
|
||||
#endif
|
||||
|
||||
gdk_threads_enter();
|
||||
|
||||
wxapp_uninstall_thread_wakeup();
|
||||
|
||||
// unblock other threads wishing to do some GUI things
|
||||
wxMutexGuiLeave();
|
||||
@@ -213,13 +208,11 @@ gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
|
||||
// block other thread again
|
||||
wxMutexGuiEnter();
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
// release lock again
|
||||
GDK_THREADS_LEAVE ();
|
||||
#endif
|
||||
|
||||
wxapp_install_thread_wakeup();
|
||||
|
||||
// release lock again
|
||||
gdk_threads_leave();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -560,6 +553,10 @@ void wxApp::CleanUp()
|
||||
|
||||
int wxEntry( int argc, char *argv[] )
|
||||
{
|
||||
#if wxUSE_THREADS
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
|
||||
gtk_set_locale();
|
||||
|
||||
#if wxUSE_WCHAR_T
|
||||
@@ -568,12 +565,17 @@ int wxEntry( int argc, char *argv[] )
|
||||
if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL;
|
||||
#endif
|
||||
|
||||
gdk_threads_enter();
|
||||
|
||||
gtk_init( &argc, &argv );
|
||||
|
||||
wxSetDetectableAutoRepeat( TRUE );
|
||||
|
||||
if (!wxApp::Initialize())
|
||||
{
|
||||
gdk_threads_leave();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
@@ -593,9 +595,10 @@ int wxEntry( int argc, char *argv[] )
|
||||
#if wxUSE_UNICODE
|
||||
wxTheApp->argv = new wxChar*[argc+1];
|
||||
int mb_argc = 0;
|
||||
while (mb_argc < argc) {
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
|
||||
mb_argc++;
|
||||
while (mb_argc < argc)
|
||||
{
|
||||
wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
|
||||
mb_argc++;
|
||||
}
|
||||
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
|
||||
#else
|
||||
@@ -668,6 +671,8 @@ int wxEntry( int argc, char *argv[] )
|
||||
|
||||
wxApp::CleanUp();
|
||||
|
||||
gdk_threads_leave();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
@@ -330,7 +330,7 @@ void wxTextCtrl::WriteText( const wxString &text )
|
||||
{
|
||||
/* this moves the cursor pos to behind the inserted text */
|
||||
gint len = GTK_EDITABLE(m_text)->current_pos;
|
||||
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
wxWX2MBbuf buf = text.mbc_str();
|
||||
gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &len );
|
||||
|
@@ -15,51 +15,6 @@
|
||||
#include "wx/timer.h"
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
/*
|
||||
#include "glib.h"
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
static GTimer *g_timer = (GTimer*) NULL;
|
||||
|
||||
void wxStartTimer()
|
||||
{
|
||||
if (g_timer)
|
||||
{
|
||||
g_timer_rest( g_timer );
|
||||
}
|
||||
else
|
||||
{
|
||||
g_timer = g_timer_new();
|
||||
g_timer_start( g_timer );
|
||||
}
|
||||
}
|
||||
|
||||
long wxGetElapsedTime( bool resetTimer )
|
||||
{
|
||||
gulong res = 0;
|
||||
if (g_timer)
|
||||
{
|
||||
g_timer_elapsed( g_timer, &res );
|
||||
if (resetTimer) g_timer_reset( g_timer );
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool wxGetLocalTime( long *timeZone, int *dstObserved )
|
||||
{
|
||||
}
|
||||
|
||||
long wxGetCurrentTime()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTimer
|
||||
@@ -71,19 +26,15 @@ static gint timeout_callback( gpointer data )
|
||||
{
|
||||
wxTimer *timer = (wxTimer*)data;
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
/* when getting called from GDK's timer handler we
|
||||
are no longer within GDK's grab on the GUI
|
||||
thread so we must lock it here ourselves */
|
||||
GDK_THREADS_ENTER ();
|
||||
#endif
|
||||
gdk_threads_enter();
|
||||
|
||||
timer->Notify();
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
/* release lock again */
|
||||
GDK_THREADS_LEAVE ();
|
||||
#endif
|
||||
gdk_threads_leave();
|
||||
|
||||
if ( timer->IsOneShot() )
|
||||
return FALSE;
|
||||
|
Reference in New Issue
Block a user