diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c index f145f54c3..4cdf8fe0e 100644 --- a/src/compositor/meta-window-actor-wayland.c +++ b/src/compositor/meta-window-actor-wayland.c @@ -91,17 +91,6 @@ meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor) actor); } -MetaWindowActor * -meta_window_actor_wayland_from_surface (MetaWaylandSurface *surface) -{ - if (surface->window) - return meta_window_actor_from_window (surface->window); - else if (surface->sub.parent) - return meta_window_actor_wayland_from_surface (surface->sub.parent); - else - return NULL; -} - static void meta_window_actor_wayland_assign_surface_actor (MetaWindowActor *actor, MetaSurfaceActor *surface_actor) diff --git a/src/compositor/meta-window-actor-wayland.h b/src/compositor/meta-window-actor-wayland.h index d7e1b7808..d94de8106 100644 --- a/src/compositor/meta-window-actor-wayland.h +++ b/src/compositor/meta-window-actor-wayland.h @@ -33,6 +33,5 @@ G_DECLARE_FINAL_TYPE (MetaWindowActorWayland, MetaWindowActor) void meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor); -MetaWindowActor * meta_window_actor_wayland_from_surface (MetaWaylandSurface *surface); #endif /*META_WINDOW_ACTOR_WAYLAND_H */ diff --git a/src/wayland/meta-wayland-shell-surface.c b/src/wayland/meta-wayland-shell-surface.c index c2022a736..aa3e397ac 100644 --- a/src/wayland/meta-wayland-shell-surface.c +++ b/src/wayland/meta-wayland-shell-surface.c @@ -24,6 +24,7 @@ #include "wayland/meta-wayland-shell-surface.h" #include "compositor/meta-surface-actor-wayland.h" +#include "compositor/meta-window-actor-wayland.h" #include "wayland/meta-wayland-actor-surface.h" #include "wayland/meta-wayland-buffer.h" #include "wayland/meta-wayland-subsurface.h" @@ -165,6 +166,22 @@ meta_wayland_shell_surface_surface_apply_state (MetaWaylandSurfaceRole *surface meta_wayland_surface_get_height (surface) * geometry_scale; } +static void +meta_wayland_shell_surface_notify_subsurface_state_changed (MetaWaylandSurfaceRole *surface_role) +{ + MetaWaylandSurface *surface = + meta_wayland_surface_role_get_surface (surface_role); + MetaWindow *window; + MetaWindowActor *window_actor; + + window = surface->window; + if (!window) + return; + + window_actor = meta_window_actor_from_window (window); + meta_window_actor_wayland_rebuild_surface_tree (window_actor); +} + static double meta_wayland_shell_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface) { @@ -246,6 +263,8 @@ meta_wayland_shell_surface_class_init (MetaWaylandShellSurfaceClass *klass) surface_role_class->apply_state = meta_wayland_shell_surface_surface_apply_state; + surface_role_class->notify_subsurface_state_changed = + meta_wayland_shell_surface_notify_subsurface_state_changed; actor_surface_class->get_geometry_scale = meta_wayland_shell_surface_get_geometry_scale; diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 3e5632010..d3afcf8af 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -139,7 +139,6 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface) { GSList *it; MetaWaylandSurface *parent; - MetaWindowActor *window_actor; parent = surface->sub.parent; @@ -184,9 +183,7 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface) g_slist_free (surface->sub.pending_placement_ops); surface->sub.pending_placement_ops = NULL; - window_actor = meta_window_actor_wayland_from_surface (surface); - if (window_actor) - meta_window_actor_wayland_rebuild_surface_tree (window_actor); + meta_wayland_surface_notify_subsurface_state_changed (parent); } if (is_surface_effectively_synchronized (surface)) @@ -258,6 +255,16 @@ meta_wayland_subsurface_should_cache_state (MetaWaylandSurfaceRole *surface_role return TRUE; } +static void +meta_wayland_subsurface_notify_subsurface_state_changed (MetaWaylandSurfaceRole *surface_role) +{ + MetaWaylandSurface *surface = + meta_wayland_surface_role_get_surface (surface_role); + MetaWaylandSurface *parent = surface->sub.parent; + + return meta_wayland_surface_notify_subsurface_state_changed (parent); +} + static double meta_wayland_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface) { @@ -313,6 +320,8 @@ meta_wayland_subsurface_class_init (MetaWaylandSubsurfaceClass *klass) surface_role_class->get_toplevel = meta_wayland_subsurface_get_toplevel; surface_role_class->should_cache_state = meta_wayland_subsurface_should_cache_state; + surface_role_class->notify_subsurface_state_changed = + meta_wayland_subsurface_notify_subsurface_state_changed; actor_surface_class->get_geometry_scale = meta_wayland_subsurface_get_geometry_scale; @@ -519,7 +528,6 @@ wl_subcompositor_get_subsurface (struct wl_client *client, MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); MetaWaylandSurface *parent = wl_resource_get_user_data (parent_resource); MetaWindow *toplevel_window; - MetaWindowActor *window_actor; if (surface->wl_subsurface) { @@ -564,9 +572,7 @@ wl_subcompositor_get_subsurface (struct wl_client *client, g_node_append (parent->subsurface_branch_node, surface->subsurface_branch_node); - window_actor = meta_window_actor_wayland_from_surface (surface); - if (window_actor) - meta_window_actor_wayland_rebuild_surface_tree (window_actor); + meta_wayland_surface_notify_subsurface_state_changed (parent); } 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 2b01a2acb..de3502b2e 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1843,6 +1843,24 @@ meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface) return meta_wayland_surface_role_should_cache_state (surface->role); } +static void +meta_wayland_surface_role_notify_subsurface_state_changed (MetaWaylandSurfaceRole *surface_role) +{ + MetaWaylandSurfaceRoleClass *klass; + + klass = META_WAYLAND_SURFACE_ROLE_GET_CLASS (surface_role); + g_return_if_fail (klass->notify_subsurface_state_changed); + + klass->notify_subsurface_state_changed (surface_role); +} + +void +meta_wayland_surface_notify_subsurface_state_changed (MetaWaylandSurface *surface) +{ + if (surface->role) + meta_wayland_surface_role_notify_subsurface_state_changed (surface->role); +} + MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role) { diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index b75b0708d..b19a35832 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -62,6 +62,7 @@ struct _MetaWaylandSurfaceRoleClass MetaLogicalMonitor *logical_monitor); MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role); gboolean (*should_cache_state) (MetaWaylandSurfaceRole *surface_role); + void (*notify_subsurface_state_changed) (MetaWaylandSurfaceRole *surface_role); }; struct _MetaWaylandSurfaceState @@ -325,6 +326,8 @@ MetaSurfaceActor * meta_wayland_surface_get_actor (MetaWaylandSurface *surface) void meta_wayland_surface_notify_geometry_changed (MetaWaylandSurface *surface); +void meta_wayland_surface_notify_subsurface_state_changed (MetaWaylandSurface *surface); + int meta_wayland_surface_get_width (MetaWaylandSurface *surface); int meta_wayland_surface_get_height (MetaWaylandSurface *surface);