[gtk/wip/carlosg/ensure-selection-notify: 1/2] gdk/wayland: Emit GDK_SELECTION_NOTIFY on all failure/unset paths



commit f43f6900c93cc59092cff3f3d771c1fba92ae2e1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 20 23:04:01 2019 +0200

    gdk/wayland: Emit GDK_SELECTION_NOTIFY on all failure/unset paths
    
    Either on failure, or when replacing a selection buffer due to a new
    wl_offer. We should emit one event for each pending requestor then.

 gdk/wayland/gdkselection-wayland.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index 12737d672e..973f90cff3 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -114,6 +114,9 @@ struct _GdkWaylandSelection
 static void selection_buffer_read (SelectionBuffer *buffer);
 static void async_write_data_write (AsyncWriteData *write_data);
 static void emit_selection_clear (GdkDisplay *display, GdkAtom selection);
+static void emit_empty_selection_notify (GdkWindow *requestor,
+                                         GdkAtom    selection,
+                                         GdkAtom    target);
 
 static void
 selection_buffer_notify (SelectionBuffer *buffer)
@@ -168,11 +171,22 @@ selection_buffer_ref (SelectionBuffer *buffer)
 static void
 selection_buffer_unref (SelectionBuffer *buffer_data)
 {
+  GList *l;
+
   buffer_data->ref_count--;
 
   if (buffer_data->ref_count != 0)
     return;
 
+  for (l = buffer_data->requestors; l; l = l->next)
+    {
+      emit_empty_selection_notify (l->data, buffer_data->selection,
+                                   buffer_data->target);
+    }
+
+  g_list_free (buffer_data->requestors);
+  buffer_data->requestors = NULL;
+
   if (buffer_data->cancellable)
     g_object_unref (buffer_data->cancellable);
 
@@ -1313,7 +1327,10 @@ _gdk_wayland_display_convert_selection (GdkDisplay *display,
 
   selection_data = selection_lookup_offer_by_atom (wayland_selection, selection);
   if (!selection_data)
-    return;
+    {
+      emit_empty_selection_notify (requestor, selection, target);
+      return;
+    }
 
   offer = gdk_wayland_selection_get_offer (display, selection);
   target_list = gdk_wayland_selection_get_targets (display, selection);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]