gtk: Properly calculate device offset for DnD
We need to take the device scale into account, like it is done in gdkwindow.c. This fixes wrongly placed DnD surfaces in scaled contexts on X11 as well as Wayland.
This commit is contained in:
		| @ -14,6 +14,7 @@ drag_begin (GtkWidget      *widget, | ||||
|   cairo_surface_t *surface; | ||||
|   cairo_t *cr; | ||||
|   int x, y; | ||||
|   double sx, sy; | ||||
|  | ||||
|   row = gtk_widget_get_ancestor (widget, GTK_TYPE_LIST_BOX_ROW); | ||||
|   gtk_widget_get_allocation (row, &alloc); | ||||
| @ -25,7 +26,8 @@ drag_begin (GtkWidget      *widget, | ||||
|   gtk_style_context_remove_class (gtk_widget_get_style_context (row), "drag-icon"); | ||||
|  | ||||
|   gtk_widget_translate_coordinates (widget, row, 0, 0, &x, &y); | ||||
|   cairo_surface_set_device_offset (surface, -x, -y); | ||||
|   cairo_surface_get_device_scale (surface, &sx, &sy); | ||||
|   cairo_surface_set_device_offset (surface, -x * sy, -y * sy); | ||||
|   gtk_drag_set_icon_surface (context, surface); | ||||
|  | ||||
|   cairo_destroy (cr); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Robert Mader
					Robert Mader