[PATCH weston 3/4] data-device: Lookup drag resources using the focussed surface

Rob Bradford robert.bradford at intel.com
Fri Sep 6 09:48:21 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

Rather than relying on focussed resource to get the client to lookup the
drag resource with instead derive the client from the focussed surface.

This is equivalent as the focussed resource is derived from the focussed
surface in the weston_keyboard_set_focus function.
---
 src/data-device.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/data-device.c b/src/data-device.c
index 1eb1925..e062875 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -421,15 +421,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data)
 	struct weston_seat *seat = container_of(listener, struct weston_seat,
 						selection_data_source_listener);
 	struct wl_resource *data_device;
-	struct wl_resource *focus = NULL;
+	struct wl_client *client;
 
 	seat->selection_data_source = NULL;
 
-	if (seat->keyboard)
-		focus = seat->keyboard->focus_resource;
-	if (focus) {
+	if (seat->keyboard && seat->keyboard->focus) {
+		client = wl_resource_get_client(seat->keyboard->focus->resource);
 		data_device = wl_resource_find_for_client(&seat->drag_resource_list,
-							  wl_resource_get_client(focus));
+							  client);
 		if (data_device)
 			wl_data_device_send_selection(data_device, NULL);
 	}
@@ -442,7 +441,7 @@ weston_seat_set_selection(struct weston_seat *seat,
 			  struct weston_data_source *source, uint32_t serial)
 {
 	struct wl_resource *data_device, *offer;
-	struct wl_resource *focus = NULL;
+	struct wl_client *client;
 
 	if (seat->selection_data_source &&
 	    seat->selection_serial - serial < UINT32_MAX / 2)
@@ -457,11 +456,10 @@ weston_seat_set_selection(struct weston_seat *seat,
 	seat->selection_data_source = source;
 	seat->selection_serial = serial;
 
-	if (seat->keyboard)
-		focus = seat->keyboard->focus_resource;
-	if (focus) {
+	if (seat->keyboard && seat->keyboard->focus) {
+		client = wl_resource_get_client(seat->keyboard->focus->resource);
 		data_device = wl_resource_find_for_client(&seat->drag_resource_list,
-							  wl_resource_get_client(focus));
+							  client);
 		if (data_device && source) {
 			offer = weston_data_source_send_offer(seat->selection_data_source,
 							      data_device);
@@ -615,18 +613,19 @@ bind_manager(struct wl_client *client,
 WL_EXPORT void
 wl_data_device_set_keyboard_focus(struct weston_seat *seat)
 {
-	struct wl_resource *data_device, *focus, *offer;
+	struct wl_resource *data_device = NULL, *offer;
 	struct weston_data_source *source;
+	struct wl_client *client;
 
 	if (!seat->keyboard)
 		return;
 
-	focus = seat->keyboard->focus_resource;
-	if (!focus)
-		return;
+	if (seat->keyboard && seat->keyboard->focus) {
+		client = wl_resource_get_client(seat->keyboard->focus->resource);
+		data_device = wl_resource_find_for_client(&seat->drag_resource_list,
+							  client);
+	}
 
-	data_device = wl_resource_find_for_client(&seat->drag_resource_list,
-						  wl_resource_get_client(focus));
 	if (!data_device)
 		return;
 
-- 
1.8.3.1



More information about the wayland-devel mailing list