<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 20, 2016 at 11:11 PM Jonas Ådahl <<a href="mailto:jadahl@gmail.com">jadahl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the version of the source object is old enough to not have<br>
wl_data_source.set_actions() the current action would never be updated<br>
since source->set_actions would never be set.<br>
<br>
To fix this, instead of checking whether source->set_actions before<br>
proceeding with updating the current action, just always update the<br>
action when we know all parts are valid dnd data device objects.<br>
<br>
Signed-off-by: Jonas Ådahl <<a href="mailto:jadahl@gmail.com" target="_blank">jadahl@gmail.com</a>><br>
---<br>
 src/data-device.c | 22 ++++++++++++----------<br>
 1 file changed, 12 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/data-device.c b/src/data-device.c<br>
index 862a4e0..f04f030 100644<br>
--- a/src/data-device.c<br>
+++ b/src/data-device.c<br>
@@ -160,7 +160,7 @@ data_offer_update_action(struct weston_data_offer *offer)<br>
 {<br>
        uint32_t action;<br>
<br>
-       if (!offer->source || !offer->source->actions_set)<br>
+       if (!offer->source)<br>
                return;<br>
<br>
        action = data_offer_choose_action(offer);<br>
@@ -293,7 +293,7 @@ destroy_offer_data_source(struct wl_listener *listener, void *data)<br>
        offer->source = NULL;<br>
 }<br>
<br>
-static struct wl_resource *<br>
+static struct weston_data_offer *<br>
 weston_data_source_send_offer(struct weston_data_source *source,<br>
                              struct wl_resource *target)<br>
 {<br>
@@ -331,9 +331,8 @@ weston_data_source_send_offer(struct weston_data_source *source,<br>
<br>
        source->offer = offer;<br>
        source->accepted = false;<br>
-       data_offer_update_action(offer);<br>
<br>
-       return offer->resource;<br>
+       return offer;<br>
 }<br>
<br>
 static void<br>
@@ -533,11 +532,13 @@ weston_drag_set_focus(struct weston_drag *drag,<br>
<br>
        if (drag->data_source) {<br>
                drag->data_source->accepted = false;<br>
-               offer_resource = weston_data_source_send_offer(drag->data_source,<br>
-                                                              resource);<br>
-               if (offer_resource == NULL)<br>
+               offer = weston_data_source_send_offer(drag->data_source, resource);<br>
+               if (offer == NULL)<br>
                        return;<br>
<br>
+               data_offer_update_action(offer);<br>
+<br>
+               offer_resource = offer->resource;<br>
                if (wl_resource_get_version (offer_resource) >=<br>
                    WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {<br>
                        wl_data_offer_send_source_actions (offer_resource,<br>
@@ -1095,7 +1096,8 @@ destroy_selection_data_source(struct wl_listener *listener, void *data)<br>
 WL_EXPORT void<br>
 weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)<br>
 {<br>
-       struct wl_resource *data_device, *offer;<br>
+       struct weston_data_offer *offer;<br>
+       struct wl_resource *data_device;<br>
<br>
        wl_resource_for_each(data_device, &seat->drag_resource_list) {<br>
                if (wl_resource_get_client(data_device) != client)<br>
@@ -1103,8 +1105,8 @@ weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)<br>
<br>
                if (seat->selection_data_source) {<br>
                        offer = weston_data_source_send_offer(seat->selection_data_source,<br>
-                                                               data_device);<br>
-                       wl_data_device_send_selection(data_device, offer);<br>
+                                                             data_device);<br></blockquote><div><br></div><div><br></div><div>Trying to mix in whitespace changes to throw off your reviewers is certainly a valid strategy.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                       wl_data_device_send_selection(data_device, offer->resource);<br>
                } else {<br>
                        wl_data_device_send_selection(data_device, NULL);<br>
                }<br>
--<br>
2.5.5<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/wayland-devel</a></blockquote><div><br></div><div>Reviewed-By: Mike Blumenkrantz <<a href="mailto:zmike@osg.samsung.com">zmike@osg.samsung.com</a>> </div></div></div>