wayland: Replace manual GNode subsurface iteration with macro
Similar to wl_list_foreach(), add META_WAYLAND_SURFACE_FOREACH_SUBSURFACE() that iterates over all the subsurfaces of a surface, without the caller needing to care about implementation details, such as leaf nodes vs non-leaf nodes. https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
This commit is contained in:
parent
76ee026caa
commit
fcfe90aa9f
@ -147,9 +147,9 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
|
|||||||
meta_wayland_surface_role_get_surface (surface_role);
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
MetaSurfaceActor *surface_actor;
|
MetaSurfaceActor *surface_actor;
|
||||||
MetaShapedTexture *stex;
|
MetaShapedTexture *stex;
|
||||||
GNode *n;
|
|
||||||
cairo_rectangle_int_t surface_rect;
|
cairo_rectangle_int_t surface_rect;
|
||||||
int geometry_scale;
|
int geometry_scale;
|
||||||
|
MetaWaylandSurface *subsurface_surface;
|
||||||
|
|
||||||
surface_actor = priv->actor;
|
surface_actor = priv->actor;
|
||||||
stex = meta_surface_actor_get_texture (surface_actor);
|
stex = meta_surface_actor_get_texture (surface_actor);
|
||||||
@ -213,19 +213,12 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor
|
|||||||
meta_surface_actor_reset_viewport_dst_size (surface_actor);
|
meta_surface_actor_reset_viewport_dst_size (surface_actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
||||||
n;
|
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *subsurface_surface = n->data;
|
MetaWaylandActorSurface *actor_surface;
|
||||||
MetaWaylandActorSurface *subsurface_actor_surface;
|
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
actor_surface = META_WAYLAND_ACTOR_SURFACE (subsurface_surface->role);
|
||||||
continue;
|
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
||||||
|
|
||||||
subsurface_actor_surface =
|
|
||||||
META_WAYLAND_ACTOR_SURFACE (subsurface_surface->role);
|
|
||||||
meta_wayland_actor_surface_sync_actor_state (subsurface_actor_surface);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1205,20 +1205,13 @@ static gboolean
|
|||||||
pointer_can_grab_surface (MetaWaylandPointer *pointer,
|
pointer_can_grab_surface (MetaWaylandPointer *pointer,
|
||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
GNode *n;
|
MetaWaylandSurface *subsurface;
|
||||||
|
|
||||||
if (pointer->focus_surface == surface)
|
if (pointer->focus_surface == surface)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface)
|
||||||
n;
|
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *subsurface = n->data;
|
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pointer_can_grab_surface (pointer, subsurface))
|
if (pointer_can_grab_surface (pointer, subsurface))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -43,23 +43,17 @@ meta_wayland_shell_surface_calculate_geometry (MetaWaylandShellSurface *shell_su
|
|||||||
MetaWaylandSurface *surface =
|
MetaWaylandSurface *surface =
|
||||||
meta_wayland_surface_role_get_surface (surface_role);
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
MetaRectangle geometry;
|
MetaRectangle geometry;
|
||||||
GNode *n;
|
MetaWaylandSurface *subsurface_surface;
|
||||||
|
|
||||||
geometry = (MetaRectangle) {
|
geometry = (MetaRectangle) {
|
||||||
.width = meta_wayland_surface_get_width (surface),
|
.width = meta_wayland_surface_get_width (surface),
|
||||||
.height = meta_wayland_surface_get_height (surface),
|
.height = meta_wayland_surface_get_height (surface),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
||||||
n;
|
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *subsurface_surface = n->data;
|
|
||||||
MetaWaylandSubsurface *subsurface;
|
MetaWaylandSubsurface *subsurface;
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
||||||
meta_wayland_subsurface_union_geometry (subsurface,
|
meta_wayland_subsurface_union_geometry (subsurface,
|
||||||
0, 0,
|
0, 0,
|
||||||
|
@ -204,7 +204,7 @@ meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
|
|||||||
MetaWaylandSurface *surface =
|
MetaWaylandSurface *surface =
|
||||||
meta_wayland_surface_role_get_surface (surface_role);
|
meta_wayland_surface_role_get_surface (surface_role);
|
||||||
MetaRectangle geometry;
|
MetaRectangle geometry;
|
||||||
GNode *n;
|
MetaWaylandSurface *subsurface_surface;
|
||||||
|
|
||||||
geometry = (MetaRectangle) {
|
geometry = (MetaRectangle) {
|
||||||
.x = surface->offset_x + surface->sub.x,
|
.x = surface->offset_x + surface->sub.x,
|
||||||
@ -215,16 +215,10 @@ meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
|
|||||||
|
|
||||||
meta_rectangle_union (out_geometry, &geometry, out_geometry);
|
meta_rectangle_union (out_geometry, &geometry, out_geometry);
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
||||||
n;
|
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *subsurface_surface = n->data;
|
|
||||||
MetaWaylandSubsurface *subsurface;
|
MetaWaylandSubsurface *subsurface;
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
||||||
meta_wayland_subsurface_union_geometry (subsurface,
|
meta_wayland_subsurface_union_geometry (subsurface,
|
||||||
parent_x + geometry.x,
|
parent_x + geometry.x,
|
||||||
|
@ -600,20 +600,6 @@ meta_wayland_surface_state_class_init (MetaWaylandSurfaceStateClass *klass)
|
|||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
parent_surface_state_applied (GNode *subsurface_node,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
MetaWaylandSurface *surface = subsurface_node->data;
|
|
||||||
MetaWaylandSubsurface *subsurface;
|
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (subsurface_node))
|
|
||||||
return;
|
|
||||||
|
|
||||||
subsurface = META_WAYLAND_SUBSURFACE (surface->role);
|
|
||||||
meta_wayland_subsurface_parent_state_applied (subsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_surface_cache_pending_frame_callbacks (MetaWaylandSurface *surface,
|
meta_wayland_surface_cache_pending_frame_callbacks (MetaWaylandSurface *surface,
|
||||||
MetaWaylandSurfaceState *pending)
|
MetaWaylandSurfaceState *pending)
|
||||||
@ -627,6 +613,7 @@ static void
|
|||||||
meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
|
meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
|
||||||
MetaWaylandSurfaceState *state)
|
MetaWaylandSurfaceState *state)
|
||||||
{
|
{
|
||||||
|
MetaWaylandSurface *subsurface_surface;
|
||||||
gboolean had_damage = FALSE;
|
gboolean had_damage = FALSE;
|
||||||
|
|
||||||
g_signal_emit (surface, surface_signals[SURFACE_PRE_STATE_APPLIED], 0);
|
g_signal_emit (surface, surface_signals[SURFACE_PRE_STATE_APPLIED], 0);
|
||||||
@ -802,10 +789,13 @@ cleanup:
|
|||||||
|
|
||||||
meta_wayland_surface_state_reset (state);
|
meta_wayland_surface_state_reset (state);
|
||||||
|
|
||||||
g_node_children_foreach (surface->subsurface_branch_node,
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
||||||
G_TRAVERSE_ALL,
|
{
|
||||||
parent_surface_state_applied,
|
MetaWaylandSubsurface *subsurface;
|
||||||
NULL);
|
|
||||||
|
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
||||||
|
meta_wayland_subsurface_parent_state_applied (subsurface);
|
||||||
|
}
|
||||||
|
|
||||||
if (had_damage)
|
if (had_damage)
|
||||||
{
|
{
|
||||||
@ -1287,22 +1277,14 @@ meta_wayland_surface_update_outputs (MetaWaylandSurface *surface)
|
|||||||
static void
|
static void
|
||||||
meta_wayland_surface_update_outputs_recursively (MetaWaylandSurface *surface)
|
meta_wayland_surface_update_outputs_recursively (MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
GNode *n;
|
MetaWaylandSurface *subsurface_surface;
|
||||||
|
|
||||||
meta_wayland_surface_update_outputs (surface);
|
meta_wayland_surface_update_outputs (surface);
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
||||||
n;
|
meta_wayland_surface_update_outputs_recursively (subsurface_surface);
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
meta_wayland_surface_update_outputs_recursively (n->data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_surface_set_window (MetaWaylandSurface *surface,
|
meta_wayland_surface_set_window (MetaWaylandSurface *surface,
|
||||||
MetaWindow *window)
|
MetaWindow *window)
|
||||||
|
@ -328,4 +328,38 @@ void meta_wayland_surface_notify_geometry_changed (MetaWaylandSur
|
|||||||
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);
|
||||||
|
|
||||||
|
static inline GNode *
|
||||||
|
meta_get_next_subsurface_sibling (GNode *n)
|
||||||
|
{
|
||||||
|
GNode *next;
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
next = g_node_next_sibling (n);
|
||||||
|
if (!next)
|
||||||
|
return NULL;
|
||||||
|
if (!G_NODE_IS_LEAF (next))
|
||||||
|
return next;
|
||||||
|
else
|
||||||
|
return meta_get_next_subsurface_sibling (next);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline GNode *
|
||||||
|
meta_get_first_subsurface_node (MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
GNode *n;
|
||||||
|
|
||||||
|
n = g_node_first_child (surface->subsurface_branch_node);
|
||||||
|
if (!G_NODE_IS_LEAF (n))
|
||||||
|
return n;
|
||||||
|
else
|
||||||
|
return meta_get_next_subsurface_sibling (n);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define META_WAYLAND_SURFACE_FOREACH_SUBSURFACE(surface, subsurface) \
|
||||||
|
for (GNode *G_PASTE(__n, __LINE__) = meta_get_first_subsurface_node ((surface)); \
|
||||||
|
(subsurface = (G_PASTE (__n, __LINE__) ? G_PASTE (__n, __LINE__)->data : NULL)); \
|
||||||
|
G_PASTE (__n, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__)))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -989,20 +989,13 @@ static gboolean
|
|||||||
tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
GNode *n;
|
MetaWaylandSurface *subsurface;
|
||||||
|
|
||||||
if (tool->focus_surface == surface)
|
if (tool->focus_surface == surface)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
for (n = g_node_first_child (surface->subsurface_branch_node);
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface)
|
||||||
n;
|
|
||||||
n = g_node_next_sibling (n))
|
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *subsurface = n->data;
|
|
||||||
|
|
||||||
if (G_NODE_IS_LEAF (n))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (tablet_tool_can_grab_surface (tool, subsurface))
|
if (tablet_tool_can_grab_surface (tool, subsurface))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user