data_device: Send dnd finish when destroying data_offer 20/280020/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 17 Aug 2022 05:59:50 +0000 (14:59 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 22 Aug 2022 09:08:16 +0000 (18:08 +0900)
Change-Id: I92ce0690b8dae6178c96cefd702b178e6fc7e610

src/data_device/data_offer.c

index 7139308..b8fd0ad 100644 (file)
@@ -97,7 +97,23 @@ void
 data_offer_destroy(struct ds_data_offer *offer)
 {
     wl_list_remove(&offer->link);
-    wl_list_remove(&offer->source_destroy.link);
+
+    if (offer->source) {
+        wl_list_remove(&offer->source_destroy.link);
+
+        // If the drag destination has version < 3, wl_data_offer.finish
+        // won't be called, so do this here as a safety net, because
+        // we still want the version >= 3 drag source to be happy.
+        if (offer->type == DS_DATA_OFFER_DRAG) {
+            if (wl_resource_get_version(offer->resource) <
+                    WL_DATA_OFFER_ACTION_SINCE_VERSION) {
+                data_offer_source_dnd_finish(offer);
+            }
+            else if (offer->source->iface->dnd_finish) {
+                ds_data_source_destroy(offer->source);
+            }
+        }
+    }
 
     wl_resource_set_user_data(offer->resource, NULL);