wayland-surface: Use the same commit() when commiting subsurface
Refactor our commit() implementation out of wl_surface_commit(), and pass the double-buffered state around to all our implementation methods. This allows us to drop a few lines destroying and reinitializing list of frame callbacks. This is a big cleanup for the next commit, though.
This commit is contained in:
parent
3e35cac67a
commit
d74796ee80
@ -249,11 +249,12 @@ ensure_buffer_texture (MetaWaylandBuffer *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cursor_surface_commit (MetaWaylandSurface *surface)
|
cursor_surface_commit (MetaWaylandSurface *surface,
|
||||||
|
MetaWaylandDoubleBufferedState *pending)
|
||||||
{
|
{
|
||||||
MetaWaylandBuffer *buffer = surface->pending.buffer;
|
MetaWaylandBuffer *buffer = pending->buffer;
|
||||||
|
|
||||||
if (surface->pending.newly_attached && buffer != surface->buffer_ref.buffer)
|
if (pending->newly_attached && buffer != surface->buffer_ref.buffer)
|
||||||
{
|
{
|
||||||
ensure_buffer_texture (buffer);
|
ensure_buffer_texture (buffer);
|
||||||
meta_wayland_buffer_reference (&surface->buffer_ref, buffer);
|
meta_wayland_buffer_reference (&surface->buffer_ref, buffer);
|
||||||
@ -263,7 +264,7 @@ cursor_surface_commit (MetaWaylandSurface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
actor_surface_commit (MetaWaylandSurface *surface,
|
actor_surface_commit (MetaWaylandSurface *surface,
|
||||||
MetaWaylandDoubleBufferedState *pending)
|
MetaWaylandDoubleBufferedState *pending)
|
||||||
{
|
{
|
||||||
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
||||||
@ -290,12 +291,13 @@ actor_surface_commit (MetaWaylandSurface *surface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
toplevel_surface_commit (MetaWaylandSurface *surface)
|
toplevel_surface_commit (MetaWaylandSurface *surface,
|
||||||
|
MetaWaylandDoubleBufferedState *pending)
|
||||||
{
|
{
|
||||||
if (actor_surface_commit (surface, &surface->pending))
|
if (actor_surface_commit (surface, pending))
|
||||||
{
|
{
|
||||||
MetaWindow *window = surface->window;
|
MetaWindow *window = surface->window;
|
||||||
MetaWaylandBuffer *buffer = surface->pending.buffer;
|
MetaWaylandBuffer *buffer = pending->buffer;
|
||||||
|
|
||||||
meta_window_set_surface_mapped (window, buffer != NULL);
|
meta_window_set_surface_mapped (window, buffer != NULL);
|
||||||
/* We resize X based surfaces according to X events */
|
/* We resize X based surfaces according to X events */
|
||||||
@ -308,10 +310,9 @@ toplevel_surface_commit (MetaWaylandSurface *surface)
|
|||||||
new_height = surface->buffer_ref.buffer->height;
|
new_height = surface->buffer_ref.buffer->height;
|
||||||
if (new_width != window->rect.width ||
|
if (new_width != window->rect.width ||
|
||||||
new_height != window->rect.height ||
|
new_height != window->rect.height ||
|
||||||
surface->pending.dx != 0 ||
|
pending->dx != 0 ||
|
||||||
surface->pending.dy != 0)
|
pending->dy != 0)
|
||||||
meta_window_move_resize_wayland (window, new_width, new_height,
|
meta_window_move_resize_wayland (window, new_width, new_height, pending->dx, pending->dy);
|
||||||
surface->pending.dx, surface->pending.dy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,7 +397,8 @@ move_double_buffered_state (MetaWaylandDoubleBufferedState *from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
subsurface_surface_commit (MetaWaylandSurface *surface)
|
subsurface_surface_commit (MetaWaylandSurface *surface,
|
||||||
|
MetaWaylandDoubleBufferedState *pending)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* If the sub-surface is in synchronous mode, post-pone the commit of its
|
* If the sub-surface is in synchronous mode, post-pone the commit of its
|
||||||
@ -412,13 +414,12 @@ subsurface_surface_commit (MetaWaylandSurface *surface)
|
|||||||
*/
|
*/
|
||||||
if (surface->sub.synchronous)
|
if (surface->sub.synchronous)
|
||||||
{
|
{
|
||||||
move_double_buffered_state (&surface->pending,
|
move_double_buffered_state (pending, &surface->sub.pending_surface_state);
|
||||||
&surface->sub.pending_surface_state);
|
|
||||||
}
|
}
|
||||||
else if (actor_surface_commit (surface, &surface->pending))
|
else if (actor_surface_commit (surface, pending))
|
||||||
{
|
{
|
||||||
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
||||||
MetaWaylandBuffer *buffer = surface->pending.buffer;
|
MetaWaylandBuffer *buffer = pending->buffer;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
@ -427,8 +428,8 @@ subsurface_surface_commit (MetaWaylandSurface *surface)
|
|||||||
clutter_actor_hide (CLUTTER_ACTOR (surface_actor));
|
clutter_actor_hide (CLUTTER_ACTOR (surface_actor));
|
||||||
|
|
||||||
clutter_actor_get_position (CLUTTER_ACTOR (surface_actor), &x, &y);
|
clutter_actor_get_position (CLUTTER_ACTOR (surface_actor), &x, &y);
|
||||||
x += surface->pending.dx;
|
x += pending->dx;
|
||||||
y += surface->pending.dy;
|
y += pending->dy;
|
||||||
clutter_actor_set_position (CLUTTER_ACTOR (surface_actor), x, y);
|
clutter_actor_set_position (CLUTTER_ACTOR (surface_actor), x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,41 +444,46 @@ parent_surface_committed (gpointer data, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_wayland_surface_commit (struct wl_client *client,
|
commit_double_buffered_state (MetaWaylandSurface *surface,
|
||||||
struct wl_resource *resource)
|
MetaWaylandDoubleBufferedState *pending)
|
||||||
{
|
{
|
||||||
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
MetaWaylandCompositor *compositor = surface->compositor;
|
||||||
MetaWaylandCompositor *compositor;
|
|
||||||
|
|
||||||
/* X11 unmanaged window */
|
|
||||||
if (!surface)
|
|
||||||
return;
|
|
||||||
|
|
||||||
compositor = surface->compositor;
|
|
||||||
|
|
||||||
if (surface == compositor->seat->sprite)
|
if (surface == compositor->seat->sprite)
|
||||||
cursor_surface_commit (surface);
|
cursor_surface_commit (surface, pending);
|
||||||
else if (surface->window)
|
else if (surface->window)
|
||||||
toplevel_surface_commit (surface);
|
toplevel_surface_commit (surface, pending);
|
||||||
else if (surface->subsurface.resource)
|
else if (surface->subsurface.resource)
|
||||||
subsurface_surface_commit (surface);
|
subsurface_surface_commit (surface, pending);
|
||||||
|
|
||||||
g_list_foreach (surface->subsurfaces,
|
g_list_foreach (surface->subsurfaces,
|
||||||
parent_surface_committed,
|
parent_surface_committed,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (surface->pending.buffer)
|
if (pending->buffer)
|
||||||
{
|
{
|
||||||
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
|
wl_list_remove (&pending->buffer_destroy_listener.link);
|
||||||
surface->pending.buffer = NULL;
|
pending->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wl_surface.frame */
|
/* wl_surface.frame */
|
||||||
wl_list_insert_list (&compositor->frame_callbacks,
|
wl_list_insert_list (&compositor->frame_callbacks, &pending->frame_callback_list);
|
||||||
&surface->pending.frame_callback_list);
|
wl_list_init (&pending->frame_callback_list);
|
||||||
wl_list_init (&surface->pending.frame_callback_list);
|
|
||||||
|
|
||||||
double_buffered_state_reset (&surface->pending);
|
double_buffered_state_reset (pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_wayland_surface_commit (struct wl_client *client,
|
||||||
|
struct wl_resource *resource)
|
||||||
|
{
|
||||||
|
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
||||||
|
|
||||||
|
/* X11 unmanaged window */
|
||||||
|
if (!surface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
commit_double_buffered_state (surface, &surface->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1081,9 +1087,7 @@ bind_gtk_shell (struct wl_client *client,
|
|||||||
static void
|
static void
|
||||||
subsurface_parent_surface_committed (MetaWaylandSurface *surface)
|
subsurface_parent_surface_committed (MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
MetaWaylandCompositor *compositor = surface->compositor;
|
MetaWaylandDoubleBufferedState *pending_surface_state = &surface->sub.pending_surface_state;
|
||||||
MetaWaylandDoubleBufferedState *pending_surface_state =
|
|
||||||
&surface->sub.pending_surface_state;
|
|
||||||
|
|
||||||
if (surface->sub.pending_pos)
|
if (surface->sub.pending_pos)
|
||||||
{
|
{
|
||||||
@ -1132,15 +1136,9 @@ subsurface_parent_surface_committed (MetaWaylandSurface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (surface->sub.synchronous)
|
if (surface->sub.synchronous)
|
||||||
{
|
commit_double_buffered_state (surface, pending_surface_state);
|
||||||
actor_surface_commit (surface, pending_surface_state);
|
|
||||||
|
|
||||||
wl_list_insert_list (&compositor->frame_callbacks,
|
double_buffered_state_reset (pending_surface_state);
|
||||||
&pending_surface_state->frame_callback_list);
|
|
||||||
wl_list_init (&pending_surface_state->frame_callback_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
double_buffered_state_reset (&surface->sub.pending_surface_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user