From 06380938d4b1bcb9636520d837c5d27c8f9f5966 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 9 Feb 2014 18:23:07 -0500 Subject: [PATCH] wayland-surface: Make set_fullscreen / set_maximized and friends double-buffered --- src/wayland/meta-wayland-surface.c | 31 ++++++++++++++++++++++++++---- src/wayland/meta-wayland-surface.h | 9 +++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 2e5201e44..96668826f 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -336,6 +336,22 @@ toplevel_surface_commit (MetaWaylandSurface *surface, meta_window_move_resize_wayland (window, new_width, new_height, pending->dx, pending->dy); } } + + if (pending->maximized.changed) + { + if (pending->maximized.value) + meta_window_maximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); + else + meta_window_unmaximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); + } + + if (pending->fullscreen.changed) + { + if (pending->fullscreen.value) + meta_window_make_fullscreen (surface->window); + else + meta_window_unmake_fullscreen (surface->window); + } } static void @@ -359,6 +375,9 @@ double_buffered_state_init (MetaWaylandDoubleBufferedState *state) state->buffer_destroy_listener.notify = surface_handle_pending_buffer_destroy; wl_list_init (&state->frame_callback_list); + + state->maximized.changed = FALSE; + state->fullscreen.changed = FALSE; } static void @@ -875,7 +894,8 @@ xdg_surface_set_fullscreen (struct wl_client *client, MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface); - meta_window_make_fullscreen (surface->window); + surface->pending.fullscreen.changed = TRUE; + surface->pending.fullscreen.value = TRUE; } static void @@ -885,7 +905,8 @@ xdg_surface_unset_fullscreen (struct wl_client *client, MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface); - meta_window_unmake_fullscreen (surface->window); + surface->pending.fullscreen.changed = TRUE; + surface->pending.fullscreen.value = FALSE; } static void @@ -895,7 +916,8 @@ xdg_surface_set_maximized (struct wl_client *client, MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface); - meta_window_maximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); + surface->pending.maximized.changed = TRUE; + surface->pending.maximized.value = TRUE; } static void @@ -905,7 +927,8 @@ xdg_surface_unset_maximized (struct wl_client *client, MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource); MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface); - meta_window_unmaximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); + surface->pending.maximized.changed = TRUE; + surface->pending.maximized.value = FALSE; } static void diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index c87854bb1..6b0516e38 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -42,6 +42,12 @@ struct _MetaWaylandBuffer uint32_t ref_count; }; +typedef struct +{ + guint changed : 1; + guint value : 1; +} MetaWaylandStateFlag; + typedef struct { /* wl_surface.attach */ @@ -59,6 +65,9 @@ typedef struct /* wl_surface.frame */ struct wl_list frame_callback_list; + + MetaWaylandStateFlag fullscreen; + MetaWaylandStateFlag maximized; } MetaWaylandDoubleBufferedState; typedef struct