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:
Robert Roebling
1999-12-29 17:16:55 +00:00
parent e12be2f7fb
commit 924ef85080
12 changed files with 889 additions and 629 deletions
Vendored
+300 -279
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1493,7 +1493,7 @@ if test "$wxUSE_GTK" = 1; then
AM_PATH_GTK(1.2.1, WXGTK12=1, AC_MSG_ERROR(Is gtk-config in path and GTK+ is version 1.2.1 or above?))
TOOLKIT_INCLUDE="$GTK_CFLAGS"
GUI_TK_LIBRARY="$GTK_LIBS"
GUI_TK_LIBRARY="$GTK_LIBS -lgthread"
TOOLKIT=GTK
GUIOBJS="\$(GTK_GUIOBJS)"
+4
View File
@@ -436,6 +436,10 @@ public:
// for implementation code only: is the operation allowed?
bool IsAllowed() const { return m_bAllow; }
// probably useless: CopyObject() is used for deferred event
// handling but wxNotifyEvent must be processed immediately
void CopyObject(wxObject& obj) const;
private:
bool m_bAllow;
+468 -170
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -134,7 +134,7 @@ void MyThread::WriteText(const wxString& text)
msg << text;
m_frame->WriteText(msg);
wxMutexGuiLeave();
}
+31 -6
View File
@@ -173,10 +173,24 @@ void wxCommandEvent::CopyObject(wxObject& obj_d) const
wxEvent::CopyObject(obj_d);
obj->m_clientData = m_clientData;
obj->m_clientObject = m_clientObject;
obj->m_extraLong = m_extraLong;
obj->m_commandInt = m_commandInt;
obj->m_clientData = m_clientData;
obj->m_clientObject = m_clientObject;
obj->m_extraLong = m_extraLong;
obj->m_commandInt = m_commandInt;
obj->m_commandString = m_commandString;
}
/*
* Notify events
*/
void wxNotifyEvent::CopyObject(wxObject& obj_d) const
{
wxNotifyEvent *obj = (wxNotifyEvent *)&obj_d;
wxEvent::CopyObject(obj_d);
if (!m_bAllow) obj->Veto();
}
/*
@@ -380,6 +394,10 @@ void wxKeyEvent::CopyObject(wxObject& obj_d) const
wxKeyEvent *obj = (wxKeyEvent *)&obj_d;
wxEvent::CopyObject(obj_d);
obj->m_x = m_x;
obj->m_y = m_y;
obj->m_keyCode = m_keyCode;
obj->m_shiftDown = m_shiftDown;
obj->m_controlDown = m_controlDown;
obj->m_metaDown = m_metaDown;
@@ -685,11 +703,18 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
// An event handler can be enabled or disabled
if ( GetEvtHandlerEnabled() )
{
#if wxUSE_THREADS
#if 0
/*
What is this? When using GUI threads, a non main
threads can send an event and process it itself.
This breaks GTK's GUI threads, so please explain.
*/
// Check whether we are in a child thread.
if ( !wxThread::IsMain() )
return ProcessThreadEvent(event);
#endif // wxUSE_THREADS
#endif
// Handle per-instance dynamic event tables first
if ( m_dynamicEvents && SearchDynamicEventTable(event) )
+39 -34
View File
@@ -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;
}
+1 -1
View File
@@ -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 );
+2 -51
View File
@@ -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;
+39 -34
View File
@@ -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;
}
+1 -1
View File
@@ -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 );
+2 -51
View File
@@ -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;