mirror of
https://github.com/brl/mutter.git
synced 2025-02-08 17:44:09 +00:00
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:
parent
ac2c870177
commit
5149e1e43a
@ -91,17 +91,6 @@ meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor)
|
|||||||
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
|
static void
|
||||||
meta_window_actor_wayland_assign_surface_actor (MetaWindowActor *actor,
|
meta_window_actor_wayland_assign_surface_actor (MetaWindowActor *actor,
|
||||||
MetaSurfaceActor *surface_actor)
|
MetaSurfaceActor *surface_actor)
|
||||||
|
@ -33,6 +33,5 @@ G_DECLARE_FINAL_TYPE (MetaWindowActorWayland,
|
|||||||
MetaWindowActor)
|
MetaWindowActor)
|
||||||
|
|
||||||
void meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor);
|
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 */
|
#endif /*META_WINDOW_ACTOR_WAYLAND_H */
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "wayland/meta-wayland-shell-surface.h"
|
#include "wayland/meta-wayland-shell-surface.h"
|
||||||
|
|
||||||
#include "compositor/meta-surface-actor-wayland.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-actor-surface.h"
|
||||||
#include "wayland/meta-wayland-buffer.h"
|
#include "wayland/meta-wayland-buffer.h"
|
||||||
#include "wayland/meta-wayland-subsurface.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;
|
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
|
static double
|
||||||
meta_wayland_shell_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
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 =
|
surface_role_class->apply_state =
|
||||||
meta_wayland_shell_surface_surface_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 =
|
actor_surface_class->get_geometry_scale =
|
||||||
meta_wayland_shell_surface_get_geometry_scale;
|
meta_wayland_shell_surface_get_geometry_scale;
|
||||||
|
@ -139,7 +139,6 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
|
|||||||
{
|
{
|
||||||
GSList *it;
|
GSList *it;
|
||||||
MetaWaylandSurface *parent;
|
MetaWaylandSurface *parent;
|
||||||
MetaWindowActor *window_actor;
|
|
||||||
|
|
||||||
parent = surface->sub.parent;
|
parent = surface->sub.parent;
|
||||||
|
|
||||||
@ -184,9 +183,7 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
|
|||||||
g_slist_free (surface->sub.pending_placement_ops);
|
g_slist_free (surface->sub.pending_placement_ops);
|
||||||
surface->sub.pending_placement_ops = NULL;
|
surface->sub.pending_placement_ops = NULL;
|
||||||
|
|
||||||
window_actor = meta_window_actor_wayland_from_surface (surface);
|
meta_wayland_surface_notify_subsurface_state_changed (parent);
|
||||||
if (window_actor)
|
|
||||||
meta_window_actor_wayland_rebuild_surface_tree (window_actor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_surface_effectively_synchronized (surface))
|
if (is_surface_effectively_synchronized (surface))
|
||||||
@ -258,6 +255,16 @@ meta_wayland_subsurface_should_cache_state (MetaWaylandSurfaceRole *surface_role
|
|||||||
return TRUE;
|
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
|
static double
|
||||||
meta_wayland_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
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->get_toplevel = meta_wayland_subsurface_get_toplevel;
|
||||||
surface_role_class->should_cache_state = meta_wayland_subsurface_should_cache_state;
|
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 =
|
actor_surface_class->get_geometry_scale =
|
||||||
meta_wayland_subsurface_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 *surface = wl_resource_get_user_data (surface_resource);
|
||||||
MetaWaylandSurface *parent = wl_resource_get_user_data (parent_resource);
|
MetaWaylandSurface *parent = wl_resource_get_user_data (parent_resource);
|
||||||
MetaWindow *toplevel_window;
|
MetaWindow *toplevel_window;
|
||||||
MetaWindowActor *window_actor;
|
|
||||||
|
|
||||||
if (surface->wl_subsurface)
|
if (surface->wl_subsurface)
|
||||||
{
|
{
|
||||||
@ -564,9 +572,7 @@ wl_subcompositor_get_subsurface (struct wl_client *client,
|
|||||||
g_node_append (parent->subsurface_branch_node,
|
g_node_append (parent->subsurface_branch_node,
|
||||||
surface->subsurface_branch_node);
|
surface->subsurface_branch_node);
|
||||||
|
|
||||||
window_actor = meta_window_actor_wayland_from_surface (surface);
|
meta_wayland_surface_notify_subsurface_state_changed (parent);
|
||||||
if (window_actor)
|
|
||||||
meta_window_actor_wayland_rebuild_surface_tree (window_actor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_subcompositor_interface meta_wayland_subcompositor_interface = {
|
static const struct wl_subcompositor_interface meta_wayland_subcompositor_interface = {
|
||||||
|
@ -1843,6 +1843,24 @@ meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface)
|
|||||||
return meta_wayland_surface_role_should_cache_state (surface->role);
|
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 *
|
MetaWaylandSurface *
|
||||||
meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role)
|
meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,7 @@ struct _MetaWaylandSurfaceRoleClass
|
|||||||
MetaLogicalMonitor *logical_monitor);
|
MetaLogicalMonitor *logical_monitor);
|
||||||
MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role);
|
MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role);
|
||||||
gboolean (*should_cache_state) (MetaWaylandSurfaceRole *surface_role);
|
gboolean (*should_cache_state) (MetaWaylandSurfaceRole *surface_role);
|
||||||
|
void (*notify_subsurface_state_changed) (MetaWaylandSurfaceRole *surface_role);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MetaWaylandSurfaceState
|
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_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_width (MetaWaylandSurface *surface);
|
||||||
int meta_wayland_surface_get_height (MetaWaylandSurface *surface);
|
int meta_wayland_surface_get_height (MetaWaylandSurface *surface);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user