示例#1
0
static void
wl_shell_surface_destructor (struct wl_resource *resource)
{
  MetaWaylandWlShellSurface *wl_shell_surface =
    META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
  MetaWaylandSurface *surface =
    surface_from_wl_shell_surface_resource (resource);
  GList *l;

  meta_wayland_compositor_destroy_frame_callbacks (surface->compositor,
                                                   surface);

  if (wl_shell_surface->popup)
    meta_wayland_popup_dismiss (wl_shell_surface->popup);

  for (l = wl_shell_surface->children; l; l = l->next)
    {
      MetaWaylandSurface *child_surface = l->data;
      MetaWaylandWlShellSurface *child_wl_shell_surface =
        META_WAYLAND_WL_SHELL_SURFACE (child_surface->role);

      child_wl_shell_surface->parent_surface = NULL;

      if (child_wl_shell_surface->parent_surface == surface)
        {
          meta_wayland_popup_dismiss (child_wl_shell_surface->popup);
          child_wl_shell_surface->parent_surface = NULL;
        }
    }

  if (wl_shell_surface->parent_surface)
    {
      MetaWaylandSurface *parent_surface = wl_shell_surface->parent_surface;
      MetaWaylandWlShellSurface *parent_wl_shell_surface =
        META_WAYLAND_WL_SHELL_SURFACE (parent_surface->role);

      parent_wl_shell_surface->children =
        g_list_remove (parent_wl_shell_surface->children, surface);
    }

  g_free (wl_shell_surface->title);
  g_free (wl_shell_surface->wm_class);

  if (wl_shell_surface->popup)
    {
      wl_shell_surface->parent_surface = NULL;

      meta_wayland_popup_dismiss (wl_shell_surface->popup);
    }

  wl_shell_surface->resource = NULL;
}
示例#2
0
static void
wl_shell_surface_set_state (MetaWaylandSurface     *surface,
                            MetaWlShellSurfaceState state)
{
  MetaWaylandWlShellSurface *wl_shell_surface =
    META_WAYLAND_WL_SHELL_SURFACE (surface->role);
  MetaWlShellSurfaceState old_state = wl_shell_surface->state;

  wl_shell_surface->state = state;

  if (surface->window && old_state != state)
    {
      if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP &&
          wl_shell_surface->popup)
        {
          meta_wayland_popup_dismiss (wl_shell_surface->popup);
          wl_shell_surface->popup = NULL;
        }

      if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN)
        meta_window_make_fullscreen (surface->window);
      else
        meta_window_unmake_fullscreen (surface->window);

      if (state == META_WL_SHELL_SURFACE_STATE_MAXIMIZED)
        meta_window_maximize (surface->window, META_MAXIMIZE_BOTH);
      else
        meta_window_unmaximize (surface->window, META_MAXIMIZE_BOTH);
    }
}
示例#3
0
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);
}
示例#4
0
static void
wl_shell_surface_set_popup (struct wl_client   *client,
                            struct wl_resource *resource,
                            struct wl_resource *seat_resource,
                            uint32_t            serial,
                            struct wl_resource *parent_resource,
                            int32_t             x,
                            int32_t             y,
                            uint32_t            flags)
{
  MetaWaylandWlShellSurface *wl_shell_surface =
    META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
  MetaWaylandSurface *surface =
    surface_from_wl_shell_surface_resource (resource);
  MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
  MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);

  if (wl_shell_surface->popup)
    {
      wl_shell_surface->parent_surface = NULL;

      meta_wayland_popup_dismiss (wl_shell_surface->popup);
    }

  wl_shell_surface_set_state (surface,
                              META_WL_SHELL_SURFACE_STATE_POPUP);

  if (!meta_wayland_seat_can_popup (seat, serial))
    {
      wl_shell_surface_send_popup_done (resource);
      return;
    }

  set_wl_shell_surface_parent (surface, parent_surf);
  wl_shell_surface->popup_seat = seat;
  wl_shell_surface->x = x;
  wl_shell_surface->y = y;
  wl_shell_surface->pending_popup = TRUE;

  if (surface->window && parent_surf->window)
    sync_wl_shell_parent_relationship (surface, parent_surf);
}
static void
xdg_popup_destructor (struct wl_resource *resource)
{
  MetaWaylandSurface *surface = surface_from_xdg_popup_resource (resource);
  MetaWaylandXdgPopup *xdg_popup =
    META_WAYLAND_XDG_POPUP (wl_resource_get_user_data (resource));

  meta_wayland_compositor_destroy_frame_callbacks (surface->compositor,
                                                   surface);
  if (xdg_popup->parent_surface)
    {
      wl_list_remove (&xdg_popup->parent_destroy_listener.link);
      xdg_popup->parent_surface = NULL;
    }

  if (xdg_popup->popup)
    meta_wayland_popup_dismiss (xdg_popup->popup);

  xdg_popup->resource = NULL;
}