X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/439c7eae9b77cc6c0414ccae52e688d626c86851..9cb80f3fa331228864ebc13188a0168da36a4998:/src/gtk/clipbrd.cpp diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 8276951829..f963bdd6ae 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -75,10 +75,11 @@ public: ~wxClipboardSync() { +#if wxUSE_CONSOLE_EVENTLOOP // ensure that there is a running event loop: this might not be the // case if we're called before the main event loop startup wxEventLoopGuarantor ensureEventLoop; - +#endif while (ms_clipboard) wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_CLIPBOARD); } @@ -261,7 +262,7 @@ selection_handler( GtkWidget *WXUNUSED(widget), if ( !clipboard ) return; - wxDataObject * const data = clipboard->GTKGetDataObject(); + wxDataObject * const data = clipboard->GTKGetDataObject(selection_data->selection); if ( !data ) return; @@ -485,11 +486,7 @@ GdkAtom wxClipboard::GTKGetClipboardAtom() const void wxClipboard::GTKClearData(Kind kind) { wxDataObject *&data = Data(kind); - if ( data ) - { - delete data; - data = NULL; - } + wxDELETE(data); } bool wxClipboard::SetSelectionOwner(bool set) @@ -674,10 +671,11 @@ bool wxClipboard::GetData( wxDataObject& data ) { wxCHECK_MSG( m_open, false, wxT("clipboard not open") ); - // get all supported formats from wxDataObjects - const size_t count = data.GetFormatCount(); + // get all supported formats from wxDataObjects: notice that we are setting + // the object data, so we need them in "Set" direction + const size_t count = data.GetFormatCount(wxDataObject::Set); wxDataFormatArray formats(new wxDataFormat[count]); - data.GetAllFormats(formats.get()); + data.GetAllFormats(formats.get(), wxDataObject::Set); for ( size_t i = 0; i < count; i++ ) { @@ -731,4 +729,27 @@ bool wxClipboard::GetData( wxDataObject& data ) return false; } +wxDataObject* wxClipboard::GTKGetDataObject( GdkAtom atom ) +{ + if ( atom == GDK_NONE ) + return Data(); + + if ( atom == GDK_SELECTION_PRIMARY ) + { + wxLogTrace(TRACE_CLIPBOARD, wxT("Primary selection requested" )); + + return Data( wxClipboard::Primary ); + } + else if ( atom == g_clipboardAtom ) + { + wxLogTrace(TRACE_CLIPBOARD, wxT("Clipboard data requested" )); + + return Data( wxClipboard::Clipboard ); + } + else // some other selection, we're not concerned + { + return (wxDataObject*)NULL; + } +} + #endif // wxUSE_CLIPBOARD