[mutter/wip/dnd-surface3: 10/11] wayland: Use a MetaDnDActor for the DnD icon surface
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/dnd-surface3: 10/11] wayland: Use a MetaDnDActor for the DnD icon surface
- Date: Mon, 6 Oct 2014 15:12:49 +0000 (UTC)
commit 55a583adb8fcf4a2312b2dc2833297a033999a81
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Oct 6 17:03:51 2014 +0200
wayland: Use a MetaDnDActor for the DnD icon surface
The actor is updated on DnD grab motion events, properly notified
when dragging finishes, and destroyed if the client/surface disappear
below its feet.
src/wayland/meta-wayland-data-device.c | 48 ++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 6d6f33e..97f1426 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -34,6 +34,7 @@
#include "meta-wayland-seat.h"
#include "meta-wayland-pointer.h"
#include "meta-wayland-private.h"
+#include "meta-dnd-actor-private.h"
typedef struct
{
@@ -182,6 +183,8 @@ struct _MetaWaylandDragGrab {
MetaWaylandDataSource *drag_data_source;
struct wl_listener drag_data_source_listener;
+ ClutterActor *feedback_actor;
+
MetaWaylandSurface *drag_origin;
struct wl_listener drag_origin_listener;
@@ -268,6 +271,10 @@ drag_grab_motion (MetaWaylandPointerGrab *grab,
clutter_event_get_time (event),
sx, sy);
}
+
+ if (drag_grab->drag_surface)
+ meta_feedback_actor_update (META_FEEDBACK_ACTOR (drag_grab->feedback_actor),
+ event);
}
static void
@@ -291,6 +298,12 @@ data_device_end_drag_grab (MetaWaylandDragGrab *drag_grab)
wl_list_remove (&drag_grab->drag_data_source_listener.link);
}
+ if (drag_grab->feedback_actor)
+ {
+ clutter_actor_remove_all_children (drag_grab->feedback_actor);
+ clutter_actor_destroy (drag_grab->feedback_actor);
+ }
+
drag_grab->seat->data_device.current_grab = NULL;
drag_grab_focus (&drag_grab->generic, NULL);
@@ -307,10 +320,23 @@ 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);
+ {
+ gboolean success = FALSE;
+
+ 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);
+ success = TRUE;
+ }
+
+ /* Finish drag and let actor self-destruct */
+ meta_dnd_actor_drag_finish (META_DND_ACTOR (drag_grab->feedback_actor),
+ success);
+ drag_grab->feedback_actor = NULL;
+ }
if (seat->pointer.button_count == 0 &&
event_type == CLUTTER_BUTTON_RELEASE)
@@ -350,6 +376,9 @@ destroy_data_device_icon (struct wl_listener *listener, void *data)
wl_container_of (listener, drag_grab, drag_data_source_listener);
drag_grab->drag_surface = NULL;
+
+ if (drag_grab->feedback_actor)
+ clutter_actor_remove_all_children (drag_grab->feedback_actor);
}
static void
@@ -416,6 +445,19 @@ data_device_start_drag (struct wl_client *client,
drag_grab->drag_icon_listener.notify = destroy_data_device_icon;
wl_resource_add_destroy_listener (icon_resource,
&drag_grab->drag_icon_listener);
+
+ drag_grab->feedback_actor = meta_dnd_actor_new (CLUTTER_ACTOR (drag_grab->drag_origin->surface_actor),
+ drag_grab->drag_start_x,
+ drag_grab->drag_start_y);
+ meta_feedback_actor_set_anchor (META_FEEDBACK_ACTOR (drag_grab->feedback_actor),
+ -drag_grab->drag_surface->offset_x,
+ -drag_grab->drag_surface->offset_y);
+ clutter_actor_add_child (drag_grab->feedback_actor,
+ CLUTTER_ACTOR (drag_grab->drag_surface->surface_actor));
+
+ clutter_input_device_get_coords (seat->pointer.device, NULL, &pos);
+ meta_feedback_actor_set_position (META_FEEDBACK_ACTOR (drag_grab->feedback_actor),
+ pos.x, pos.y);
}
meta_wayland_pointer_set_focus (&seat->pointer, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]