Handle rootwin drop in gdk

This lets us drop the only use of the drag protocol in gtk.
This commit is contained in:
Matthias Clasen
2017-08-23 23:55:06 -04:00
parent a61aeb389d
commit fa7f48cbfd
2 changed files with 31 additions and 46 deletions

View File

@@ -2396,7 +2396,30 @@ 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");
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));
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()");

View File

@@ -1536,43 +1536,6 @@ gtk_drag_source_release_selections (GtkDragSourceInfo *info,
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);
@@ -1583,7 +1546,6 @@ gtk_drag_drop (GtkDragSourceInfo *info,
info);
g_source_set_name_by_id (info->drop_timeout, "[gtk+] gtk_drag_abort_timeout");
}
}
/*
* Source side callbacks.