wayland: Move tree updating to the shell surface role

The shell surface role is the one where subsurfaces may exist, and it
has direct relation to the MetaWindowActorWayland which currently has
the subsurface stacking logic.

Instead of directly finding the window actor when dealing with
subsurfaces, notify the parent surface that the subsurface state
changed, so that it can outsource the application of this information to
the role. For subsurface roles, this simply means forward upward to the
parent; for shell surface roles, this means regenerate the surface actor
layering.

This allows us to move away from accessing the window directly from the
surface, which in turn allows us to change the ownership structure of
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
This commit is contained in:
Jonas Ådahl 2019-10-08 23:32:37 +02:00 committed by Robert Mader
parent ac2c870177
commit 5149e1e43a
6 changed files with 54 additions and 20 deletions

View File

@ -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)

View File

@ -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 */

View File

@ -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;

View File

@ -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 = {

View File

@ -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)
{

View File

@ -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);