summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-02-23 00:21:54 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-02-23 00:21:54 +0000
commit8d5cece080b77a277adea95d0cf18932fe646596 (patch)
tree0631daf88d6c2d12bbf0017206608d1b58993c46
parent7edfcc37a3c4e92dd7bca836426c5a6586dbeb53 (diff)
parentec383a238842b5e50a4e8008c6e59ab5b7158dc7 (diff)
downloadgtk+-8d5cece080b77a277adea95d0cf18932fe646596.tar.gz
Merge branch 'x11-dnd-fixes' into 'master'
X11 dnd fixes See merge request GNOME/gtk!1464
-rw-r--r--gdk/gdksurface.c4
-rw-r--r--gdk/x11/gdkdrag-x11.c31
-rw-r--r--gdk/x11/gdkprivate-x11.h6
-rw-r--r--gdk/x11/gdksurface-x11.c2
4 files changed, 29 insertions, 14 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 399e40c368..13b0dec48d 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -3587,6 +3587,10 @@ gdk_surface_register_dnd (GdkSurface *surface)
* probably want to set up the drag icon using the surface returned
* by gdk_drag_get_drag_surface().
*
+ * This function returns a reference to the GdkDrag object, but GTK
+ * keeps its own reference as well, as long as the DND operation is
+ * going on.
+ *
* Note: if @actions include %GDK_ACTION_MOVE, you need to listen for
* the #GdkDrag::dnd-finished signal and delete the data at the source
* if gdk_drag_get_selected_action() returns %GDK_ACTION_MOVE.
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index c29304e818..04fa753fa3 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -900,16 +900,12 @@ gdk_x11_drag_handle_finished (GdkDisplay *display,
if (drag)
{
- g_object_ref (drag);
-
drag_x11 = GDK_X11_DRAG (drag);
if (drag_x11->version == 5)
drag_x11->drop_failed = xevent->xclient.data.l[1] == 0;
g_signal_emit_by_name (drag, "dnd-finished");
gdk_drag_drop_done (drag, !drag_x11->drop_failed);
-
- g_object_unref (drag);
}
}
@@ -1714,8 +1710,8 @@ gdk_x11_drag_default_output_handler (GOutputStream *stream,
static gboolean
gdk_x11_drag_xevent (GdkDisplay *display,
- const XEvent *xevent,
- gpointer data)
+ const XEvent *xevent,
+ gpointer data)
{
GdkDrag *drag = GDK_DRAG (data);
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
@@ -1876,8 +1872,8 @@ gdk_x11_drag_release_selection (GdkDrag *drag)
}
static void
-gdk_x11_drag_drop_done (GdkDrag *drag,
- gboolean success)
+gdk_x11_drag_drop_done (GdkDrag *drag,
+ gboolean success)
{
GdkX11Drag *x11_drag = GDK_X11_DRAG (drag);
GdkDragAnim *anim;
@@ -1896,6 +1892,7 @@ gdk_x11_drag_drop_done (GdkDrag *drag,
if (success)
{
gdk_surface_hide (x11_drag->drag_surface);
+ g_object_unref (drag);
return;
}
@@ -1928,6 +1925,7 @@ gdk_x11_drag_drop_done (GdkDrag *drag,
gdk_drag_anim_timeout, anim,
(GDestroyNotify) gdk_drag_anim_destroy);
g_source_set_name_by_id (id, "[gtk] gdk_drag_anim_timeout");
+ g_object_unref (drag);
}
static gboolean
@@ -2072,13 +2070,15 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
NULL);
x11_drag = GDK_X11_DRAG (drag);
- g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag);
-
precache_target_list (drag);
gdk_device_get_position (device, &px, &py);
- x_root = round (px) + dx;
- y_root = round (py) + dy;
+
+ gdk_x11_surface_get_root_coords (surface,
+ round (px) + dx,
+ round (py) + dy,
+ &x_root,
+ &y_root);
x11_drag->start_x = x_root;
x11_drag->start_y = y_root;
@@ -2099,7 +2099,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
g_object_unref (drag);
return NULL;
}
-
+
move_drag_surface (drag, x_root, y_root);
x11_drag->timestamp = gdk_display_get_last_seen_time (display);
@@ -2115,6 +2115,11 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
return NULL;
}
+
+ g_signal_connect_object (display, "xevent", G_CALLBACK (gdk_x11_drag_xevent), drag, 0);
+ /* backend holds a ref until gdk_drag_drop_done is called */
+ g_object_ref (drag);
+
return drag;
}
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 0f8ca87765..69a1248b8a 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -230,6 +230,12 @@ GdkDrag * _gdk_x11_surface_drag_begin (GdkSurface *window,
gint dx,
gint dy);
+void gdk_x11_surface_get_root_coords (GdkSurface *surface,
+ gint x,
+ gint y,
+ gint *root_x,
+ gint *root_y);
+
GdkGrabStatus _gdk_x11_convert_grab_status (gint status);
cairo_surface_t * _gdk_x11_display_create_bitmap_surface (GdkDisplay *display,
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 7c4ce1199e..8d052e9d3d 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -2402,7 +2402,7 @@ gdk_x11_surface_get_geometry (GdkSurface *surface,
}
}
-static void
+void
gdk_x11_surface_get_root_coords (GdkSurface *surface,
gint x,
gint y,