X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a126fcc3438c6b2693090e8c97761fa12d8ca7a..c127177f8dc31dbe99764852b8dbcc047d3ad826:/src/gtk/dnd.cpp diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 225318a235..7bef3e8f1c 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -273,6 +273,8 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), qualifies for junk */ gtk_drag_finish (context, FALSE, FALSE, time); +// printf( "no data.\n" ); + return; } @@ -340,6 +342,12 @@ bool wxDropTarget::RequestData( wxDataFormat format ) if (!m_dragContext) return FALSE; if (!m_dragWidget) return FALSE; +/* + wxPrintf( _T("format: %s.\n"), format.GetId().c_str() ); + if (format.GetType() == wxDF_PRIVATE) wxPrintf( _T("private data.\n") ); + if (format.GetType() == wxDF_TEXT) wxPrintf( _T("text data.\n") ); +*/ + /* this should trigger an "drag_data_received" event */ gtk_drag_get_data( m_dragWidget, m_dragContext, @@ -470,7 +478,7 @@ bool wxTextDropTarget::OnData( int x, int y ) wxTextDataObject data; if (!GetData( &data )) return FALSE; - OnDropText( x, y, data.GetText().mbc_str() ); + OnDropText( x, y, data.GetText() ); return TRUE; } @@ -581,6 +589,8 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropSource *drop_source ) { +// printf( "Provide data!\n" ); + // char *name = gdk_atom_name( selection_data->target ); // if (name) printf( "Format requested: %s.\n", name ); @@ -590,15 +600,20 @@ 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" ); + size_t data_size = data_object->GetSize(); + if (data_size > 0) { +// printf( "data size: %d.\n", (int)data_size ); + guchar *buffer = new guchar[data_size]; data_object->WriteData( buffer ); gtk_selection_data_set( selection_data, selection_data->target, - 8, /* 8-bit */ + 8, // 8-bit buffer, data_size ); @@ -761,8 +776,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) m_waiting = TRUE; + GdkAtom atom = gdk_atom_intern( "STRING", FALSE ); +// wxPrintf( _T("atom id: %d.\n"), (int)atom ); + GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 ); - gtk_target_list_add( target_list, gdk_atom_intern( "STRING", FALSE ), 0, 0 ); + gtk_target_list_add( target_list, atom, 0, 0 ); GdkEventMotion event; event.window = m_widget->window; @@ -773,6 +791,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) event.x = x; event.y = y; event.state = state; + event.time = GDK_CURRENT_TIME; /* GTK wants to know which button was pressed which caused the dragging */ int button_number = 0; @@ -801,9 +820,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) 0, 0 ); - gdk_flush(); - - while (m_waiting) wxYield(); + while (m_waiting) gtk_main_iteration();; } g_blockEventsOnDrag = FALSE;