From f21df371902f942ff9f77abcaaf1a202207c61d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 1 Jul 2016 15:59:23 +0800 Subject: [PATCH] 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 --- src/wayland/meta-wayland-surface.c | 48 ++++++++++++++++++---------- src/wayland/meta-wayland-surface.h | 3 -- src/wayland/meta-wayland-wl-shell.c | 1 - src/wayland/meta-wayland-xdg-shell.c | 3 -- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 1c41e5554..4ad6e7ab0 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -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 diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index f20e2264b..6c892dedc 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -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, diff --git a/src/wayland/meta-wayland-wl-shell.c b/src/wayland/meta-wayland-wl-shell.c index 0b0030905..e04df4781 100644 --- a/src/wayland/meta-wayland-wl-shell.c +++ b/src/wayland/meta-wayland-wl-shell.c @@ -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, diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index a3e089608..6a7441da0 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -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,