2015-12-14 23:51:24 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
|
|
|
* Copyright (C) 2013-2015 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "wayland/meta-wayland-wl-shell.h"
|
|
|
|
|
|
|
|
#include "core/window-private.h"
|
2016-03-09 02:27:40 -05:00
|
|
|
#include "wayland/meta-wayland-popup.h"
|
2015-12-14 23:51:24 -05:00
|
|
|
#include "wayland/meta-wayland-private.h"
|
|
|
|
#include "wayland/meta-wayland-seat.h"
|
2017-12-22 01:28:28 -05:00
|
|
|
#include "wayland/meta-wayland-shell-surface.h"
|
2015-12-14 23:51:24 -05:00
|
|
|
#include "wayland/meta-wayland-surface.h"
|
|
|
|
#include "wayland/meta-wayland-versions.h"
|
2019-07-05 12:10:14 -04:00
|
|
|
#include "wayland/meta-wayland-window-configuration.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "wayland/meta-wayland.h"
|
2015-12-14 23:51:24 -05:00
|
|
|
#include "wayland/meta-window-wayland.h"
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
META_WL_SHELL_SURFACE_STATE_NONE,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_TOPLEVEL,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_POPUP,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_TRANSIENT,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_FULLSCREEN,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_MAXIMIZED,
|
|
|
|
} MetaWlShellSurfaceState;
|
|
|
|
|
2016-01-13 23:50:12 -05:00
|
|
|
struct _MetaWaylandWlShellSurface
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2017-12-12 23:37:23 -05:00
|
|
|
MetaWaylandShellSurface parent;
|
2016-01-22 01:22:40 -05:00
|
|
|
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
MetaWlShellSurfaceState state;
|
|
|
|
|
|
|
|
char *title;
|
|
|
|
char *wm_class;
|
|
|
|
|
|
|
|
MetaWaylandSurface *parent_surface;
|
|
|
|
GList *children;
|
|
|
|
|
|
|
|
MetaWaylandSeat *popup_seat;
|
|
|
|
MetaWaylandPopup *popup;
|
|
|
|
gboolean pending_popup;
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int y;
|
2019-07-05 12:10:14 -04:00
|
|
|
|
|
|
|
uint32_t emulated_ack_configure_serial;
|
2015-12-14 23:51:24 -05:00
|
|
|
};
|
|
|
|
|
2016-01-21 04:01:08 -05:00
|
|
|
static void
|
|
|
|
popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaWaylandWlShellSurface,
|
|
|
|
meta_wayland_wl_shell_surface,
|
2017-12-12 23:37:23 -05:00
|
|
|
META_TYPE_WAYLAND_SHELL_SURFACE,
|
2016-01-21 04:01:08 -05:00
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_WAYLAND_POPUP_SURFACE,
|
|
|
|
popup_surface_iface_init));
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
static MetaWaylandSurface *
|
|
|
|
surface_from_wl_shell_surface_resource (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (wl_shell_surface);
|
|
|
|
|
|
|
|
return meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
}
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
static void
|
|
|
|
sync_wl_shell_parent_relationship (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurface *parent);
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
|
|
|
wl_shell_surface_destructor (struct wl_resource *resource)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-15 05:14:25 -05:00
|
|
|
GList *l;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
meta_wayland_compositor_destroy_frame_callbacks (surface->compositor,
|
|
|
|
surface);
|
2016-03-09 02:27:40 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->popup)
|
|
|
|
meta_wayland_popup_dismiss (wl_shell_surface->popup);
|
2016-01-21 04:03:16 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
for (l = wl_shell_surface->children; l; l = l->next)
|
2016-03-09 02:27:40 -05:00
|
|
|
{
|
2015-12-15 05:14:25 -05:00
|
|
|
MetaWaylandSurface *child_surface = l->data;
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *child_wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (child_surface->role);
|
2016-03-09 02:27:40 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
child_wl_shell_surface->parent_surface = NULL;
|
2016-01-21 21:35:05 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (child_wl_shell_surface->parent_surface == surface)
|
2016-01-21 21:35:05 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_popup_dismiss (child_wl_shell_surface->popup);
|
|
|
|
child_wl_shell_surface->parent_surface = NULL;
|
2016-01-21 21:35:05 -05:00
|
|
|
}
|
2016-03-09 02:27:40 -05:00
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->parent_surface)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *parent_surface = wl_shell_surface->parent_surface;
|
|
|
|
MetaWaylandWlShellSurface *parent_wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (parent_surface->role);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
parent_wl_shell_surface->children =
|
|
|
|
g_list_remove (parent_wl_shell_surface->children, surface);
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
g_free (wl_shell_surface->title);
|
|
|
|
g_free (wl_shell_surface->wm_class);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->popup)
|
2016-03-09 02:27:40 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->parent_surface = NULL;
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_popup_dismiss (wl_shell_surface->popup);
|
2016-03-09 02:27:40 -05:00
|
|
|
}
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->resource = NULL;
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_pong (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_get_display ();
|
|
|
|
|
|
|
|
meta_display_pong_for_serial (display, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_move (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
gfloat x, y;
|
|
|
|
|
|
|
|
if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_wayland_surface_begin_grab_op (surface, seat, META_GRAB_OP_MOVING, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaGrabOp
|
|
|
|
grab_op_for_wl_shell_surface_resize_edge (int edge)
|
|
|
|
{
|
|
|
|
MetaGrabOp op = META_GRAB_OP_WINDOW_BASE;
|
|
|
|
|
|
|
|
if (edge & WL_SHELL_SURFACE_RESIZE_TOP)
|
|
|
|
op |= META_GRAB_OP_WINDOW_DIR_NORTH;
|
|
|
|
if (edge & WL_SHELL_SURFACE_RESIZE_BOTTOM)
|
|
|
|
op |= META_GRAB_OP_WINDOW_DIR_SOUTH;
|
|
|
|
if (edge & WL_SHELL_SURFACE_RESIZE_LEFT)
|
|
|
|
op |= META_GRAB_OP_WINDOW_DIR_WEST;
|
|
|
|
if (edge & WL_SHELL_SURFACE_RESIZE_RIGHT)
|
|
|
|
op |= META_GRAB_OP_WINDOW_DIR_EAST;
|
|
|
|
|
|
|
|
if (op == META_GRAB_OP_WINDOW_BASE)
|
|
|
|
{
|
|
|
|
g_warning ("invalid edge: %d", edge);
|
|
|
|
return META_GRAB_OP_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_resize (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t edges)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
gfloat x, y;
|
|
|
|
MetaGrabOp grab_op;
|
|
|
|
|
|
|
|
if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y))
|
|
|
|
return;
|
|
|
|
|
|
|
|
grab_op = grab_op_for_wl_shell_surface_resize_edge (edges);
|
|
|
|
meta_wayland_surface_begin_grab_op (surface, seat, grab_op, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_state (MetaWaylandSurface *surface,
|
|
|
|
MetaWlShellSurfaceState state)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface->role);
|
|
|
|
MetaWlShellSurfaceState old_state = wl_shell_surface->state;
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *window;
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->state = state;
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
window = meta_wayland_surface_get_window (surface);
|
|
|
|
if (window && old_state != state)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
2016-01-21 04:03:16 -05:00
|
|
|
if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP &&
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->popup)
|
2016-01-21 04:03:16 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_popup_dismiss (wl_shell_surface->popup);
|
|
|
|
wl_shell_surface->popup = NULL;
|
2016-01-21 04:03:16 -05:00
|
|
|
}
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN)
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_make_fullscreen (window);
|
2015-12-15 05:14:25 -05:00
|
|
|
else
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_unmake_fullscreen (window);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
|
|
|
if (state == META_WL_SHELL_SURFACE_STATE_MAXIMIZED)
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
2015-12-15 05:14:25 -05:00
|
|
|
else
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_toplevel (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
wl_shell_surface_set_state (surface,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_TOPLEVEL);
|
|
|
|
}
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
static void
|
|
|
|
set_wl_shell_surface_parent (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurface *parent)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface->role);
|
|
|
|
MetaWaylandWlShellSurface *parent_wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (parent->role);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->parent_surface)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *old_parent =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_shell_surface->parent_surface->role);
|
|
|
|
|
|
|
|
old_parent->children = g_list_remove (old_parent->children, surface);
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
parent_wl_shell_surface->children =
|
|
|
|
g_list_append (parent_wl_shell_surface->children, surface);
|
|
|
|
wl_shell_surface->parent_surface = parent;
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
|
|
|
wl_shell_surface_set_transient (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
uint32_t flags)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
|
|
|
|
|
|
|
|
wl_shell_surface_set_state (surface,
|
2015-12-15 05:14:25 -05:00
|
|
|
META_WL_SHELL_SURFACE_STATE_TRANSIENT);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
set_wl_shell_surface_parent (surface, parent_surf);
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->x = x;
|
|
|
|
wl_shell_surface->y = y;
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
if (meta_wayland_surface_get_window (surface) &&
|
|
|
|
meta_wayland_surface_get_window (parent_surf))
|
2015-12-15 05:14:25 -05:00
|
|
|
sync_wl_shell_parent_relationship (surface, parent_surf);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_fullscreen (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t method,
|
|
|
|
uint32_t framerate,
|
|
|
|
struct wl_resource *output)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
wl_shell_surface_set_state (surface,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_FULLSCREEN);
|
|
|
|
}
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
static void
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_wl_shell_surface_create_popup (MetaWaylandWlShellSurface *wl_shell_surface)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
2016-01-21 04:01:08 -05:00
|
|
|
MetaWaylandPopupSurface *popup_surface =
|
|
|
|
META_WAYLAND_POPUP_SURFACE (wl_shell_surface);
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSeat *seat = wl_shell_surface->popup_seat;
|
2015-12-15 05:14:25 -05:00
|
|
|
MetaWaylandPopup *popup;
|
|
|
|
|
2016-04-01 04:39:30 -04:00
|
|
|
popup = meta_wayland_pointer_start_popup_grab (seat->pointer, popup_surface);
|
2015-12-15 05:14:25 -05:00
|
|
|
if (!popup)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface_send_popup_done (wl_shell_surface->resource);
|
2015-12-15 05:14:25 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->popup = popup;
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
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)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
2016-03-09 02:27:40 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->popup)
|
2016-03-09 02:27:40 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->parent_surface = NULL;
|
2016-03-09 02:27:40 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_popup_dismiss (wl_shell_surface->popup);
|
2016-03-09 02:27:40 -05:00
|
|
|
}
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
wl_shell_surface_set_state (surface,
|
2015-12-15 05:14:25 -05:00
|
|
|
META_WL_SHELL_SURFACE_STATE_POPUP);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
if (!meta_wayland_seat_can_popup (seat, serial))
|
|
|
|
{
|
|
|
|
wl_shell_surface_send_popup_done (resource);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
set_wl_shell_surface_parent (surface, parent_surf);
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->popup_seat = seat;
|
|
|
|
wl_shell_surface->x = x;
|
|
|
|
wl_shell_surface->y = y;
|
|
|
|
wl_shell_surface->pending_popup = TRUE;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
if (meta_wayland_surface_get_window (surface) &&
|
|
|
|
meta_wayland_surface_get_window (parent_surf))
|
2015-12-15 05:14:25 -05:00
|
|
|
sync_wl_shell_parent_relationship (surface, parent_surf);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_maximized (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *output)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
wl_shell_surface_set_state (surface,
|
|
|
|
META_WL_SHELL_SURFACE_STATE_MAXIMIZED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_title (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *title)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *window;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
g_clear_pointer (&wl_shell_surface->title, g_free);
|
2016-06-07 10:17:28 -04:00
|
|
|
|
|
|
|
if (!g_utf8_validate (title, -1, NULL))
|
|
|
|
title = "";
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->title = g_strdup (title);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
window = meta_wayland_surface_get_window (surface);
|
|
|
|
if (window)
|
|
|
|
meta_window_set_title (window, title);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_shell_surface_set_class (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *class_)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (wl_resource_get_user_data (resource));
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
surface_from_wl_shell_surface_resource (resource);
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *window;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
g_clear_pointer (&wl_shell_surface->wm_class, g_free);
|
2016-06-07 10:17:28 -04:00
|
|
|
|
|
|
|
if (!g_utf8_validate (class_, -1, NULL))
|
|
|
|
class_ = "";
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->wm_class = g_strdup (class_);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
window = meta_wayland_surface_get_window (surface);
|
|
|
|
if (window)
|
|
|
|
meta_window_set_wm_class (window, class_, class_);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_shell_surface_interface meta_wayland_wl_shell_surface_interface = {
|
|
|
|
wl_shell_surface_pong,
|
|
|
|
wl_shell_surface_move,
|
|
|
|
wl_shell_surface_resize,
|
|
|
|
wl_shell_surface_set_toplevel,
|
|
|
|
wl_shell_surface_set_transient,
|
|
|
|
wl_shell_surface_set_fullscreen,
|
|
|
|
wl_shell_surface_set_popup,
|
|
|
|
wl_shell_surface_set_maximized,
|
|
|
|
wl_shell_surface_set_title,
|
|
|
|
wl_shell_surface_set_class,
|
|
|
|
};
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
static void
|
|
|
|
sync_wl_shell_parent_relationship (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurface *parent)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface->role);
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *window;
|
|
|
|
MetaWindow *parent_window;
|
2016-01-22 01:22:40 -05:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
window = meta_wayland_surface_get_window (surface);
|
|
|
|
parent_window = meta_wayland_surface_get_window (parent);
|
|
|
|
meta_window_set_transient_for (window, parent_window);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP ||
|
|
|
|
wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_TRANSIENT)
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_wayland_place_relative_to (window,
|
|
|
|
parent_window,
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->x,
|
|
|
|
wl_shell_surface->y);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP &&
|
|
|
|
wl_shell_surface->pending_popup)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
meta_wayland_wl_shell_surface_create_popup (wl_shell_surface);
|
|
|
|
wl_shell_surface->pending_popup = FALSE;
|
2015-12-15 05:14:25 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_wl_shell_surface_window (MetaWaylandSurface *surface)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface->role);
|
2017-12-22 03:26:24 -05:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (wl_shell_surface);
|
2015-12-15 05:14:25 -05:00
|
|
|
MetaWaylandSurface *parent;
|
2018-01-05 04:47:41 -05:00
|
|
|
MetaWindow *window;
|
2015-12-15 05:14:25 -05:00
|
|
|
GList *l;
|
|
|
|
|
2018-01-05 04:47:41 -05:00
|
|
|
window = meta_window_wayland_new (meta_get_display (), surface);
|
2017-12-22 03:26:24 -05:00
|
|
|
meta_wayland_shell_surface_set_window (shell_surface, window);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->title)
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_set_title (window, wl_shell_surface->title);
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->wm_class)
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_set_wm_class (window,
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->wm_class,
|
|
|
|
wl_shell_surface->wm_class);
|
2015-12-15 05:14:25 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
parent = wl_shell_surface->parent_surface;
|
2019-10-09 03:37:04 -04:00
|
|
|
if (parent && meta_wayland_surface_get_window (parent))
|
2015-12-15 05:14:25 -05:00
|
|
|
sync_wl_shell_parent_relationship (surface, parent);
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
for (l = wl_shell_surface->children; l; l = l->next)
|
2015-12-15 05:14:25 -05:00
|
|
|
{
|
|
|
|
MetaWaylandSurface *child = l->data;
|
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
if (meta_wayland_surface_get_window (child))
|
2015-12-15 05:14:25 -05:00
|
|
|
sync_wl_shell_parent_relationship (child, surface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
|
|
|
wl_shell_get_shell_surface (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (META_IS_WAYLAND_WL_SHELL_SURFACE (surface->role) &&
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface->role)->resource)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
|
|
|
wl_resource_post_error (surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"wl_shell::get_shell_surface already requested");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!meta_wayland_surface_assign_role (surface,
|
2016-01-28 04:14:06 -05:00
|
|
|
META_TYPE_WAYLAND_WL_SHELL_SURFACE,
|
|
|
|
NULL))
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
|
|
|
wl_resource_post_error (resource, WL_SHELL_ERROR_ROLE,
|
|
|
|
"wl_surface@%d already has a different role",
|
|
|
|
wl_resource_get_id (surface->resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface = META_WAYLAND_WL_SHELL_SURFACE (surface->role);
|
|
|
|
wl_shell_surface->resource =
|
|
|
|
wl_resource_create (client,
|
|
|
|
&wl_shell_surface_interface,
|
|
|
|
wl_resource_get_version (resource),
|
|
|
|
id);
|
|
|
|
wl_resource_set_implementation (wl_shell_surface->resource,
|
2015-12-14 23:51:24 -05:00
|
|
|
&meta_wayland_wl_shell_surface_interface,
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface,
|
2015-12-14 23:51:24 -05:00
|
|
|
wl_shell_surface_destructor);
|
|
|
|
|
2015-12-15 05:14:25 -05:00
|
|
|
create_wl_shell_surface_window (surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_shell_interface meta_wayland_wl_shell_interface = {
|
|
|
|
wl_shell_get_shell_surface,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_wl_shell (struct wl_client *client,
|
|
|
|
void *data,
|
|
|
|
uint32_t version,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_resource_create (client, &wl_shell_interface, version, id);
|
|
|
|
wl_resource_set_implementation (resource, &meta_wayland_wl_shell_interface, data, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-07-11 05:20:44 -04:00
|
|
|
wl_shell_surface_role_apply_state (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface_role);
|
2017-12-22 01:28:28 -05:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (wl_shell_surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class;
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *window = meta_wayland_surface_get_window (surface);
|
2019-07-05 11:43:24 -04:00
|
|
|
cairo_region_t *input_region;
|
2016-01-14 04:49:57 -05:00
|
|
|
MetaRectangle geom = { 0 };
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
surface_role_class =
|
2016-01-13 23:50:12 -05:00
|
|
|
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_wl_shell_surface_parent_class);
|
2019-07-11 05:20:44 -04:00
|
|
|
surface_role_class->apply_state (surface_role, pending);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
|
|
|
/* For wl_shell, it's equivalent to an unmap. Semantics
|
|
|
|
* are poorly defined, so we can choose some that are
|
|
|
|
* convenient for us. */
|
2019-08-13 12:46:36 -04:00
|
|
|
if (surface->buffer_ref->buffer && !window)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2015-12-15 05:14:25 -05:00
|
|
|
create_wl_shell_surface_window (surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
2019-08-13 12:46:36 -04:00
|
|
|
else if (!surface->buffer_ref->buffer && window)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->popup)
|
|
|
|
meta_wayland_popup_dismiss (wl_shell_surface->popup);
|
2016-01-21 04:03:16 -05:00
|
|
|
else
|
2019-09-04 12:35:08 -04:00
|
|
|
meta_wayland_shell_surface_destroy_window (shell_surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-14 04:49:57 -05:00
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!pending->newly_attached)
|
|
|
|
return;
|
|
|
|
|
2019-07-05 11:43:24 -04:00
|
|
|
input_region = meta_wayland_surface_calculate_input_region (surface);
|
|
|
|
if (!cairo_region_is_empty (input_region))
|
|
|
|
{
|
|
|
|
cairo_region_get_extents (input_region, &geom);
|
|
|
|
cairo_region_destroy (input_region);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_wayland_shell_surface_calculate_geometry (shell_surface, &geom);
|
|
|
|
}
|
|
|
|
|
2019-07-05 12:10:14 -04:00
|
|
|
pending->has_acked_configure_serial = TRUE;
|
|
|
|
pending->acked_configure_serial =
|
|
|
|
wl_shell_surface->emulated_ack_configure_serial;
|
|
|
|
|
|
|
|
meta_window_wayland_finish_move_resize (window, geom, pending);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
2016-01-14 04:43:47 -05:00
|
|
|
static MetaWaylandSurface *
|
|
|
|
wl_shell_surface_role_get_toplevel (MetaWaylandSurfaceRole *surface_role)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (surface_role);
|
2016-01-14 04:43:47 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP &&
|
|
|
|
wl_shell_surface->parent_surface)
|
|
|
|
return meta_wayland_surface_get_toplevel (wl_shell_surface->parent_surface);
|
2016-01-14 04:43:47 -05:00
|
|
|
else
|
|
|
|
return meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
2019-07-05 12:10:14 -04:00
|
|
|
wl_shell_surface_role_configure (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaWaylandWindowConfiguration *configuration)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
2017-12-12 23:37:23 -05:00
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (shell_surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (!wl_shell_surface->resource)
|
2015-12-14 23:51:24 -05:00
|
|
|
return;
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface_send_configure (wl_shell_surface->resource,
|
2015-12-14 23:51:24 -05:00
|
|
|
0,
|
2019-07-05 12:10:14 -04:00
|
|
|
configuration->width, configuration->height);
|
|
|
|
|
|
|
|
wl_shell_surface->emulated_ack_configure_serial = configuration->serial;
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
2015-12-15 09:09:20 -05:00
|
|
|
static void
|
2017-12-12 23:37:23 -05:00
|
|
|
wl_shell_surface_role_managed (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaWindow *window)
|
2015-12-15 09:09:20 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
2017-12-12 23:37:23 -05:00
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (shell_surface);
|
2015-12-15 09:13:05 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
if (wl_shell_surface->state == META_WL_SHELL_SURFACE_STATE_POPUP)
|
2015-12-15 09:13:05 -05:00
|
|
|
meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
|
2015-12-15 09:09:20 -05:00
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
2017-12-12 23:37:23 -05:00
|
|
|
wl_shell_surface_role_ping (MetaWaylandShellSurface *shell_surface,
|
|
|
|
guint32 serial)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
2017-12-12 23:37:23 -05:00
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (shell_surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface_send_ping (wl_shell_surface->resource, serial);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-12 23:37:23 -05:00
|
|
|
wl_shell_surface_role_close (MetaWaylandShellSurface *shell_surface)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
|
|
|
/* Not supported by wl_shell_surface. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-21 04:01:08 -05:00
|
|
|
meta_wayland_wl_shell_surface_popup_done (MetaWaylandPopupSurface *popup_surface)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (popup_surface);
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface_send_popup_done (wl_shell_surface->resource);
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
2016-01-21 04:01:08 -05:00
|
|
|
static void
|
|
|
|
meta_wayland_wl_shell_surface_popup_dismiss (MetaWaylandPopupSurface *popup_surface)
|
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (popup_surface);
|
2019-09-04 12:35:08 -04:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (wl_shell_surface);
|
2016-01-21 04:01:08 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
wl_shell_surface->popup = NULL;
|
2016-01-21 04:01:08 -05:00
|
|
|
|
2019-09-04 12:35:08 -04:00
|
|
|
meta_wayland_shell_surface_destroy_window (shell_surface);
|
2016-01-21 04:01:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static MetaWaylandSurface *
|
|
|
|
meta_wayland_wl_shell_surface_popup_get_surface (MetaWaylandPopupSurface *popup_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (popup_surface);
|
|
|
|
|
|
|
|
return meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
popup_surface_iface_init (MetaWaylandPopupSurfaceInterface *iface)
|
|
|
|
{
|
|
|
|
iface->done = meta_wayland_wl_shell_surface_popup_done;
|
|
|
|
iface->dismiss = meta_wayland_wl_shell_surface_popup_dismiss;
|
|
|
|
iface->get_surface = meta_wayland_wl_shell_surface_popup_get_surface;
|
|
|
|
}
|
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
static void
|
|
|
|
wl_shell_surface_role_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWaylandWlShellSurface *wl_shell_surface =
|
|
|
|
META_WAYLAND_WL_SHELL_SURFACE (object);
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
g_clear_pointer (&wl_shell_surface->resource, wl_resource_destroy);
|
|
|
|
|
|
|
|
object_class =
|
|
|
|
G_OBJECT_CLASS (meta_wayland_wl_shell_surface_parent_class);
|
|
|
|
object_class->finalize (object);
|
|
|
|
}
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
static void
|
2016-01-13 23:50:12 -05:00
|
|
|
meta_wayland_wl_shell_surface_init (MetaWaylandWlShellSurface *wl_shell_surface)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-01-13 23:50:12 -05:00
|
|
|
meta_wayland_wl_shell_surface_class_init (MetaWaylandWlShellSurfaceClass *klass)
|
2015-12-14 23:51:24 -05:00
|
|
|
{
|
2016-01-22 01:22:40 -05:00
|
|
|
GObjectClass *object_class;
|
2015-12-14 23:51:24 -05:00
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class;
|
2017-12-12 23:37:23 -05:00
|
|
|
MetaWaylandShellSurfaceClass *shell_surface_class;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2016-01-22 01:22:40 -05:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
object_class->finalize = wl_shell_surface_role_finalize;
|
|
|
|
|
2015-12-14 23:51:24 -05:00
|
|
|
surface_role_class = META_WAYLAND_SURFACE_ROLE_CLASS (klass);
|
2019-07-11 05:20:44 -04:00
|
|
|
surface_role_class->apply_state = wl_shell_surface_role_apply_state;
|
2016-01-14 04:43:47 -05:00
|
|
|
surface_role_class->get_toplevel = wl_shell_surface_role_get_toplevel;
|
2015-12-14 23:51:24 -05:00
|
|
|
|
2017-12-12 23:37:23 -05:00
|
|
|
shell_surface_class = META_WAYLAND_SHELL_SURFACE_CLASS (klass);
|
|
|
|
shell_surface_class->configure = wl_shell_surface_role_configure;
|
|
|
|
shell_surface_class->managed = wl_shell_surface_role_managed;
|
|
|
|
shell_surface_class->ping = wl_shell_surface_role_ping;
|
|
|
|
shell_surface_class->close = wl_shell_surface_role_close;
|
2015-12-14 23:51:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_wl_shell_init (MetaWaylandCompositor *compositor)
|
|
|
|
{
|
|
|
|
if (wl_global_create (compositor->wayland_display,
|
|
|
|
&wl_shell_interface,
|
|
|
|
META_WL_SHELL_VERSION,
|
|
|
|
compositor, bind_wl_shell) == NULL)
|
|
|
|
g_error ("Failed to register a global wl-shell object");
|
|
|
|
}
|