From 70036429bd4a0d854caad8b0d0f76f0a5e9b3917 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Apr 2018 12:29:37 +0200 Subject: [PATCH] wayland: Abstract access to the actor corresponding to a wl_surface The actor itself will be shuffled around, abstract all external access to it behind a function to make that easier later on. --- src/compositor/meta-window-actor.c | 2 +- src/wayland/meta-pointer-confinement-wayland.c | 4 ++-- src/wayland/meta-wayland-data-device.c | 14 ++++++++++---- src/wayland/meta-wayland-subsurface.c | 16 ++++++++-------- src/wayland/meta-wayland-surface.c | 6 ++++++ src/wayland/meta-wayland-surface.h | 2 ++ src/wayland/meta-wayland-tablet-tool.c | 5 ++++- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 5078624cc..49ed6d5b3 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -450,7 +450,7 @@ meta_window_actor_update_surface (MetaWindowActor *self) #ifdef HAVE_WAYLAND if (window->surface) - surface_actor = window->surface->surface_actor; + surface_actor = meta_wayland_surface_get_actor (window->surface); else #endif if (!meta_is_wayland_compositor ()) diff --git a/src/wayland/meta-pointer-confinement-wayland.c b/src/wayland/meta-pointer-confinement-wayland.c index 65a85c47b..01a2b7ff8 100644 --- a/src/wayland/meta-pointer-confinement-wayland.c +++ b/src/wayland/meta-pointer-confinement-wayland.c @@ -699,12 +699,12 @@ meta_pointer_confinement_wayland_new (MetaWaylandPointerConstraint *constraint) confinement->constraint = constraint; surface = meta_wayland_pointer_constraint_get_surface (constraint); - g_signal_connect_object (surface->surface_actor, + g_signal_connect_object (meta_wayland_surface_get_actor (surface), "notify::allocation", G_CALLBACK (surface_actor_allocation_notify), confinement, 0); - g_signal_connect_object (surface->surface_actor, + g_signal_connect_object (meta_wayland_surface_get_actor (surface), "notify::position", G_CALLBACK (surface_actor_position_notify), confinement, diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c index 06356c1c2..6826b6998 100644 --- a/src/wayland/meta-wayland-data-device.c +++ b/src/wayland/meta-wayland-data-device.c @@ -1083,6 +1083,7 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data MetaWaylandDragGrab *drag_grab; ClutterPoint pos, surface_pos; ClutterModifierType modifiers; + MetaSurfaceActor *surface_actor; data_device->current_grab = drag_grab = g_slice_new0 (MetaWaylandDragGrab); @@ -1100,7 +1101,9 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data wl_resource_add_destroy_listener (surface->resource, &drag_grab->drag_origin_listener); - clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)), + surface_actor = meta_wayland_surface_get_actor (surface); + + clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface_actor)), seat->pointer->grab_x, seat->pointer->grab_y, &surface_pos.x, &surface_pos.y); @@ -1121,19 +1124,22 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data if (icon_surface) { + ClutterActor *drag_origin_actor; + drag_grab->drag_surface = icon_surface; drag_grab->drag_icon_listener.notify = destroy_data_device_icon; wl_resource_add_destroy_listener (icon_surface->resource, &drag_grab->drag_icon_listener); - drag_grab->feedback_actor = meta_dnd_actor_new (CLUTTER_ACTOR (drag_grab->drag_origin->surface_actor), + drag_origin_actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (drag_grab->drag_origin)); + + drag_grab->feedback_actor = meta_dnd_actor_new (drag_origin_actor, drag_grab->drag_start_x, drag_grab->drag_start_y); meta_feedback_actor_set_anchor (META_FEEDBACK_ACTOR (drag_grab->feedback_actor), 0, 0); - clutter_actor_add_child (drag_grab->feedback_actor, - CLUTTER_ACTOR (drag_grab->drag_surface->surface_actor)); + clutter_actor_add_child (drag_grab->feedback_actor, drag_origin_actor); clutter_input_device_get_coords (seat->pointer->device, NULL, &pos); meta_feedback_actor_set_position (META_FEEDBACK_ACTOR (drag_grab->feedback_actor), diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 4bcffd0ea..399212da6 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -54,7 +54,7 @@ G_DEFINE_TYPE (MetaWaylandSubsurface, static void sync_actor_subsurface_state (MetaWaylandSurface *surface) { - ClutterActor *actor = CLUTTER_ACTOR (surface->surface_actor); + ClutterActor *actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); MetaWindow *toplevel_window; int geometry_scale; int x, y; @@ -99,8 +99,8 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface) GSList *it; MetaWaylandSurface *parent = surface->sub.parent; ClutterActor *parent_actor = - clutter_actor_get_parent (CLUTTER_ACTOR (parent->surface_actor)); - ClutterActor *surface_actor = CLUTTER_ACTOR (surface->surface_actor); + clutter_actor_get_parent (CLUTTER_ACTOR (meta_wayland_surface_get_actor (parent))); + ClutterActor *surface_actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); for (it = surface->sub.pending_placement_ops; it; it = it->next) { @@ -113,7 +113,7 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface) continue; } - sibling_actor = CLUTTER_ACTOR (op->sibling->surface_actor); + sibling_actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (op->sibling)); switch (op->placement) { @@ -234,7 +234,7 @@ meta_wayland_subsurface_class_init (MetaWaylandSubsurfaceClass *klass) static void unparent_actor (MetaWaylandSurface *surface) { - ClutterActor *actor = CLUTTER_ACTOR (surface->surface_actor); + ClutterActor *actor = CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)); ClutterActor *parent_actor; parent_actor = clutter_actor_get_parent (actor); @@ -471,10 +471,10 @@ wl_subcompositor_get_subsurface (struct wl_client *client, &surface->sub.parent_destroy_listener); parent->subsurfaces = g_list_append (parent->subsurfaces, surface); - clutter_actor_add_child (CLUTTER_ACTOR (parent->surface_actor), - CLUTTER_ACTOR (surface->surface_actor)); + clutter_actor_add_child (CLUTTER_ACTOR (meta_wayland_surface_get_actor (parent)), + CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface))); - clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), TRUE); + clutter_actor_set_reactive (CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface)), TRUE); } static const struct wl_subcompositor_interface meta_wayland_subcompositor_interface = { diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index f849d5b4d..fe7f59d78 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1789,3 +1789,9 @@ meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface, return g_hash_table_contains (surface->shortcut_inhibited_seats, seat); } + +MetaSurfaceActor * +meta_wayland_surface_get_actor (MetaWaylandSurface *surface) +{ + return surface->surface_actor; +} diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 05d2a0a24..ec0b011ac 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -303,4 +303,6 @@ void meta_wayland_surface_restore_shortcuts (MetaWaylandSurface * gboolean meta_wayland_surface_is_shortcuts_inhibited (MetaWaylandSurface *surface, MetaWaylandSeat *seat); +MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface); + #endif diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index 4b57d4156..1ea685ed6 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -632,10 +632,13 @@ meta_wayland_tablet_tool_get_relative_coordinates (MetaWaylandTabletTool *tool, wl_fixed_t *sx, wl_fixed_t *sy) { + MetaSurfaceActor *surface_actor; float xf, yf; + surface_actor = meta_wayland_surface_get_actor (surface); + clutter_event_get_coords (event, &xf, &yf); - clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)), + clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface_actor)), xf, yf, &xf, &yf); *sx = wl_fixed_from_double (xf) / surface->scale;