[gtk+/wip/matthiasc/no-unmanaged-dnd] Handle rootwin drop in gdk



commit 67cd81dbdd636e445d40f1f69276fc1607d594da
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 23 23:55:06 2017 -0400

    Handle rootwin drop in gdk
    
    This lets us drop the only use of the drag protocol in gtk.

 gdk/x11/gdkdnd-x11.c |   27 ++++++++++++++++++++++++-
 gtk/gtkdnd.c         |   54 +++++++------------------------------------------
 2 files changed, 34 insertions(+), 47 deletions(-)
---
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 6841d0a..b36965a 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -2398,7 +2398,32 @@ gdk_x11_drag_context_drag_drop (GdkDragContext *context,
           break;
 
         case GDK_DRAG_PROTO_ROOTWIN:
-          g_warning ("Drops for GDK_DRAG_PROTO_ROOTWIN must be handled internally");
+          {
+            GdkEvent *temp_event;
+            /* GTK+ traditionally has used application/x-rootwin-drop,
+             * but the XDND spec specifies x-rootwindow-drop.
+             */
+            GdkAtom target1 = gdk_atom_intern_static_string ("application/x-rootwindow-drop");
+            GdkAtom target2 = gdk_atom_intern_static_string ("application/x-rootwin-drop");
+
+g_print ("in root window drop case\n");
+            if (g_list_find (context->targets, GDK_ATOM_TO_POINTER (target1)) ||
+                g_list_find (context->targets, GDK_ATOM_TO_POINTER (target2)))
+              {
+                temp_event = gdk_event_new (GDK_SELECTION_REQUEST);
+                temp_event->selection.window = g_object_ref (context->source_window);
+                temp_event->selection.send_event = FALSE;
+                temp_event->selection.selection = gdk_atom_intern_static_string ("XdndSelection");
+                temp_event->selection.target = target1;
+                temp_event->selection.property = GDK_NONE;
+                temp_event->selection.requestor = g_object_ref (context->source_window);
+                gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
+
+g_print ("putting in selection request\n");
+                gdk_event_put (temp_event);
+                gdk_event_free (temp_event);
+              }
+          }
           break;
         case GDK_DRAG_PROTO_NONE:
           g_warning ("GDK_DRAG_PROTO_NONE is not valid in gdk_drag_drop()");
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 13cbe71..f5cb409 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -1537,52 +1537,14 @@ static void
 gtk_drag_drop (GtkDragSourceInfo *info, 
                guint32            time)
 {
-  if (gdk_drag_context_get_protocol (info->context) == GDK_DRAG_PROTO_ROOTWIN)
-    {
-      GtkSelectionData selection_data;
-      GList *tmp_list;
-      /* GTK+ traditionally has used application/x-rootwin-drop, but the
-       * XDND spec specifies x-rootwindow-drop.
-       */
-      GdkAtom target1 = gdk_atom_intern_static_string ("application/x-rootwindow-drop");
-      GdkAtom target2 = gdk_atom_intern_static_string ("application/x-rootwin-drop");
-      
-      tmp_list = info->target_list->list;
-      while (tmp_list)
-        {
-          GtkTargetPair *pair = tmp_list->data;
-          
-          if (pair->target == target1 || pair->target == target2)
-            {
-              selection_data.selection = GDK_NONE;
-              selection_data.target = pair->target;
-              selection_data.data = NULL;
-              selection_data.length = -1;
-
-              g_signal_emit_by_name (info->widget, "drag-data-get",
-                                     info->context, &selection_data,
-                                     pair->info,
-                                     time);
-
-              /* FIXME: Should we check for length >= 0 here? */
-              gtk_drag_drop_finished (info, GTK_DRAG_RESULT_SUCCESS, time);
-              return;
-            }
-          tmp_list = tmp_list->next;
-        }
-      gtk_drag_drop_finished (info, GTK_DRAG_RESULT_NO_TARGET, time);
-    }
-  else
-    {
-      if (info->icon_window)
-        gtk_widget_hide (info->icon_window);
-
-      gdk_drag_drop (info->context, time);
-      info->drop_timeout = gdk_threads_add_timeout (DROP_ABORT_TIME,
-                                          gtk_drag_abort_timeout,
-                                          info);
-      g_source_set_name_by_id (info->drop_timeout, "[gtk+] gtk_drag_abort_timeout");
-    }
+  if (info->icon_window)
+    gtk_widget_hide (info->icon_window);
+
+  gdk_drag_drop (info->context, time);
+  info->drop_timeout = gdk_threads_add_timeout (DROP_ABORT_TIME,
+                                                gtk_drag_abort_timeout,
+                                                info);
+  g_source_set_name_by_id (info->drop_timeout, "[gtk+] gtk_drag_abort_timeout");
 }
 
 /*


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