From 9ed6a3dffb75676dca31ec6d9767ac5caaab9539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 1 Nov 2022 16:43:03 +0100 Subject: [PATCH] wayland/surface: Add role commit_state callback Which gets called when pending state is committed for the surface. This callback may amend the pending transaction or surface state as needed. Part-of: --- src/wayland/meta-wayland-surface.c | 20 ++++++++++++++++++++ src/wayland/meta-wayland-surface.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 31ffff1c5..7beb0ab60 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -114,6 +114,11 @@ guint surface_signals[N_SURFACE_SIGNALS] = { 0 }; static void meta_wayland_surface_role_assigned (MetaWaylandSurfaceRole *surface_role); +static void +meta_wayland_surface_role_commit_state (MetaWaylandSurfaceRole *surface_role, + MetaWaylandTransaction *transaction, + MetaWaylandSurfaceState *pending); + static void meta_wayland_surface_role_pre_apply_state (MetaWaylandSurfaceRole *surface_role, MetaWaylandSurfaceState *pending); @@ -1023,6 +1028,9 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface) else transaction = meta_wayland_transaction_new (surface->compositor); + if (surface->role) + meta_wayland_surface_role_commit_state (surface->role, transaction, pending); + meta_wayland_transaction_merge_pending_state (transaction, surface); META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (&surface->protocol_state, @@ -1952,6 +1960,18 @@ meta_wayland_surface_role_assigned (MetaWaylandSurfaceRole *surface_role) META_WAYLAND_SURFACE_ROLE_GET_CLASS (surface_role)->assigned (surface_role); } +static void +meta_wayland_surface_role_commit_state (MetaWaylandSurfaceRole *surface_role, + MetaWaylandTransaction *transaction, + MetaWaylandSurfaceState *pending) +{ + MetaWaylandSurfaceRoleClass *klass; + + klass = META_WAYLAND_SURFACE_ROLE_GET_CLASS (surface_role); + if (klass->commit_state) + klass->commit_state (surface_role, transaction, pending); +} + static void meta_wayland_surface_role_pre_apply_state (MetaWaylandSurfaceRole *surface_role, MetaWaylandSurfaceState *pending) diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 072d7f8eb..307038a2c 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -54,6 +54,9 @@ struct _MetaWaylandSurfaceRoleClass GObjectClass parent_class; void (*assigned) (MetaWaylandSurfaceRole *surface_role); + void (*commit_state) (MetaWaylandSurfaceRole *surface_role, + MetaWaylandTransaction *transaction, + MetaWaylandSurfaceState *pending); void (*pre_apply_state) (MetaWaylandSurfaceRole *surface_role, MetaWaylandSurfaceState *pending); void (*apply_state) (MetaWaylandSurfaceRole *surface_role,