made wxHTML a chapter
  GUI thread work
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3211 
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
12 files changed:
   // Read some text
   if (wxTheClipboard->Open())
   {
   // Read some text
   if (wxTheClipboard->Open())
   {
-    wxTextDataObject data;
-    if (wxTheClipboard->IsSupported(data))
+    if (wxTheClipboard->IsSupported( "STRING" ))
-      wxTheClipboard->GetData(data);
-      wxMessageBox(data.GetText());
+      wxTextDataObject data;
+      wxTheClipboard->GetData( &data );
+      wxMessageBox( data.GetText() );
     }  
     wxTheClipboard->Close();
   }
     }  
     wxTheClipboard->Close();
   }
 
 \membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
 
 
 \membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
 
-\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
+\func{bool}{GetData}{\param{wxDataObject*}{ data}}
 
 Call this function to fill {\it data} with data on the clipboard, if available in the required
 format. Returns TRUE on success.
 
 \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
 
 
 Call this function to fill {\it data} with data on the clipboard, if available in the required
 format. Returns TRUE on success.
 
 \membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
 
-\func{bool}{IsSupported}{\param{wxDataObject\&}{ data}}
+\func{bool}{IsSupported}{\param{wxDataFormat}{ format}}
 
 Returns TRUE if the format of the given data object is available on the clipboard.
 
 
 Returns TRUE if the format of the given data object is available on the clipboard.
 
 clear all previous contents in the clipboard, so calling it several times
 does not make any sense.
 
 clear all previous contents in the clipboard, so calling it several times
 does not make any sense.
 
+\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboaruseprimary}
+
+\func{void}{UsePrimarySelection}{\param(bool}{ primary = TRUE}
+
+On platforms supporting it (currently only GTK), selects the so called
+PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
+if primary is TRUE.
+
+
 
 \section{File Systems}\label{fs}
 
 \section{File Systems}\label{fs}
 
-The wxHTML library uses {\bf virtual file systems} mechanism
-similar to the one used in Midnight Commander or Dos Navigator or
+The wxHTML library uses a {\bf virtual file systems} mechanism
+similar to the one used in Midnight Commander, Dos Navigator,
 FAR or almost any modern file manager. (Do you remember? You can
 FAR or almost any modern file manager. (Do you remember? You can
-press enter on ZIP file and it's content is displayed like it's
-a directory...)
+press enter on ZIP file and its contents is displayed as if it
+were a local directory...)
 
 \wxheading{Classes}
 
 Three classes are used in order to provide full VFS:
 
 \begin{itemize}
 
 \wxheading{Classes}
 
 Three classes are used in order to provide full VFS:
 
 \begin{itemize}
-\item \helpref{wxFSFile}{wxfsfile} class provides information
+\item The \helpref{wxFSFile}{wxfsfile} class provides information
 on opened file (name, input stream, mime type and anchor).
 
 on opened file (name, input stream, mime type and anchor).
 
-\item \helpref{wxFileSystem}{wxfilesystem} class is interface.
-It's main methods are ChangePathTo() and OpenFile(). This class
+\item The \helpref{wxFileSystem}{wxfilesystem} class is the interface.
+Its main methods are ChangePathTo() and OpenFile(). This class
 is most often used by the end user.
 
 is most often used by the end user.
 
-\item \helpref{wxFileSystemHandler}{wxfilesystemhandler} is the core
+\item The \helpref{wxFileSystemHandler}{wxfilesystemhandler} is the core
 if VFS mechanism. You can derive your own handler and pass it to
 wxFileSystem's AddHandler() method. In the new handler you only need to
 overwrite OpenFile() and CanOpen() methods.
 if VFS mechanism. You can derive your own handler and pass it to
 wxFileSystem's AddHandler() method. In the new handler you only need to
 overwrite OpenFile() and CanOpen() methods.
 Locations (aka filenames aka addresses) are constructed from 4 parts:
 
 \begin{itemize}
 Locations (aka filenames aka addresses) are constructed from 4 parts:
 
 \begin{itemize}
-\item {\bf protocol} - handler can regonize if it is able to open some
-file by checking it's protocol. Examples are "http", "file" or "ftp"
+\item {\bf protocol} - handler can recognize if it is able to open a
+file by checking its protocol. Examples are "http", "file" or "ftp".
 
 \item {\bf right location} - is the name of file within the protocol.
 
 \item {\bf right location} - is the name of file within the protocol.
-In "http://www.wxwindows.org/index.html" the right location is "//www.wxwindows.org/index.html"
+In "http://www.wxwindows.org/index.html" the right location is "//www.wxwindows.org/index.html".
 
 \item {\bf anchor} - anchor is optional and is usually not present.
 
 \item {\bf anchor} - anchor is optional and is usually not present.
-In "index.htm\#chapter2" the anchor is "chapter2"
+In "index.htm\#chapter2" the anchor is "chapter2".
-\item {\bf left location} - this is usually empty string. 
+\item {\bf left location} - this is usually an empty string. 
 It is used by 'local' protocols such as ZIP.
 See Combined Protocols paragraph for details.
 \end{itemize}
 It is used by 'local' protocols such as ZIP.
 See Combined Protocols paragraph for details.
 \end{itemize}
 is "file:archives/cpp_doc.zip". It is used by zip handler
 to determine in what file this particular zip VFS is stored.
 
 is "file:archives/cpp_doc.zip". It is used by zip handler
 to determine in what file this particular zip VFS is stored.
 
-In fact there are two protocols used in this example : zip and file.
+In fact there are two protocols used in this example: zip and file.
 You can construct even more complicated addresses like this one:
 
 http://www.archives.org/myarchive.zip\#zip:local/docs/cpp/stdio.zip\#zip:index.htm
 
 In this example you access zip VFS stdio.zip stored in another zip (myarchive.zip)
 You can construct even more complicated addresses like this one:
 
 http://www.archives.org/myarchive.zip\#zip:local/docs/cpp/stdio.zip\#zip:index.htm
 
 In this example you access zip VFS stdio.zip stored in another zip (myarchive.zip)
-which is at WWW. Enjoy it :-)
 
 \wxheading{File Systems Included in wxHTML}
 
 
 \wxheading{File Systems Included in wxHTML}
 
 
 \helpinput{classes.tex}
 \helpinput{category.tex}
 \helpinput{topics.tex}
 \helpinput{classes.tex}
 \helpinput{category.tex}
 \helpinput{topics.tex}
 \helpinput{wxPython.tex}
 
 \begin{comment}
 \helpinput{wxPython.tex}
 
 \begin{comment}
 
 \input tusage.tex
 \input ttips.tex
 \input fs.tex
 \input tusage.tex
 \input ttips.tex
 \input fs.tex
 
 This class provides functions that read text datas using an input stream.
 So, you can read \it{text} floats, integers.
 
 This class provides functions that read text datas using an input stream.
 So, you can read \it{text} floats, integers.
 
-Operator >> is overloaded and you can use this class a C++ std-iostream.
+Operator >> is overloaded and you can use this class like a standard C++ iostream.
+Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc
+and on a typical 32-bit computer, none of these match to the "long" type (wxInt32
+is defined as int on 32-bit architectures) so that you cannot use long. To avoid
+problems (here and elsewhere), make use of the wxInt32, wxUint32, etc types.
 
 For example:
 \begin{verbatim}
 
 For example:
 \begin{verbatim}
+  wxFileInputStream input( "mytext.txt" );
   wxTextInputStream text( input );
   wxUint8 i1;
   float f2;
   wxTextInputStream text( input );
   wxUint8 i1;
   float f2;
 
 \membersection{wxTextInputStream::Read8}
 
 
 \membersection{wxTextInputStream::Read8}
 
-\func{unsigned char}{Read8}{\void}
+\func{wxUint8}{Read8}{\void}
 
 Reads a single byte from the stream.
 
 \membersection{wxTextInputStream::Read16}
 
 
 Reads a single byte from the stream.
 
 \membersection{wxTextInputStream::Read16}
 
-\func{unsigned short}{Read16}{\void}
+\func{wxUint16}{Read16}{\void}
 
 Reads a 16 bit integer from the stream.
 
 \membersection{wxTextInputStream::Read32}
 
 
 Reads a 16 bit integer from the stream.
 
 \membersection{wxTextInputStream::Read32}
 
-\func{unsigned long}{Read32}{\void}
+\func{wxUint16}{Read32}{\void}
 
 Reads a 32 bit integer from the stream.
 
 
 Reads a 32 bit integer from the stream.
 
 
 For example:
 \begin{verbatim}
 
 For example:
 \begin{verbatim}
+  wxFileOutputStream output( "mytext.txt" );
   wxTextOutputStream text( output );
 
   output << "This is a text line\n";
   wxTextOutputStream text( output );
 
   output << "This is a text line\n";
 
 \membersection{wxTextOutputStream::Write8}
 
 
 \membersection{wxTextOutputStream::Write8}
 
-\func{void}{wxTextOutputStream::Write8}{{\param unsigned char }{i8}}
+\func{void}{wxTextOutputStream::Write8}{{\param wxUint8 }{i8}}
 
 Writes the single byte {\it i8} to the stream.
 
 \membersection{wxTextOutputStream::Write16}
 
 
 Writes the single byte {\it i8} to the stream.
 
 \membersection{wxTextOutputStream::Write16}
 
-\func{void}{wxTextOutputStream::Write16}{{\param unsigned short }{i16}}
+\func{void}{wxTextOutputStream::Write16}{{\param wxUint16 }{i16}}
 
 Writes the 16 bit integer {\it i16} to the stream.
 
 \membersection{wxTextOutputStream::Write32}
 
 
 Writes the 16 bit integer {\it i16} to the stream.
 
 \membersection{wxTextOutputStream::Write32}
 
-\func{void}{wxTextOutputStream::Write32}{{\param unsigned long }{i32}}
+\func{void}{wxTextOutputStream::Write32}{{\param wxUint32 }{i32}}
 
 Writes the 32 bit integer {\it i32} to the stream.
 
 
 Writes the 32 bit integer {\it i32} to the stream.
 
 
+\chapter{wxHTML Notes}\label{wxHTML}
+\pagenumbering{arabic}%
+\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
+\setfooter{\thepage}{}{}{}{}{\thepage}%
+
 \section{wxHTML Sub-library Overview}\label{wxhtmloverview}
 
 This library provides classes for parsing and displaying HTML.
 \section{wxHTML Sub-library Overview}\label{wxhtmloverview}
 
 This library provides classes for parsing and displaying HTML.
 
-static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
+
+/* forward declaration */
+static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
+
+void wxapp_install_thread_wakeup()
+    if (wxTheApp->m_wakeUpTimerTag) return;
+    
+    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 100, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+}
+
+void wxapp_uninstall_thread_wakeup()
+{
+    if (!wxTheApp->m_wakeUpTimerTag) return;
+    
     gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
     wxTheApp->m_wakeUpTimerTag = 0;
     gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
     wxTheApp->m_wakeUpTimerTag = 0;
+}
+
+static 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
 
 #if (GTK_MINOR_VERSION > 0)
     // when getting called from GDK's time-out handler
     GDK_THREADS_LEAVE ();
 #endif
 
     GDK_THREADS_LEAVE ();
 #endif
 
-    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    wxapp_install_thread_wakeup();
 
 //-----------------------------------------------------------------------------
 // wxApp
 
 //-----------------------------------------------------------------------------
 // wxApp
 
     m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
 
     m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
-    m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    m_wakeUpTimerTag = 0;
+    wxapp_install_thread_wakeup();
 
     m_colorCube = (unsigned char*) NULL;
 }
 
     m_colorCube = (unsigned char*) NULL;
 }
 {
     if (m_idleTag) gtk_idle_remove( m_idleTag );
 
 {
     if (m_idleTag) gtk_idle_remove( m_idleTag );
 
-    if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag );
+    wxapp_uninstall_thread_wakeup();
 
     if (m_colorCube) free(m_colorCube);
 }
 
     if (m_colorCube) free(m_colorCube);
 }
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
+//-----------------------------------------------------------------------------
+// thread system
+//-----------------------------------------------------------------------------
+
+#if wxUSE_THREADS
+extern void wxapp_install_thread_wakeup();
+extern void wxapp_uninstall_thread_wakeup();
+#endif
+
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
+#if wxUSE_THREADS
+        /* disable GUI threads */
+        wxapp_uninstall_thread_wakeup();
+#endif
+    
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
         if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             m_waiting = TRUE;
         if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             m_waiting = TRUE;
            delete m_dataBroker;
            m_dataBroker = (wxDataBroker*) NULL;
        }
            delete m_dataBroker;
            m_dataBroker = (wxDataBroker*) NULL;
        }
+       
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
                               (gpointer) NULL );
 #endif
 
                               (gpointer) NULL );
 #endif
 
+#if wxUSE_THREADS
+        /* disable GUI threads */
+        wxapp_uninstall_thread_wakeup();
+#endif
+    
     /* Tell the world we offer clipboard data */
     if (!gtk_selection_owner_set( m_clipboardWidget, 
                                   g_clipboardAtom,
                                  GDK_CURRENT_TIME ))
     {
     /* Tell the world we offer clipboard data */
     if (!gtk_selection_owner_set( m_clipboardWidget, 
                                   g_clipboardAtom,
                                  GDK_CURRENT_TIME ))
     {
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
         return FALSE;
     }
     m_ownsClipboard = TRUE;
         return FALSE;
     }
     m_ownsClipboard = TRUE;
                                   GDK_SELECTION_PRIMARY,
                                  GDK_CURRENT_TIME ))
     {  
                                   GDK_SELECTION_PRIMARY,
                                  GDK_CURRENT_TIME ))
     {  
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
         return FALSE;
     }
     m_ownsPrimarySelection = TRUE;
         return FALSE;
     }
     m_ownsPrimarySelection = TRUE;
+    
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
 
 extern void wxapp_install_idle_handler();
 extern bool g_isIdle;
 
 extern void wxapp_install_idle_handler();
 extern bool g_isIdle;
 
+//-----------------------------------------------------------------------------
+// thread system
+//-----------------------------------------------------------------------------
+
+#if wxUSE_THREADS
+extern void wxapp_install_thread_wakeup();
+extern void wxapp_uninstall_thread_wakeup();
+#endif
+
 //----------------------------------------------------------------------------
 // global data
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 // global data
 //----------------------------------------------------------------------------
     if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") );
 */
 
     if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") );
 */
 
+#if wxUSE_THREADS
+    /* disable GUI threads */
+    wxapp_uninstall_thread_wakeup();
+#endif
+
     /* this should trigger an "drag_data_received" event */
     gtk_drag_get_data( m_dragWidget,
                        m_dragContext,
                        format.GetAtom(),
                        m_dragTime );
 
     /* this should trigger an "drag_data_received" event */
     gtk_drag_get_data( m_dragWidget,
                        m_dragContext,
                        format.GetAtom(),
                        m_dragTime );
 
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
+
         wxDataObject *data_object = (wxDataObject*) node->Data();
         if (data_object->GetFormat().GetAtom() == selection_data->target)
         {
         wxDataObject *data_object = (wxDataObject*) node->Data();
         if (data_object->GetFormat().GetAtom() == selection_data->target)
         {
-//            printf( "format found.\n" );
+//          printf( "format found.\n" );
 
             size_t data_size = data_object->GetSize();
 
             if (data_size > 0)
             {
 
             size_t data_size = data_object->GetSize();
 
             if (data_size > 0)
             {
-//                printf( "data size: %d.\n", (int)data_size );
+//              printf( "data size: %d.\n", (int)data_size );
 
                 guchar *buffer = new guchar[data_size];
                 data_object->WriteData( buffer );
 
 
                 guchar *buffer = new guchar[data_size];
                 data_object->WriteData( buffer );
 
+#if wxUSE_THREADS
+                /* disable GUI threads */
+                wxapp_uninstall_thread_wakeup();
+#endif
+    
                 gtk_selection_data_set( selection_data,
                                         selection_data->target,
                                         8,   // 8-bit
                                         buffer,
                                         data_size );
 
                 gtk_selection_data_set( selection_data,
                                         selection_data->target,
                                         8,   // 8-bit
                                         buffer,
                                         data_size );
 
+#if wxUSE_THREADS
+                /* enable GUI threads */
+                wxapp_install_thread_wakeup();
+#endif
                 free( buffer );
 
                 /* so far only copy, no moves. TODO. */
                 free( buffer );
 
                 /* so far only copy, no moves. TODO. */
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "Delete the data!\n" );
+//  printf( "Delete the data!\n" );
 
     drop_source->m_retValue = wxDragMove;
 }
 
     drop_source->m_retValue = wxDragMove;
 }
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "drag_begin.\n" );
+//  printf( "drag_begin.\n" );
 }
 
 //----------------------------------------------------------------------------
 }
 
 //----------------------------------------------------------------------------
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "drag_end.\n" );
+//  printf( "drag_end.\n" );
 
     drop_source->m_waiting = FALSE;
 }
 
     drop_source->m_waiting = FALSE;
 }
     m_waiting = TRUE;
 
     GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
     m_waiting = TRUE;
 
     GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
-//    wxPrintf( _T("atom id: %d.\n"), (int)atom );
+//    printf( "atom id: %d.\n", (int)atom );
 
     GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
     gtk_target_list_add( target_list, atom, 0, 0 );
 
     GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
     gtk_target_list_add( target_list, atom, 0, 0 );
     else if (event.state & GDK_BUTTON2_MASK) button_number = 2;
     else if (event.state & GDK_BUTTON3_MASK) button_number = 3;
 
     else if (event.state & GDK_BUTTON2_MASK) button_number = 2;
     else if (event.state & GDK_BUTTON3_MASK) button_number = 3;
 
+#if wxUSE_THREADS
+    /* disable GUI threads */
+    wxapp_uninstall_thread_wakeup();
+#endif
+    
     /* don't start dragging if no button is down */
     if (button_number)
     {
     /* don't start dragging if no button is down */
     if (button_number)
     {
         while (m_waiting) gtk_main_iteration();;
     }
 
         while (m_waiting) gtk_main_iteration();;
     }
 
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
+    
     g_blockEventsOnDrag = FALSE;
 
     UnregisterWindow();
     g_blockEventsOnDrag = FALSE;
 
     UnregisterWindow();
 
-static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
+
+/* forward declaration */
+static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
+
+void wxapp_install_thread_wakeup()
+    if (wxTheApp->m_wakeUpTimerTag) return;
+    
+    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 100, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+}
+
+void wxapp_uninstall_thread_wakeup()
+{
+    if (!wxTheApp->m_wakeUpTimerTag) return;
+    
     gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
     wxTheApp->m_wakeUpTimerTag = 0;
     gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
     wxTheApp->m_wakeUpTimerTag = 0;
+}
+
+static 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
 
 #if (GTK_MINOR_VERSION > 0)
     // when getting called from GDK's time-out handler
     GDK_THREADS_LEAVE ();
 #endif
 
     GDK_THREADS_LEAVE ();
 #endif
 
-    wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    wxapp_install_thread_wakeup();
 
 //-----------------------------------------------------------------------------
 // wxApp
 
 //-----------------------------------------------------------------------------
 // wxApp
 
     m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
 
     m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
 
-    m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+    m_wakeUpTimerTag = 0;
+    wxapp_install_thread_wakeup();
 
     m_colorCube = (unsigned char*) NULL;
 }
 
     m_colorCube = (unsigned char*) NULL;
 }
 {
     if (m_idleTag) gtk_idle_remove( m_idleTag );
 
 {
     if (m_idleTag) gtk_idle_remove( m_idleTag );
 
-    if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag );
+    wxapp_uninstall_thread_wakeup();
 
     if (m_colorCube) free(m_colorCube);
 }
 
     if (m_colorCube) free(m_colorCube);
 }
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
 #include "gdk/gdk.h"
 #include "gtk/gtk.h"
 
+//-----------------------------------------------------------------------------
+// thread system
+//-----------------------------------------------------------------------------
+
+#if wxUSE_THREADS
+extern void wxapp_install_thread_wakeup();
+extern void wxapp_uninstall_thread_wakeup();
+#endif
+
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // data
 //-----------------------------------------------------------------------------
+#if wxUSE_THREADS
+        /* disable GUI threads */
+        wxapp_uninstall_thread_wakeup();
+#endif
+    
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
         /*  As we have data we also own the clipboard. Once we no longer own
             it, clear_selection is called which will set m_data to zero */
         if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             m_waiting = TRUE;
         if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window)
         {
             m_waiting = TRUE;
            delete m_dataBroker;
            m_dataBroker = (wxDataBroker*) NULL;
        }
            delete m_dataBroker;
            m_dataBroker = (wxDataBroker*) NULL;
        }
+       
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
                               (gpointer) NULL );
 #endif
 
                               (gpointer) NULL );
 #endif
 
+#if wxUSE_THREADS
+        /* disable GUI threads */
+        wxapp_uninstall_thread_wakeup();
+#endif
+    
     /* Tell the world we offer clipboard data */
     if (!gtk_selection_owner_set( m_clipboardWidget, 
                                   g_clipboardAtom,
                                  GDK_CURRENT_TIME ))
     {
     /* Tell the world we offer clipboard data */
     if (!gtk_selection_owner_set( m_clipboardWidget, 
                                   g_clipboardAtom,
                                  GDK_CURRENT_TIME ))
     {
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
         return FALSE;
     }
     m_ownsClipboard = TRUE;
         return FALSE;
     }
     m_ownsClipboard = TRUE;
                                   GDK_SELECTION_PRIMARY,
                                  GDK_CURRENT_TIME ))
     {  
                                   GDK_SELECTION_PRIMARY,
                                  GDK_CURRENT_TIME ))
     {  
+#if wxUSE_THREADS
+        /* re-enable GUI threads */
+        wxapp_install_thread_wakeup();
+#endif
         return FALSE;
     }
     m_ownsPrimarySelection = TRUE;
         return FALSE;
     }
     m_ownsPrimarySelection = TRUE;
+    
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
 
 extern void wxapp_install_idle_handler();
 extern bool g_isIdle;
 
 extern void wxapp_install_idle_handler();
 extern bool g_isIdle;
 
+//-----------------------------------------------------------------------------
+// thread system
+//-----------------------------------------------------------------------------
+
+#if wxUSE_THREADS
+extern void wxapp_install_thread_wakeup();
+extern void wxapp_uninstall_thread_wakeup();
+#endif
+
 //----------------------------------------------------------------------------
 // global data
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 // global data
 //----------------------------------------------------------------------------
     if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") );
 */
 
     if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") );
 */
 
+#if wxUSE_THREADS
+    /* disable GUI threads */
+    wxapp_uninstall_thread_wakeup();
+#endif
+
     /* this should trigger an "drag_data_received" event */
     gtk_drag_get_data( m_dragWidget,
                        m_dragContext,
                        format.GetAtom(),
                        m_dragTime );
 
     /* this should trigger an "drag_data_received" event */
     gtk_drag_get_data( m_dragWidget,
                        m_dragContext,
                        format.GetAtom(),
                        m_dragTime );
 
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
+
         wxDataObject *data_object = (wxDataObject*) node->Data();
         if (data_object->GetFormat().GetAtom() == selection_data->target)
         {
         wxDataObject *data_object = (wxDataObject*) node->Data();
         if (data_object->GetFormat().GetAtom() == selection_data->target)
         {
-//            printf( "format found.\n" );
+//          printf( "format found.\n" );
 
             size_t data_size = data_object->GetSize();
 
             if (data_size > 0)
             {
 
             size_t data_size = data_object->GetSize();
 
             if (data_size > 0)
             {
-//                printf( "data size: %d.\n", (int)data_size );
+//              printf( "data size: %d.\n", (int)data_size );
 
                 guchar *buffer = new guchar[data_size];
                 data_object->WriteData( buffer );
 
 
                 guchar *buffer = new guchar[data_size];
                 data_object->WriteData( buffer );
 
+#if wxUSE_THREADS
+                /* disable GUI threads */
+                wxapp_uninstall_thread_wakeup();
+#endif
+    
                 gtk_selection_data_set( selection_data,
                                         selection_data->target,
                                         8,   // 8-bit
                                         buffer,
                                         data_size );
 
                 gtk_selection_data_set( selection_data,
                                         selection_data->target,
                                         8,   // 8-bit
                                         buffer,
                                         data_size );
 
+#if wxUSE_THREADS
+                /* enable GUI threads */
+                wxapp_install_thread_wakeup();
+#endif
                 free( buffer );
 
                 /* so far only copy, no moves. TODO. */
                 free( buffer );
 
                 /* so far only copy, no moves. TODO. */
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "Delete the data!\n" );
+//  printf( "Delete the data!\n" );
 
     drop_source->m_retValue = wxDragMove;
 }
 
     drop_source->m_retValue = wxDragMove;
 }
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "drag_begin.\n" );
+//  printf( "drag_begin.\n" );
 }
 
 //----------------------------------------------------------------------------
 }
 
 //----------------------------------------------------------------------------
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "drag_end.\n" );
+//  printf( "drag_end.\n" );
 
     drop_source->m_waiting = FALSE;
 }
 
     drop_source->m_waiting = FALSE;
 }
     m_waiting = TRUE;
 
     GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
     m_waiting = TRUE;
 
     GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
-//    wxPrintf( _T("atom id: %d.\n"), (int)atom );
+//    printf( "atom id: %d.\n", (int)atom );
 
     GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
     gtk_target_list_add( target_list, atom, 0, 0 );
 
     GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
     gtk_target_list_add( target_list, atom, 0, 0 );
     else if (event.state & GDK_BUTTON2_MASK) button_number = 2;
     else if (event.state & GDK_BUTTON3_MASK) button_number = 3;
 
     else if (event.state & GDK_BUTTON2_MASK) button_number = 2;
     else if (event.state & GDK_BUTTON3_MASK) button_number = 3;
 
+#if wxUSE_THREADS
+    /* disable GUI threads */
+    wxapp_uninstall_thread_wakeup();
+#endif
+    
     /* don't start dragging if no button is down */
     if (button_number)
     {
     /* don't start dragging if no button is down */
     if (button_number)
     {
         while (m_waiting) gtk_main_iteration();;
     }
 
         while (m_waiting) gtk_main_iteration();;
     }
 
+#if wxUSE_THREADS
+    /* re-enable GUI threads */
+    wxapp_install_thread_wakeup();
+#endif
+    
     g_blockEventsOnDrag = FALSE;
 
     UnregisterWindow();
     g_blockEventsOnDrag = FALSE;
 
     UnregisterWindow();