[PATCH weston 3/6] data-device: Lookup drag resources using the focussed surface
Rob Bradford
robert.bradford at intel.com
Tue Aug 13 11:53:12 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 4bf6256..7de1f53 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -418,15 +418,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);
}
@@ -439,7 +438,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)
@@ -454,11 +453,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);
@@ -612,18 +610,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