[PATCH 5/5] clients/dnd: use new data_device.set_surface protocol

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Fri Feb 10 08:31:38 PST 2012


---
 clients/dnd.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/clients/dnd.c b/clients/dnd.c
index b4a9c10..46f4710 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -55,6 +55,7 @@ struct dnd_drag {
 	int x_offset, y_offset;
 	const char *mime_type;
 
+	struct wl_surface *drag_surface;
 	struct wl_data_source *data_source;
 };
 
@@ -256,8 +257,7 @@ data_source_target(void *data,
 		surface = dnd_drag->translucent;
 
 	buffer = display_get_buffer_for_surface(dnd->display, surface);
-	wl_data_device_attach(device, dnd_drag->time, buffer,
-				  dnd_drag->hotspot_x, dnd_drag->hotspot_y);
+	wl_surface_attach(dnd_drag->drag_surface, buffer, 0, 0);
 }
 
 static void
@@ -289,7 +289,9 @@ data_source_cancelled(void *data, struct wl_data_source *source)
 	/* Destroy the item that has been dragged out */
 	cairo_surface_destroy(dnd_drag->item->surface);
 	free(dnd_drag->item);
-	
+
+	wl_surface_destroy(dnd_drag->drag_surface);
+
 	cairo_surface_destroy(dnd_drag->translucent);
 	cairo_surface_destroy(dnd_drag->opaque);
 	free(dnd_drag);
@@ -361,6 +363,7 @@ dnd_button_handler(struct widget *widget,
 	struct item *item;
 	struct rectangle allocation;
 	struct dnd_drag *dnd_drag;
+	struct wl_data_device *data_device;
 	int i;
 
 	widget_get_allocation(dnd->widget, &allocation);
@@ -406,6 +409,12 @@ dnd_button_handler(struct widget *widget,
 		dnd_drag->translucent =
 			create_drag_cursor(dnd_drag, item, x, y, 0.2);
 
+		data_device = input_get_data_device(input);
+		dnd_drag->drag_surface =
+			wl_data_device_set_surface(data_device,
+						   - dnd_drag->hotspot_x,
+						   - dnd_drag->hotspot_y);
+
 		window_schedule_redraw(dnd->window);
 	}
 }
-- 
1.7.4.1



More information about the wayland-devel mailing list