wayland: Implement DND icon hotspot API

In Wayland, the hotspot of a DND icon is set using the buffer offset in
wl_buffer.attach. To implement this, add a private API to cause the
next wl_surface.attach to offset the new buffer with a given offset.
Setting a DND icon hotspot sets this offset while also queuing a redraw
of the window to trigger the wl_surface.attach.

https://bugzilla.gnome.org/show_bug.cgi?id=759168
This commit is contained in:
Jonas Ådahl
2015-12-08 18:19:33 +08:00
committed by Matthias Clasen
parent 8884e82af8
commit 561833334b
3 changed files with 39 additions and 3 deletions

View File

@ -306,8 +306,20 @@ gdk_wayland_drag_context_set_hotspot (GdkDragContext *context,
gint hot_x,
gint hot_y)
{
GDK_WAYLAND_DRAG_CONTEXT (context)->hot_x = hot_x;
GDK_WAYLAND_DRAG_CONTEXT (context)->hot_y = hot_y;
GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
gint prev_hot_x = context_wayland->hot_x;
gint prev_hot_y = context_wayland->hot_y;
const GdkRectangle damage_rect = { .width = 1, .height = 1 };
context_wayland->hot_x = hot_x;
context_wayland->hot_y = hot_y;
if (prev_hot_x == hot_x && prev_hot_y == hot_y)
return;
_gdk_wayland_window_offset_next_wl_buffer (context_wayland->dnd_window,
-hot_x, -hot_y);
gdk_window_invalidate_rect (context_wayland->dnd_window, &damage_rect, FALSE);
}
static void