From b453e1b24bfa07074b29f1599a731c0c58d731b0 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 30 Jul 1999 12:02:28 +0000 Subject: [PATCH] Doc corrections, made wxHTML a chapter GUI thread work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3211 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/clipbrd.tex | 21 +++++++++++----- docs/latex/wx/fs.tex | 30 +++++++++++------------ docs/latex/wx/manual.tex | 1 + docs/latex/wx/topics.tex | 1 - docs/latex/wx/txtstrm.tex | 20 ++++++++++------ docs/latex/wx/wxhtml.tex | 5 ++++ src/gtk/app.cpp | 33 ++++++++++++++++++-------- src/gtk/clipbrd.cpp | 38 ++++++++++++++++++++++++++++- src/gtk/dnd.cpp | 50 ++++++++++++++++++++++++++++++++++----- src/gtk1/app.cpp | 33 ++++++++++++++++++-------- src/gtk1/clipbrd.cpp | 38 ++++++++++++++++++++++++++++- src/gtk1/dnd.cpp | 50 ++++++++++++++++++++++++++++++++++----- 12 files changed, 257 insertions(+), 63 deletions(-) diff --git a/docs/latex/wx/clipbrd.tex b/docs/latex/wx/clipbrd.tex index dcab3d5fb1..151509e42d 100644 --- a/docs/latex/wx/clipbrd.tex +++ b/docs/latex/wx/clipbrd.tex @@ -26,11 +26,11 @@ For example: // 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(); } @@ -83,14 +83,14 @@ Call this function to close the clipboard, having opened it with \helpref{wxClip \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} -\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. @@ -114,3 +114,12 @@ Call this function to set the data object to the clipboard. This function will 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. + + diff --git a/docs/latex/wx/fs.tex b/docs/latex/wx/fs.tex index a183aa63a4..cf781071a5 100644 --- a/docs/latex/wx/fs.tex +++ b/docs/latex/wx/fs.tex @@ -1,24 +1,24 @@ \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 -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} -\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). -\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. -\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. @@ -29,16 +29,16 @@ overwrite OpenFile() and CanOpen() methods. 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. -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. -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} @@ -56,13 +56,13 @@ In this example, protocol is "zip", left location is 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) -which is at WWW. Enjoy it :-) +which is at WWW. \wxheading{File Systems Included in wxHTML} diff --git a/docs/latex/wx/manual.tex b/docs/latex/wx/manual.tex index 2d156ddd2b..db52b67158 100644 --- a/docs/latex/wx/manual.tex +++ b/docs/latex/wx/manual.tex @@ -97,6 +97,7 @@ licendoc.txt) for conditions of software and documentation use. \helpinput{classes.tex} \helpinput{category.tex} \helpinput{topics.tex} +\helpinput{wxhtml.tex} \helpinput{wxPython.tex} \begin{comment} diff --git a/docs/latex/wx/topics.tex b/docs/latex/wx/topics.tex index 3b222e349d..e5d0e6ac0b 100644 --- a/docs/latex/wx/topics.tex +++ b/docs/latex/wx/topics.tex @@ -44,4 +44,3 @@ This chapter contains a selection of topic overviews. \input tusage.tex \input ttips.tex \input fs.tex -\input wxhtml.tex diff --git a/docs/latex/wx/txtstrm.tex b/docs/latex/wx/txtstrm.tex index cf5f519a12..05d6b0a3bf 100644 --- a/docs/latex/wx/txtstrm.tex +++ b/docs/latex/wx/txtstrm.tex @@ -6,10 +6,15 @@ 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} + wxFileInputStream input( "mytext.txt" ); wxTextInputStream text( input ); wxUint8 i1; float f2; @@ -45,19 +50,19 @@ Destroys the wxTextInputStream object. \membersection{wxTextInputStream::Read8} -\func{unsigned char}{Read8}{\void} +\func{wxUint8}{Read8}{\void} 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} -\func{unsigned long}{Read32}{\void} +\func{wxUint16}{Read32}{\void} Reads a 32 bit integer from the stream. @@ -85,6 +90,7 @@ So, you can write \it{text} floats, integers. For example: \begin{verbatim} + wxFileOutputStream output( "mytext.txt" ); wxTextOutputStream text( output ); output << "This is a text line\n"; @@ -113,19 +119,19 @@ Destroys the wxTextOutputStream object. \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} -\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} -\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. diff --git a/docs/latex/wx/wxhtml.tex b/docs/latex/wx/wxhtml.tex index 268fab1966..2503b5e081 100644 --- a/docs/latex/wx/wxhtml.tex +++ b/docs/latex/wx/wxhtml.tex @@ -1,3 +1,8 @@ +\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. diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 17838772fb..c0ce494d7e 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -226,12 +226,29 @@ void wxapp_install_idle_handler() g_isIdle = FALSE; } -/* #if wxUSE_THREADS -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; +} + +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 @@ -254,12 +271,11 @@ static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) GDK_THREADS_LEAVE (); #endif - wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL ); + wxapp_install_thread_wakeup(); return TRUE; } #endif -*/ //----------------------------------------------------------------------------- // wxApp @@ -280,11 +296,10 @@ wxApp::wxApp() m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); -/* #if wxUSE_THREADS - m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL ); + m_wakeUpTimerTag = 0; + wxapp_install_thread_wakeup(); #endif -*/ m_colorCube = (unsigned char*) NULL; } @@ -293,11 +308,9 @@ wxApp::~wxApp() { if (m_idleTag) gtk_idle_remove( m_idleTag ); -/* #if wxUSE_THREADS - if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag ); + wxapp_uninstall_thread_wakeup(); #endif -*/ if (m_colorCube) free(m_colorCube); } diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index f4ed88753f..827e86ea22 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -21,6 +21,15 @@ #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 //----------------------------------------------------------------------------- @@ -386,9 +395,13 @@ void wxClipboard::Clear() { if (m_dataBroker) { +#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 */ - if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window) { m_waiting = TRUE; @@ -412,6 +425,11 @@ void wxClipboard::Clear() delete m_dataBroker; m_dataBroker = (wxDataBroker*) NULL; } + +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif } m_targetRequested = 0; @@ -494,11 +512,20 @@ bool wxClipboard::AddData( wxDataObject *data ) (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 )) { +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return FALSE; } m_ownsClipboard = TRUE; @@ -507,9 +534,18 @@ bool wxClipboard::AddData( wxDataObject *data ) GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME )) { +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return FALSE; } m_ownsPrimarySelection = TRUE; + +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return TRUE; } diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 289765439d..df6de3a991 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -35,6 +35,15 @@ 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 //---------------------------------------------------------------------------- @@ -363,12 +372,22 @@ bool wxDropTarget::RequestData( wxDataFormat format ) 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 ); +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif + return TRUE; } @@ -617,23 +636,32 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), 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) { -// 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 ); +#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 ); +#if wxUSE_THREADS + /* enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif free( buffer ); /* so far only copy, no moves. TODO. */ @@ -659,7 +687,7 @@ static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "Delete the data!\n" ); +// printf( "Delete the data!\n" ); drop_source->m_retValue = wxDragMove; } @@ -674,7 +702,7 @@ static void source_drag_begin( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "drag_begin.\n" ); +// printf( "drag_begin.\n" ); } //---------------------------------------------------------------------------- @@ -687,7 +715,7 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "drag_end.\n" ); +// printf( "drag_end.\n" ); drop_source->m_waiting = FALSE; } @@ -800,7 +828,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) 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 ); @@ -822,6 +850,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) 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) { @@ -846,6 +879,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) while (m_waiting) gtk_main_iteration();; } +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif + g_blockEventsOnDrag = FALSE; UnregisterWindow(); diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 17838772fb..c0ce494d7e 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -226,12 +226,29 @@ void wxapp_install_idle_handler() g_isIdle = FALSE; } -/* #if wxUSE_THREADS -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; +} + +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 @@ -254,12 +271,11 @@ static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) GDK_THREADS_LEAVE (); #endif - wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL ); + wxapp_install_thread_wakeup(); return TRUE; } #endif -*/ //----------------------------------------------------------------------------- // wxApp @@ -280,11 +296,10 @@ wxApp::wxApp() m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL ); -/* #if wxUSE_THREADS - m_wakeUpTimerTag = gtk_timeout_add( 20, wxapp_wakeup_timerout_callback, (gpointer) NULL ); + m_wakeUpTimerTag = 0; + wxapp_install_thread_wakeup(); #endif -*/ m_colorCube = (unsigned char*) NULL; } @@ -293,11 +308,9 @@ wxApp::~wxApp() { if (m_idleTag) gtk_idle_remove( m_idleTag ); -/* #if wxUSE_THREADS - if (m_wakeUpTimerTag) gtk_timeout_remove( m_wakeUpTimerTag ); + wxapp_uninstall_thread_wakeup(); #endif -*/ if (m_colorCube) free(m_colorCube); } diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp index f4ed88753f..827e86ea22 100644 --- a/src/gtk1/clipbrd.cpp +++ b/src/gtk1/clipbrd.cpp @@ -21,6 +21,15 @@ #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 //----------------------------------------------------------------------------- @@ -386,9 +395,13 @@ void wxClipboard::Clear() { if (m_dataBroker) { +#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 */ - if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window) { m_waiting = TRUE; @@ -412,6 +425,11 @@ void wxClipboard::Clear() delete m_dataBroker; m_dataBroker = (wxDataBroker*) NULL; } + +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif } m_targetRequested = 0; @@ -494,11 +512,20 @@ bool wxClipboard::AddData( wxDataObject *data ) (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 )) { +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return FALSE; } m_ownsClipboard = TRUE; @@ -507,9 +534,18 @@ bool wxClipboard::AddData( wxDataObject *data ) GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME )) { +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return FALSE; } m_ownsPrimarySelection = TRUE; + +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif return TRUE; } diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 289765439d..df6de3a991 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -35,6 +35,15 @@ 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 //---------------------------------------------------------------------------- @@ -363,12 +372,22 @@ bool wxDropTarget::RequestData( wxDataFormat format ) 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 ); +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif + return TRUE; } @@ -617,23 +636,32 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), 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) { -// 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 ); +#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 ); +#if wxUSE_THREADS + /* enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif free( buffer ); /* so far only copy, no moves. TODO. */ @@ -659,7 +687,7 @@ static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "Delete the data!\n" ); +// printf( "Delete the data!\n" ); drop_source->m_retValue = wxDragMove; } @@ -674,7 +702,7 @@ static void source_drag_begin( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "drag_begin.\n" ); +// printf( "drag_begin.\n" ); } //---------------------------------------------------------------------------- @@ -687,7 +715,7 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget), { if (g_isIdle) wxapp_install_idle_handler(); -// printf( "drag_end.\n" ); +// printf( "drag_end.\n" ); drop_source->m_waiting = FALSE; } @@ -800,7 +828,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) 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 ); @@ -822,6 +850,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) 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) { @@ -846,6 +879,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) while (m_waiting) gtk_main_iteration();; } +#if wxUSE_THREADS + /* re-enable GUI threads */ + wxapp_install_thread_wakeup(); +#endif + g_blockEventsOnDrag = FALSE; UnregisterWindow(); -- 2.45.2