mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
wayland: Use helper to access pending state from the outside
With the eventual aim of exposing the internals of MetaWaylandSurface outside of meta-wayland-surface.c, make users of the pending state use a helper to fetch it. While at it, rename the struct field to something more descriptive. https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
This commit is contained in:
parent
8dc730e5ca
commit
d60d671fec
@ -340,6 +340,7 @@ zxdg_toplevel_v6_set_max_size (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
MetaWindow *window;
|
||||
|
||||
window = surface->window;
|
||||
@ -355,9 +356,10 @@ zxdg_toplevel_v6_set_max_size (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->has_new_max_size = TRUE;
|
||||
surface->pending->new_max_width = width;
|
||||
surface->pending->new_max_height = height;
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_max_size = TRUE;
|
||||
pending->new_max_width = width;
|
||||
pending->new_max_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -367,6 +369,7 @@ zxdg_toplevel_v6_set_min_size (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
MetaWindow *window;
|
||||
|
||||
window = surface->window;
|
||||
@ -382,9 +385,10 @@ zxdg_toplevel_v6_set_min_size (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->has_new_min_size = TRUE;
|
||||
surface->pending->new_min_width = width;
|
||||
surface->pending->new_min_height = height;
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_min_size = TRUE;
|
||||
pending->new_min_width = width;
|
||||
pending->new_min_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1288,12 +1292,14 @@ zxdg_surface_v6_set_window_geometry (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
surface->pending->has_new_geometry = TRUE;
|
||||
surface->pending->new_geometry.x = x;
|
||||
surface->pending->new_geometry.y = y;
|
||||
surface->pending->new_geometry.width = width;
|
||||
surface->pending->new_geometry.height = height;
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_geometry = TRUE;
|
||||
pending->new_geometry.x = x;
|
||||
pending->new_geometry.y = y;
|
||||
pending->new_geometry.width = width;
|
||||
pending->new_geometry.height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -670,10 +670,11 @@ get_pending_constraint_state_container (MetaWaylandPendingState *pending)
|
||||
static MetaWaylandPendingConstraintState *
|
||||
get_pending_constraint_state (MetaWaylandPointerConstraint *constraint)
|
||||
{
|
||||
MetaWaylandPendingState *pending = constraint->surface->pending;
|
||||
MetaWaylandPendingState *pending;
|
||||
MetaWaylandPendingConstraintStateContainer *container;
|
||||
GList *l;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (constraint->surface);
|
||||
container = get_pending_constraint_state_container (pending);
|
||||
for (l = container->pending_constraint_states; l; l = l->next)
|
||||
{
|
||||
@ -765,10 +766,11 @@ pending_constraint_state_applied (MetaWaylandPendingState *pending,
|
||||
static MetaWaylandPendingConstraintState *
|
||||
ensure_pending_constraint_state (MetaWaylandPointerConstraint *constraint)
|
||||
{
|
||||
MetaWaylandPendingState *pending = constraint->surface->pending;
|
||||
MetaWaylandPendingState *pending;
|
||||
MetaWaylandPendingConstraintStateContainer *container;
|
||||
MetaWaylandPendingConstraintState *constraint_pending;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (constraint->surface);
|
||||
container = ensure_pending_constraint_state_container (pending);
|
||||
constraint_pending = get_pending_constraint_state (constraint);
|
||||
if (!constraint_pending)
|
||||
|
@ -817,15 +817,23 @@ cleanup:
|
||||
}
|
||||
}
|
||||
|
||||
MetaWaylandPendingState *
|
||||
meta_wayland_surface_get_pending_state (MetaWaylandSurface *surface)
|
||||
{
|
||||
return surface->pending_state;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_commit (MetaWaylandSurface *surface)
|
||||
{
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaWaylandSurfaceCommit,
|
||||
"WaylandSurface (commit)");
|
||||
|
||||
if (surface->pending->buffer &&
|
||||
!meta_wayland_buffer_is_realized (surface->pending->buffer))
|
||||
meta_wayland_buffer_realize (surface->pending->buffer);
|
||||
if (pending->buffer &&
|
||||
!meta_wayland_buffer_is_realized (pending->buffer))
|
||||
meta_wayland_buffer_realize (pending->buffer);
|
||||
|
||||
/*
|
||||
* If this is a sub-surface and it is in effective synchronous mode, only
|
||||
@ -836,9 +844,9 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
|
||||
* surface is in effective desynchronized mode.
|
||||
*/
|
||||
if (meta_wayland_surface_should_cache_state (surface))
|
||||
merge_pending_state (surface->pending, surface->sub.pending);
|
||||
merge_pending_state (pending, surface->sub.pending);
|
||||
else
|
||||
meta_wayland_surface_apply_pending_state (surface, surface->pending);
|
||||
meta_wayland_surface_apply_pending_state (surface, pending);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -856,6 +864,7 @@ wl_surface_attach (struct wl_client *client,
|
||||
{
|
||||
MetaWaylandSurface *surface =
|
||||
wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
MetaWaylandBuffer *buffer;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
@ -867,23 +876,23 @@ wl_surface_attach (struct wl_client *client,
|
||||
else
|
||||
buffer = NULL;
|
||||
|
||||
if (surface->pending->buffer)
|
||||
if (surface->pending_state->buffer)
|
||||
{
|
||||
g_clear_signal_handler (&surface->pending->buffer_destroy_handler_id,
|
||||
surface->pending->buffer);
|
||||
g_clear_signal_handler (&pending->buffer_destroy_handler_id,
|
||||
pending->buffer);
|
||||
}
|
||||
|
||||
surface->pending->newly_attached = TRUE;
|
||||
surface->pending->buffer = buffer;
|
||||
surface->pending->dx = dx;
|
||||
surface->pending->dy = dy;
|
||||
pending->newly_attached = TRUE;
|
||||
pending->buffer = buffer;
|
||||
pending->dx = dx;
|
||||
pending->dy = dy;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
surface->pending->buffer_destroy_handler_id =
|
||||
pending->buffer_destroy_handler_id =
|
||||
g_signal_connect (buffer, "resource-destroyed",
|
||||
G_CALLBACK (pending_buffer_resource_destroyed),
|
||||
surface->pending);
|
||||
pending);
|
||||
}
|
||||
}
|
||||
|
||||
@ -896,6 +905,7 @@ wl_surface_damage (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
cairo_rectangle_int_t rectangle;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
@ -908,7 +918,7 @@ wl_surface_damage (struct wl_client *client,
|
||||
.width = width,
|
||||
.height = height
|
||||
};
|
||||
cairo_region_union_rectangle (surface->pending->surface_damage, &rectangle);
|
||||
cairo_region_union_rectangle (pending->surface_damage, &rectangle);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -928,6 +938,7 @@ wl_surface_frame (struct wl_client *client,
|
||||
{
|
||||
MetaWaylandFrameCallback *callback;
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
@ -942,7 +953,7 @@ wl_surface_frame (struct wl_client *client,
|
||||
wl_resource_set_implementation (callback->resource, NULL, callback,
|
||||
destroy_frame_callback);
|
||||
|
||||
wl_list_insert (surface->pending->frame_callback_list.prev, &callback->link);
|
||||
wl_list_insert (pending->frame_callback_list.prev, &callback->link);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -951,19 +962,20 @@ wl_surface_set_opaque_region (struct wl_client *client,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending->opaque_region, cairo_region_destroy);
|
||||
g_clear_pointer (&pending->opaque_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
cairo_region_t *cr_region = meta_wayland_region_peek_cairo_region (region);
|
||||
surface->pending->opaque_region = cairo_region_copy (cr_region);
|
||||
pending->opaque_region = cairo_region_copy (cr_region);
|
||||
}
|
||||
surface->pending->opaque_region_set = TRUE;
|
||||
pending->opaque_region_set = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -972,19 +984,20 @@ wl_surface_set_input_region (struct wl_client *client,
|
||||
struct wl_resource *region_resource)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&surface->pending->input_region, cairo_region_destroy);
|
||||
g_clear_pointer (&pending->input_region, cairo_region_destroy);
|
||||
if (region_resource)
|
||||
{
|
||||
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
||||
cairo_region_t *cr_region = meta_wayland_region_peek_cairo_region (region);
|
||||
surface->pending->input_region = cairo_region_copy (cr_region);
|
||||
pending->input_region = cairo_region_copy (cr_region);
|
||||
}
|
||||
surface->pending->input_region_set = TRUE;
|
||||
pending->input_region_set = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1034,6 +1047,7 @@ wl_surface_set_buffer_transform (struct wl_client *client,
|
||||
int32_t transform)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
MetaMonitorTransform buffer_transform;
|
||||
|
||||
buffer_transform = transform_from_wl_output_transform (transform);
|
||||
@ -1047,8 +1061,8 @@ wl_surface_set_buffer_transform (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->buffer_transform = buffer_transform;
|
||||
surface->pending->has_new_buffer_transform = TRUE;
|
||||
pending->buffer_transform = buffer_transform;
|
||||
pending->has_new_buffer_transform = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1057,6 +1071,7 @@ wl_surface_set_buffer_scale (struct wl_client *client,
|
||||
int scale)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
|
||||
if (scale <= 0)
|
||||
{
|
||||
@ -1067,7 +1082,7 @@ wl_surface_set_buffer_scale (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->scale = scale;
|
||||
pending->scale = scale;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1079,6 +1094,7 @@ wl_surface_damage_buffer (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
MetaWaylandPendingState *pending = surface->pending_state;
|
||||
cairo_rectangle_int_t rectangle;
|
||||
|
||||
/* X11 unmanaged window */
|
||||
@ -1091,7 +1107,7 @@ wl_surface_damage_buffer (struct wl_client *client,
|
||||
.width = width,
|
||||
.height = height
|
||||
};
|
||||
cairo_region_union_rectangle (surface->pending->buffer_damage, &rectangle);
|
||||
cairo_region_union_rectangle (pending->buffer_damage, &rectangle);
|
||||
}
|
||||
|
||||
static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
|
||||
@ -1328,7 +1344,7 @@ wl_surface_destructor (struct wl_resource *resource)
|
||||
g_clear_pointer (&surface->texture, cogl_object_unref);
|
||||
g_clear_object (&surface->buffer_ref.buffer);
|
||||
|
||||
g_clear_object (&surface->pending);
|
||||
g_clear_object (&surface->pending_state);
|
||||
|
||||
if (surface->opaque_region)
|
||||
cairo_region_destroy (surface->opaque_region);
|
||||
@ -1631,7 +1647,7 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
|
||||
static void
|
||||
meta_wayland_surface_init (MetaWaylandSurface *surface)
|
||||
{
|
||||
surface->pending = g_object_new (META_TYPE_WAYLAND_PENDING_STATE, NULL);
|
||||
surface->pending_state = g_object_new (META_TYPE_WAYLAND_PENDING_STATE, NULL);
|
||||
surface->subsurface_branch_node = g_node_new (surface);
|
||||
surface->subsurface_leaf_node =
|
||||
g_node_prepend_data (surface->subsurface_branch_node, surface);
|
||||
|
@ -177,7 +177,7 @@ struct _MetaWaylandSurface
|
||||
} dnd;
|
||||
|
||||
/* All the pending state that wl_surface.commit will apply. */
|
||||
MetaWaylandPendingState *pending;
|
||||
MetaWaylandPendingState *pending_state;
|
||||
|
||||
/* Extension resources. */
|
||||
struct wl_resource *wl_subsurface;
|
||||
@ -231,6 +231,9 @@ MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *composit
|
||||
struct wl_resource *compositor_resource,
|
||||
guint32 id);
|
||||
|
||||
MetaWaylandPendingState *
|
||||
meta_wayland_surface_get_pending_state (MetaWaylandSurface *surface);
|
||||
|
||||
void meta_wayland_surface_apply_pending_state (MetaWaylandSurface *surface,
|
||||
MetaWaylandPendingState *pending);
|
||||
|
||||
|
@ -37,6 +37,7 @@ static void
|
||||
wp_viewport_destructor (struct wl_resource *resource)
|
||||
{
|
||||
MetaWaylandSurface *surface;
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
surface = wl_resource_get_user_data (resource);
|
||||
if (!surface)
|
||||
@ -44,10 +45,11 @@ wp_viewport_destructor (struct wl_resource *resource)
|
||||
|
||||
g_clear_signal_handler (&surface->viewport.destroy_handler_id, surface);
|
||||
|
||||
surface->pending->viewport_src_rect.size.width = -1;
|
||||
surface->pending->viewport_dst_width = -1;
|
||||
surface->pending->has_new_viewport_src_rect = TRUE;
|
||||
surface->pending->has_new_viewport_dst_size = TRUE;
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->viewport_src_rect.size.width = -1;
|
||||
pending->viewport_dst_width = -1;
|
||||
pending->has_new_viewport_src_rect = TRUE;
|
||||
pending->has_new_viewport_dst_size = TRUE;
|
||||
|
||||
surface->viewport.resource = NULL;
|
||||
}
|
||||
@ -98,11 +100,14 @@ wp_viewport_set_source (struct wl_client *client,
|
||||
(new_x == -1 && new_y == -1 &&
|
||||
new_width == -1 && new_height == -1))
|
||||
{
|
||||
surface->pending->viewport_src_rect.origin.x = new_x;
|
||||
surface->pending->viewport_src_rect.origin.y = new_y;
|
||||
surface->pending->viewport_src_rect.size.width = new_width;
|
||||
surface->pending->viewport_src_rect.size.height = new_height;
|
||||
surface->pending->has_new_viewport_src_rect = TRUE;
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->viewport_src_rect.origin.x = new_x;
|
||||
pending->viewport_src_rect.origin.y = new_y;
|
||||
pending->viewport_src_rect.size.width = new_width;
|
||||
pending->viewport_src_rect.size.height = new_height;
|
||||
pending->has_new_viewport_src_rect = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -134,9 +139,12 @@ wp_viewport_set_destination (struct wl_client *client,
|
||||
if ((dst_width > 0 && dst_height > 0) ||
|
||||
(dst_width == -1 && dst_height == -1))
|
||||
{
|
||||
surface->pending->viewport_dst_width = dst_width;
|
||||
surface->pending->viewport_dst_height = dst_height;
|
||||
surface->pending->has_new_viewport_dst_size = TRUE;
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->viewport_dst_width = dst_width;
|
||||
pending->viewport_dst_height = dst_height;
|
||||
pending->has_new_viewport_dst_size = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -346,6 +346,7 @@ xdg_toplevel_set_max_size (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
if (width < 0 || height < 0)
|
||||
{
|
||||
@ -356,9 +357,11 @@ xdg_toplevel_set_max_size (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->has_new_max_size = TRUE;
|
||||
surface->pending->new_max_width = width;
|
||||
surface->pending->new_max_height = height;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_max_size = TRUE;
|
||||
pending->new_max_width = width;
|
||||
pending->new_max_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -368,6 +371,7 @@ xdg_toplevel_set_min_size (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_toplevel_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
if (width < 0 || height < 0)
|
||||
{
|
||||
@ -378,9 +382,11 @@ xdg_toplevel_set_min_size (struct wl_client *client,
|
||||
return;
|
||||
}
|
||||
|
||||
surface->pending->has_new_min_size = TRUE;
|
||||
surface->pending->new_min_width = width;
|
||||
surface->pending->new_min_height = height;
|
||||
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_min_size = TRUE;
|
||||
pending->new_min_width = width;
|
||||
pending->new_min_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1377,12 +1383,14 @@ xdg_surface_set_window_geometry (struct wl_client *client,
|
||||
int32_t height)
|
||||
{
|
||||
MetaWaylandSurface *surface = surface_from_xdg_surface_resource (resource);
|
||||
MetaWaylandPendingState *pending;
|
||||
|
||||
surface->pending->has_new_geometry = TRUE;
|
||||
surface->pending->new_geometry.x = x;
|
||||
surface->pending->new_geometry.y = y;
|
||||
surface->pending->new_geometry.width = width;
|
||||
surface->pending->new_geometry.height = height;
|
||||
pending = meta_wayland_surface_get_pending_state (surface);
|
||||
pending->has_new_geometry = TRUE;
|
||||
pending->new_geometry.x = x;
|
||||
pending->new_geometry.y = y;
|
||||
pending->new_geometry.width = width;
|
||||
pending->new_geometry.height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user