static void wl_shell_surface_role_commit (MetaWaylandSurfaceRole *surface_role, MetaWaylandPendingState *pending) { MetaWaylandWlShellSurface *wl_shell_surface = META_WAYLAND_WL_SHELL_SURFACE (surface_role); MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); MetaWindow *window = surface->window; MetaRectangle geom = { 0 }; surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_wl_shell_surface_parent_class); surface_role_class->commit (surface_role, pending); /* For wl_shell, it's equivalent to an unmap. Semantics * are poorly defined, so we can choose some that are * convenient for us. */ if (surface->buffer_ref.buffer && !window) { create_wl_shell_surface_window (surface); } else if (!surface->buffer_ref.buffer && window) { if (wl_shell_surface->popup) meta_wayland_popup_dismiss (wl_shell_surface->popup); else meta_wayland_surface_destroy_window (surface); return; } if (!window) return; if (!pending->newly_attached) return; meta_wayland_surface_calculate_window_geometry (surface, &geom, 0, 0); meta_window_wayland_move_resize (window, NULL, geom, pending->dx, pending->dy); }
static void xdg_popup_role_commit (MetaWaylandSurfaceRole *surface_role, MetaWaylandPendingState *pending) { MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); MetaWindow *window = surface->window; MetaRectangle geom = { 0 }; surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_xdg_popup_parent_class); surface_role_class->commit (surface_role, pending); if (surface->buffer_ref.buffer == NULL) { /* XDG surfaces can't commit NULL buffers */ wl_resource_post_error (surface->resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "Cannot commit a NULL buffer to an xdg_popup"); return; } if (!pending->newly_attached) return; /* If the window disappeared the surface is not coming back. */ 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, geom, pending->dx, pending->dy); }
static void xdg_surface_role_commit (MetaWaylandSurfaceRole *surface_role, MetaWaylandPendingState *pending) { MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (surface_role); MetaWaylandSurfaceRoleClass *surface_role_class; MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); MetaWindow *window = surface->window; MetaRectangle geom = { 0 }; surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_xdg_surface_parent_class); surface_role_class->commit (surface_role, pending); if (surface->buffer_ref.buffer == NULL) { /* XDG surfaces can't commit NULL buffers */ wl_resource_post_error (surface->resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "Cannot commit a NULL buffer to an xdg_surface"); return; } if (!pending->newly_attached) return; /* If the window disappeared the surface is not coming back. */ if (!window) return; meta_wayland_surface_apply_window_state (surface, pending); if (pending->has_new_geometry) { /* If we have new geometry, use it. */ geom = pending->new_geometry; xdg_surface->has_set_geometry = TRUE; } else if (!xdg_surface->has_set_geometry) { /* If the surface has never set any geometry, calculate * a default one unioning the surface and all subsurfaces together. */ meta_wayland_surface_calculate_window_geometry (surface, &geom, 0, 0); } else { /* Otherwise, keep the geometry the same. */ /* XXX: We don't store the geometry in any consistent place * right now, so we can't re-fetch it. We should change * meta_window_wayland_move_resize. */ /* XXX: This is the common case. Recognize it to prevent * a warning. */ if (pending->dx == 0 && pending->dy == 0) return; g_warning ("XXX: Attach-initiated move without a new geometry. This is unimplemented right now."); return; } meta_window_wayland_move_resize (window, &xdg_surface->acked_configure_serial, geom, pending->dx, pending->dy); xdg_surface->acked_configure_serial.set = FALSE; }