[mutter/wip/dnd-surface2: 16/18] wayland: Trigger the DnD failed animation if no DnD is to happen
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/dnd-surface2: 16/18] wayland: Trigger the DnD failed animation if no DnD is to happen
- Date: Tue, 30 Sep 2014 15:36:29 +0000 (UTC)
commit 869d12c36d69dc4fe7d980739059eb1f91fdec21
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Sep 30 17:12:08 2014 +0200
wayland: Trigger the DnD failed animation if no DnD is to happen
If there is no focus window, focus data_source or target selected,
DnD will fail and show the fancy animation.
src/wayland/meta-wayland-data-device.c | 34 +++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 7e8cdc6..877eace 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -306,6 +306,29 @@ drag_grab_motion (MetaWaylandPointerGrab *grab,
}
static void
+data_device_dnd_failed (MetaWaylandDragGrab *drag_grab)
+{
+ MetaWaylandSurface *surface = drag_grab->drag_origin;
+ MetaWaylandSeat *seat = drag_grab->seat;
+ ClutterPoint dest;
+
+ if (drag_grab->drag_origin &&
+ !meta_window_is_hidden (surface->window))
+ {
+ /* Find out the snap back position */
+ clutter_actor_get_transformed_position (CLUTTER_ACTOR (meta_surface_actor_get_texture
(surface->surface_actor)),
+ &dest.x, &dest.y);
+ dest.x += drag_grab->drag_start_x;
+ dest.y += drag_grab->drag_start_y;
+ }
+ else
+ clutter_input_device_get_coords (seat->pointer.device, NULL, &dest);
+
+ meta_cursor_tracker_dnd_failed (seat->pointer.cursor_tracker,
+ dest.x, dest.y);
+}
+
+static void
data_device_end_drag_grab (MetaWaylandDragGrab *drag_grab)
{
if (drag_grab->drag_origin)
@@ -343,10 +366,15 @@ drag_grab_button (MetaWaylandPointerGrab *grab,
MetaWaylandSeat *seat = drag_grab->seat;
ClutterEventType event_type = clutter_event_type (event);
- if (drag_grab->drag_focus_data_device &&
- drag_grab->generic.pointer->grab_button == clutter_event_get_button (event) &&
+ if (drag_grab->generic.pointer->grab_button == clutter_event_get_button (event) &&
event_type == CLUTTER_BUTTON_RELEASE)
- wl_data_device_send_drop (drag_grab->drag_focus_data_device);
+ {
+ if (drag_grab->drag_focus_data_device &&
+ drag_grab->drag_data_source->has_target)
+ wl_data_device_send_drop (drag_grab->drag_focus_data_device);
+ else
+ data_device_dnd_failed (drag_grab);
+ }
if (seat->pointer.button_count == 0 &&
event_type == CLUTTER_BUTTON_RELEASE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]