mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
dnd: Get rid of IPC widgets
Instead, pass the source window to gdk_drag_begin(). Also make Wayland use this window instead of the one under the pointer (though those 2 Windows are most likely the same anyway).
This commit is contained in:
parent
3438dcdd4e
commit
f824439137
@ -534,7 +534,6 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
|||||||
GdkWaylandDragContext *context_wayland;
|
GdkWaylandDragContext *context_wayland;
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
GdkWaylandDisplay *display_wayland;
|
GdkWaylandDisplay *display_wayland;
|
||||||
GdkWindow *toplevel;
|
|
||||||
const char *const *mimetypes;
|
const char *const *mimetypes;
|
||||||
gsize i, n_mimetypes;
|
gsize i, n_mimetypes;
|
||||||
|
|
||||||
@ -561,8 +560,6 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
|||||||
wl_data_source_offer (context_wayland->data_source, mimetypes[i]);
|
wl_data_source_offer (context_wayland->data_source, mimetypes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel = _gdk_device_window_at_position (device, NULL, NULL, NULL, TRUE);
|
|
||||||
|
|
||||||
if (display_wayland->data_device_manager_version >=
|
if (display_wayland->data_device_manager_version >=
|
||||||
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
|
WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION)
|
||||||
{
|
{
|
||||||
@ -572,7 +569,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
|||||||
|
|
||||||
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
|
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
|
||||||
context_wayland->data_source,
|
context_wayland->data_source,
|
||||||
gdk_wayland_window_get_wl_surface (toplevel),
|
gdk_wayland_window_get_wl_surface (window),
|
||||||
context_wayland->dnd_surface,
|
context_wayland->dnd_surface,
|
||||||
_gdk_wayland_display_get_serial (display_wayland));
|
_gdk_wayland_display_get_serial (display_wayland));
|
||||||
|
|
||||||
|
112
gtk/gtkdnd.c
112
gtk/gtkdnd.c
@ -73,7 +73,6 @@ struct _GtkDragSourceInfo
|
|||||||
GdkDragContext *context; /* drag context */
|
GdkDragContext *context; /* drag context */
|
||||||
GtkWidget *icon_window; /* Window for drag */
|
GtkWidget *icon_window; /* Window for drag */
|
||||||
GtkWidget *icon_widget; /* Widget for drag */
|
GtkWidget *icon_widget; /* Widget for drag */
|
||||||
GtkWidget *ipc_widget; /* GtkInvisible for grab, message passing */
|
|
||||||
|
|
||||||
guint drop_timeout; /* Timeout for aborting drop */
|
guint drop_timeout; /* Timeout for aborting drop */
|
||||||
guint destroy_icon : 1; /* If true, destroy icon_widget */
|
guint destroy_icon : 1; /* If true, destroy icon_widget */
|
||||||
@ -94,10 +93,6 @@ typedef gboolean (* GtkDragDestCallback) (GtkWidget *widget,
|
|||||||
guint32 time);
|
guint32 time);
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static GtkWidget *gtk_drag_get_ipc_widget (GtkWidget *widget);
|
|
||||||
static GtkWidget *gtk_drag_get_ipc_widget_for_display(GdkDisplay*display);
|
|
||||||
static void gtk_drag_release_ipc_widget (GtkWidget *widget);
|
|
||||||
|
|
||||||
static gboolean gtk_drag_find_widget (GtkWidget *widget,
|
static gboolean gtk_drag_find_widget (GtkWidget *widget,
|
||||||
GdkDragContext *context,
|
GdkDragContext *context,
|
||||||
GtkDragDestInfo *info,
|
GtkDragDestInfo *info,
|
||||||
@ -156,82 +151,6 @@ static void set_icon_helper (GdkDragContext *context,
|
|||||||
gint hot_y);
|
gint hot_y);
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
|
||||||
* Utility functions *
|
|
||||||
*********************/
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
gtk_drag_get_ipc_widget_for_display (GdkDisplay *display)
|
|
||||||
{
|
|
||||||
GtkWidget *result;
|
|
||||||
GSList *drag_widgets = g_object_get_data (G_OBJECT (display),
|
|
||||||
"gtk-dnd-ipc-widgets");
|
|
||||||
|
|
||||||
if (drag_widgets)
|
|
||||||
{
|
|
||||||
GSList *tmp = drag_widgets;
|
|
||||||
result = drag_widgets->data;
|
|
||||||
drag_widgets = drag_widgets->next;
|
|
||||||
g_object_set_data (G_OBJECT (display),
|
|
||||||
I_("gtk-dnd-ipc-widgets"),
|
|
||||||
drag_widgets);
|
|
||||||
g_slist_free_1 (tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = gtk_window_new (GTK_WINDOW_POPUP);
|
|
||||||
gtk_window_set_display (GTK_WINDOW (result), display);
|
|
||||||
gtk_window_resize (GTK_WINDOW (result), 1, 1);
|
|
||||||
gtk_window_move (GTK_WINDOW (result), -99, -99);
|
|
||||||
gtk_widget_show (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
gtk_drag_get_ipc_widget (GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GtkWidget *result;
|
|
||||||
GtkWidget *toplevel;
|
|
||||||
|
|
||||||
result = gtk_drag_get_ipc_widget_for_display (gtk_widget_get_display (widget));
|
|
||||||
|
|
||||||
toplevel = gtk_widget_get_toplevel (widget);
|
|
||||||
|
|
||||||
if (GTK_IS_WINDOW (toplevel))
|
|
||||||
{
|
|
||||||
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
|
||||||
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
|
|
||||||
GTK_WINDOW (result));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gtk_drag_release_ipc_widget:
|
|
||||||
* @widget: the widget to release
|
|
||||||
*
|
|
||||||
* Releases widget retrieved with gtk_drag_get_ipc_widget().
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
gtk_drag_release_ipc_widget (GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GtkWindow *window = GTK_WINDOW (widget);
|
|
||||||
GdkDisplay *display = gtk_widget_get_display (widget);
|
|
||||||
GSList *drag_widgets = g_object_get_data (G_OBJECT (display),
|
|
||||||
"gtk-dnd-ipc-widgets");
|
|
||||||
|
|
||||||
if (gtk_window_has_group (window))
|
|
||||||
gtk_window_group_remove_window (gtk_window_get_group (window),
|
|
||||||
window);
|
|
||||||
drag_widgets = g_slist_prepend (drag_widgets, widget);
|
|
||||||
g_object_set_data (G_OBJECT (display),
|
|
||||||
I_("gtk-dnd-ipc-widgets"),
|
|
||||||
drag_widgets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************
|
/********************
|
||||||
* Destination side *
|
* Destination side *
|
||||||
********************/
|
********************/
|
||||||
@ -407,15 +326,10 @@ gtk_drag_get_source_widget (GdkDragContext *context)
|
|||||||
tmp_list = source_widgets;
|
tmp_list = source_widgets;
|
||||||
while (tmp_list)
|
while (tmp_list)
|
||||||
{
|
{
|
||||||
GtkWidget *ipc_widget = tmp_list->data;
|
GtkWidget *widget = tmp_list->data;
|
||||||
|
|
||||||
if (gtk_widget_get_window (ipc_widget) == gdk_drag_context_get_source_window (context))
|
if (gtk_widget_get_window (widget) == gdk_drag_context_get_source_window (context))
|
||||||
{
|
return widget;
|
||||||
GtkDragSourceInfo *info;
|
|
||||||
info = g_object_get_data (G_OBJECT (ipc_widget), "gtk-info");
|
|
||||||
|
|
||||||
return info ? info->widget : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
}
|
}
|
||||||
@ -1020,21 +934,16 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
|||||||
GtkDragSourceInfo *info;
|
GtkDragSourceInfo *info;
|
||||||
GtkWidget *toplevel;
|
GtkWidget *toplevel;
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
GtkWidget *ipc_widget;
|
|
||||||
GdkWindow *ipc_window;
|
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
GtkDragContent *content;
|
GtkDragContent *content;
|
||||||
guint32 time;
|
guint32 time;
|
||||||
|
|
||||||
ipc_widget = gtk_drag_get_ipc_widget (widget);
|
|
||||||
time = gtk_get_current_event_time ();
|
time = gtk_get_current_event_time ();
|
||||||
|
|
||||||
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
||||||
device = gdk_device_get_associated_device (device);
|
device = gdk_device_get_associated_device (device);
|
||||||
|
|
||||||
ipc_window = gtk_widget_get_window (ipc_widget);
|
source_widgets = g_slist_prepend (source_widgets, widget);
|
||||||
|
|
||||||
source_widgets = g_slist_prepend (source_widgets, ipc_widget);
|
|
||||||
|
|
||||||
toplevel = gtk_widget_get_toplevel (widget);
|
toplevel = gtk_widget_get_toplevel (widget);
|
||||||
gtk_widget_translate_coordinates (widget, toplevel,
|
gtk_widget_translate_coordinates (widget, toplevel,
|
||||||
@ -1051,10 +960,9 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
|||||||
content->formats = gdk_content_formats_ref (target_list);
|
content->formats = gdk_content_formats_ref (target_list);
|
||||||
content->time = time;
|
content->time = time;
|
||||||
|
|
||||||
context = gdk_drag_begin (ipc_window, device, GDK_CONTENT_PROVIDER (content), actions, dx, dy);
|
context = gdk_drag_begin (gtk_widget_get_window (toplevel), device, GDK_CONTENT_PROVIDER (content), actions, dx, dy);
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
{
|
{
|
||||||
gtk_drag_release_ipc_widget (ipc_widget);
|
|
||||||
g_object_unref (content);
|
g_object_unref (content);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1064,8 +972,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
|||||||
|
|
||||||
info = gtk_drag_get_source_info (context, TRUE);
|
info = gtk_drag_get_source_info (context, TRUE);
|
||||||
|
|
||||||
info->ipc_widget = ipc_widget;
|
g_object_set_data (G_OBJECT (widget), I_("gtk-info"), info);
|
||||||
g_object_set_data (G_OBJECT (info->ipc_widget), I_("gtk-info"), info);
|
|
||||||
|
|
||||||
info->widget = g_object_ref (widget);
|
info->widget = g_object_ref (widget);
|
||||||
|
|
||||||
@ -1520,11 +1427,10 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
|
|||||||
|
|
||||||
g_signal_emit_by_name (info->widget, "drag-end", info->context);
|
g_signal_emit_by_name (info->widget, "drag-end", info->context);
|
||||||
|
|
||||||
g_clear_object (&info->widget);
|
g_object_set_data (G_OBJECT (info->widget), I_("gtk-info"), NULL);
|
||||||
|
source_widgets = g_slist_remove (source_widgets, info->widget);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (info->ipc_widget), I_("gtk-info"), NULL);
|
g_clear_object (&info->widget);
|
||||||
source_widgets = g_slist_remove (source_widgets, info->ipc_widget);
|
|
||||||
gtk_drag_release_ipc_widget (info->ipc_widget);
|
|
||||||
|
|
||||||
gdk_content_formats_unref (info->target_list);
|
gdk_content_formats_unref (info->target_list);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user