wayland: Ensure that opaque / input regions are set at commit time

The protocol specification says that opaque / input regions should be
considered pending state and should only be actually swapped out when
the surface is committed, so it can be set atomically.
This commit is contained in:
Jasper St. Pierre 2013-08-31 13:27:41 -04:00
parent ad4053ab84
commit b1206ceb66
2 changed files with 16 additions and 4 deletions

View File

@ -89,6 +89,9 @@ struct _MetaWaylandSurface
/* wl_surface.damage */
cairo_region_t *damage;
cairo_region_t *input_region;
cairo_region_t *opaque_region;
/* wl_surface.frame */
struct wl_list frame_callback_list;
} pending;

View File

@ -335,8 +335,8 @@ meta_wayland_surface_set_opaque_region (struct wl_client *client,
if (!surface)
return;
if (surface->window)
meta_window_set_opaque_region (surface->window, cairo_region_copy (region->region));
g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
surface->pending.opaque_region = cairo_region_copy (region->region);
}
static void
@ -351,8 +351,8 @@ meta_wayland_surface_set_input_region (struct wl_client *client,
if (!surface)
return;
if (surface->window)
meta_window_set_input_region (surface->window, cairo_region_copy (region->region));
g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
surface->pending.input_region = cairo_region_copy (region->region);
}
static void
@ -420,6 +420,15 @@ meta_wayland_surface_commit (struct wl_client *client,
surface->pending.sy = 0;
surface->pending.newly_attached = FALSE;
if (surface->window)
{
meta_window_set_opaque_region (surface->window, surface->pending.opaque_region);
g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
meta_window_set_input_region (surface->window, surface->pending.input_region);
g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
}
surface_process_damage (surface, surface->pending.damage);
empty_region (surface->pending.damage);