wayland: Let shell surface role sync generic window state

Instead of having each final role do the same call, lets just make the
common role object deal with synchronizing window buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
This commit is contained in:
Jonas Ådahl 2016-07-01 15:59:23 +08:00
parent a5efa30f6c
commit f21df37190
4 changed files with 32 additions and 23 deletions

View File

@ -453,22 +453,6 @@ queue_surface_actor_frame_callbacks (MetaWaylandSurface *surface,
wl_list_init (&pending->frame_callback_list);
}
void
meta_wayland_surface_apply_window_state (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending)
{
MetaSurfaceActorWayland *actor =
META_SURFACE_ACTOR_WAYLAND (surface->surface_actor);
MetaWindow *window = surface->window;
MetaWaylandBuffer *buffer = surface->buffer_ref.buffer;
CoglTexture *texture = buffer->texture;
double scale;
scale = meta_surface_actor_wayland_get_scale (actor);
window->buffer_rect.width = cogl_texture_get_width (texture) * scale;
window->buffer_rect.height = cogl_texture_get_height (texture) * scale;
}
static void
pending_buffer_resource_destroyed (MetaWaylandBuffer *buffer,
MetaWaylandPendingState *pending)
@ -2035,6 +2019,34 @@ meta_wayland_surface_role_actor_surface_class_init (MetaWaylandSurfaceRoleActorS
surface_role_class->is_on_output = actor_surface_is_on_output;
}
static void
shell_surface_role_surface_commit (MetaWaylandSurfaceRole *surface_role,
MetaWaylandPendingState *pending)
{
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
MetaWaylandSurfaceRoleClass *surface_role_class;
MetaWindow *window = surface->window;
MetaWaylandBuffer *buffer;
CoglTexture *texture;
MetaSurfaceActorWayland *actor;
double scale;
surface_role_class =
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_surface_role_shell_surface_parent_class);
surface_role_class->commit (surface_role, pending);
buffer = surface->buffer_ref.buffer;
if (!buffer)
return;
actor = META_SURFACE_ACTOR_WAYLAND (surface->surface_actor);
scale = meta_surface_actor_wayland_get_scale (actor);
texture = buffer->texture;
window->buffer_rect.width = cogl_texture_get_width (texture) * scale;
window->buffer_rect.height = cogl_texture_get_height (texture) * scale;
}
static void
meta_wayland_surface_role_shell_surface_init (MetaWaylandSurfaceRoleShellSurface *role)
{
@ -2043,6 +2055,10 @@ meta_wayland_surface_role_shell_surface_init (MetaWaylandSurfaceRoleShellSurface
static void
meta_wayland_surface_role_shell_surface_class_init (MetaWaylandSurfaceRoleShellSurfaceClass *klass)
{
MetaWaylandSurfaceRoleClass *surface_role_class =
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
surface_role_class->commit = shell_surface_role_surface_commit;
}
static void

View File

@ -301,9 +301,6 @@ MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRo
cairo_region_t * meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface);
void meta_wayland_surface_apply_window_state (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending);
void meta_wayland_surface_calculate_window_geometry (MetaWaylandSurface *surface,
MetaRectangle *total_geometry,
float parent_x,

View File

@ -595,7 +595,6 @@ wl_shell_surface_role_commit (MetaWaylandSurfaceRole *surface_role,
if (!pending->newly_attached)
return;
meta_wayland_surface_apply_window_state (surface, pending);
meta_wayland_surface_calculate_window_geometry (surface, &geom, 0, 0);
meta_window_wayland_move_resize (window,
NULL,

View File

@ -432,8 +432,6 @@ xdg_surface_role_commit (MetaWaylandSurfaceRole *surface_role,
if (!window)
return;
meta_wayland_surface_apply_window_state (surface, pending);
if (pending->has_new_geometry)
{
/* If we have new geometry, use it. */
@ -606,7 +604,6 @@ xdg_popup_role_commit (MetaWaylandSurfaceRole *surface_role,
if (!window)
return;
meta_wayland_surface_apply_window_state (surface, pending);
meta_wayland_surface_calculate_window_geometry (surface, &geom, 0, 0);
meta_window_wayland_move_resize (window,
NULL,