wayland/surface: Use transactions for applying committed states

A transaction contains the committed state for a surface, plus any
cached state for synchronized subsurfaces.

v2:
* Handle sub-surface positions separately from surface states.
v3:
* Sync child states only for surfaces with state in the transaction.
v4: (Jonas Ådahl)
* Drop unnecessary g_object_new call from wl_subsurface_set_desync. (me)
* Fix indentation & formatting in meta_wayland_surface_commit.
* Add meta_wayland_surface_state_new helper function.
* Fix alignment of meta_wayland_transaction_apply_subsurface_position
  parameters.
* Add curly braces around meta_wayland_transaction_sync_child_states
  call in meta_wayland_transaction_apply.
v5:
* Make meta_wayland_surface_state_new an inline function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880>
This commit is contained in:
Michel Dänzer
2021-05-28 12:39:48 +02:00
committed by Michel Dänzer
parent 56260e3e07
commit 0bae4ece19
6 changed files with 125 additions and 60 deletions

View File

@ -28,6 +28,7 @@
#include "wayland/meta-wayland-actor-surface.h"
#include "wayland/meta-wayland-buffer.h"
#include "wayland/meta-wayland-surface.h"
#include "wayland/meta-wayland-transaction.h"
#include "wayland/meta-window-wayland.h"
struct _MetaWaylandSubsurface
@ -105,28 +106,6 @@ is_sibling (MetaWaylandSurface *surface,
return surface != sibling && surface->sub.parent == sibling->sub.parent;
}
void
meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
{
MetaWaylandSurfaceRole *surface_role = META_WAYLAND_SURFACE_ROLE (subsurface);
MetaWaylandActorSurface *actor_surface =
META_WAYLAND_ACTOR_SURFACE (subsurface);
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
if (surface->sub.pending_pos)
{
surface->sub.x = surface->sub.pending_x;
surface->sub.y = surface->sub.pending_y;
surface->sub.pending_pos = FALSE;
}
if (meta_wayland_surface_is_synchronized (surface))
meta_wayland_surface_apply_cached_state (surface);
meta_wayland_actor_surface_sync_actor_state (actor_surface);
}
void
meta_wayland_subsurface_union_geometry (MetaWaylandSubsurface *subsurface,
int parent_x,
@ -452,7 +431,13 @@ wl_subsurface_set_desync (struct wl_client *client,
meta_wayland_surface_is_synchronized (surface->sub.parent);
if (!is_parent_effectively_synchronized)
meta_wayland_surface_apply_cached_state (surface);
{
MetaWaylandTransaction *transaction;
transaction = meta_wayland_transaction_new (surface->compositor);
meta_wayland_transaction_add_cached_states (transaction, surface);
meta_wayland_transaction_commit (transaction);
}
surface->sub.synchronous = FALSE;
}