2017-12-20 04:40:22 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012,2013 Intel Corporation
|
|
|
|
* Copyright (C) 2013-2017 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-shell-surface.h"
|
|
|
|
|
|
|
|
#include "compositor/meta-surface-actor-wayland.h"
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
#include "compositor/meta-window-actor-private.h"
|
2019-10-08 17:32:37 -04:00
|
|
|
#include "compositor/meta-window-actor-wayland.h"
|
2017-12-20 04:40:22 -05:00
|
|
|
#include "wayland/meta-wayland-actor-surface.h"
|
|
|
|
#include "wayland/meta-wayland-buffer.h"
|
2017-12-22 01:28:28 -05:00
|
|
|
#include "wayland/meta-wayland-subsurface.h"
|
|
|
|
#include "wayland/meta-wayland-surface.h"
|
|
|
|
#include "wayland/meta-window-wayland.h"
|
2017-12-20 04:40:22 -05:00
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
typedef struct _MetaWaylandShellSurfacePrivate
|
|
|
|
{
|
|
|
|
MetaWindow *window;
|
|
|
|
|
|
|
|
gulong unmanaging_handler_id;
|
|
|
|
gulong effects_completed_handler_id;
|
|
|
|
} MetaWaylandShellSurfacePrivate;
|
|
|
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaWaylandShellSurface,
|
|
|
|
meta_wayland_shell_surface,
|
|
|
|
META_TYPE_WAYLAND_ACTOR_SURFACE)
|
2017-12-20 04:40:22 -05:00
|
|
|
|
2017-12-22 01:28:28 -05:00
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_calculate_geometry (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaRectangle *out_geometry)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (shell_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaRectangle geometry;
|
2019-12-06 12:22:47 -05:00
|
|
|
MetaWaylandSurface *subsurface_surface;
|
2017-12-22 01:28:28 -05:00
|
|
|
|
|
|
|
geometry = (MetaRectangle) {
|
2018-06-29 11:53:21 -04:00
|
|
|
.width = meta_wayland_surface_get_width (surface),
|
|
|
|
.height = meta_wayland_surface_get_height (surface),
|
2017-12-22 01:28:28 -05:00
|
|
|
};
|
|
|
|
|
2019-12-06 12:22:47 -05:00
|
|
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
|
2017-12-22 01:28:28 -05:00
|
|
|
{
|
2019-06-30 09:18:46 -04:00
|
|
|
MetaWaylandSubsurface *subsurface;
|
2017-12-22 01:28:28 -05:00
|
|
|
|
2019-06-30 09:18:46 -04:00
|
|
|
subsurface = META_WAYLAND_SUBSURFACE (subsurface_surface->role);
|
2017-12-22 01:28:28 -05:00
|
|
|
meta_wayland_subsurface_union_geometry (subsurface,
|
|
|
|
0, 0,
|
|
|
|
&geometry);
|
|
|
|
}
|
|
|
|
|
|
|
|
*out_geometry = geometry;
|
|
|
|
}
|
|
|
|
|
2018-08-18 13:41:15 -04:00
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_determine_geometry (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaRectangle *set_geometry,
|
|
|
|
MetaRectangle *out_geometry)
|
|
|
|
{
|
|
|
|
MetaRectangle bounding_geometry = { 0 };
|
|
|
|
MetaRectangle intersected_geometry = { 0 };
|
|
|
|
|
|
|
|
meta_wayland_shell_surface_calculate_geometry (shell_surface,
|
|
|
|
&bounding_geometry);
|
|
|
|
|
|
|
|
meta_rectangle_intersect (set_geometry, &bounding_geometry,
|
|
|
|
&intersected_geometry);
|
|
|
|
|
|
|
|
*out_geometry = intersected_geometry;
|
|
|
|
}
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
static void
|
|
|
|
clear_window (MetaWaylandShellSurface *shell_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (shell_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaSurfaceActor *surface_actor;
|
|
|
|
|
|
|
|
if (!priv->window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_signal_handler (&priv->unmanaging_handler_id,
|
|
|
|
priv->window);
|
|
|
|
g_clear_signal_handler (&priv->effects_completed_handler_id,
|
|
|
|
meta_window_actor_from_window (priv->window));
|
|
|
|
priv->window = NULL;
|
|
|
|
|
|
|
|
surface_actor = meta_wayland_surface_get_actor (surface);
|
|
|
|
if (surface_actor)
|
|
|
|
clutter_actor_set_reactive (CLUTTER_ACTOR (surface_actor), FALSE);
|
|
|
|
|
|
|
|
meta_wayland_surface_notify_unmapped (surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
window_unmanaging (MetaWindow *window,
|
|
|
|
MetaWaylandShellSurface *shell_surface)
|
|
|
|
{
|
|
|
|
clear_window (shell_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
window_actor_effects_completed (MetaWindowActor *window_actor,
|
|
|
|
MetaWaylandSurface *surface)
|
|
|
|
{
|
|
|
|
meta_wayland_compositor_repick (surface->compositor);
|
|
|
|
}
|
|
|
|
|
2017-12-22 03:26:24 -05:00
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_set_window (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
2017-12-22 03:26:24 -05:00
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (shell_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaSurfaceActor *surface_actor;
|
|
|
|
|
|
|
|
g_assert (!priv->window);
|
|
|
|
|
|
|
|
priv->window = window;
|
|
|
|
|
|
|
|
surface_actor = meta_wayland_surface_get_actor (surface);
|
|
|
|
if (surface_actor)
|
|
|
|
clutter_actor_set_reactive (CLUTTER_ACTOR (surface_actor), TRUE);
|
|
|
|
|
|
|
|
priv->unmanaging_handler_id =
|
|
|
|
g_signal_connect (window,
|
|
|
|
"unmanaging",
|
|
|
|
G_CALLBACK (window_unmanaging),
|
|
|
|
shell_surface);
|
|
|
|
priv->effects_completed_handler_id =
|
|
|
|
g_signal_connect (meta_window_actor_from_window (window),
|
|
|
|
"effects-completed",
|
|
|
|
G_CALLBACK (window_actor_effects_completed),
|
|
|
|
surface);
|
2017-12-22 03:26:24 -05:00
|
|
|
|
2018-08-24 06:54:50 -04:00
|
|
|
meta_window_update_monitor (window, META_WINDOW_UPDATE_MONITOR_FLAGS_NONE);
|
2017-12-22 03:26:24 -05:00
|
|
|
}
|
|
|
|
|
2017-12-20 04:40:22 -05:00
|
|
|
void
|
2019-07-05 12:10:14 -04:00
|
|
|
meta_wayland_shell_surface_configure (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaWaylandWindowConfiguration *configuration)
|
2017-12-20 04:40:22 -05:00
|
|
|
{
|
|
|
|
MetaWaylandShellSurfaceClass *shell_surface_class =
|
|
|
|
META_WAYLAND_SHELL_SURFACE_GET_CLASS (shell_surface);
|
|
|
|
|
2019-07-05 12:10:14 -04:00
|
|
|
shell_surface_class->configure (shell_surface, configuration);
|
2017-12-20 04:40:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_ping (MetaWaylandShellSurface *shell_surface,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurfaceClass *shell_surface_class =
|
|
|
|
META_WAYLAND_SHELL_SURFACE_GET_CLASS (shell_surface);
|
|
|
|
|
|
|
|
shell_surface_class->ping (shell_surface, serial);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_close (MetaWaylandShellSurface *shell_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurfaceClass *shell_surface_class =
|
|
|
|
META_WAYLAND_SHELL_SURFACE_GET_CLASS (shell_surface);
|
|
|
|
|
|
|
|
shell_surface_class->close (shell_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_managed (MetaWaylandShellSurface *shell_surface,
|
|
|
|
MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurfaceClass *shell_surface_class =
|
|
|
|
META_WAYLAND_SHELL_SURFACE_GET_CLASS (shell_surface);
|
|
|
|
|
|
|
|
shell_surface_class->managed (shell_surface, window);
|
|
|
|
}
|
|
|
|
|
2019-10-09 03:53:23 -04:00
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_assigned (MetaWaylandSurfaceRole *surface_role)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class =
|
|
|
|
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_shell_surface_parent_class);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
|
|
|
|
surface->dnd.funcs = meta_wayland_data_device_get_drag_dest_funcs ();
|
|
|
|
|
|
|
|
surface_role_class->assigned (surface_role);
|
|
|
|
}
|
|
|
|
|
2019-10-09 03:56:34 -04:00
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_surface_pre_apply_state (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending)
|
|
|
|
{
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (surface_role);
|
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
2019-10-09 03:56:34 -04:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
|
|
|
|
if (pending->newly_attached &&
|
2019-08-13 12:46:36 -04:00
|
|
|
!surface->buffer_ref->buffer &&
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
priv->window)
|
|
|
|
meta_window_queue (priv->window, META_QUEUE_CALC_SHOWING);
|
2019-10-09 03:56:34 -04:00
|
|
|
}
|
|
|
|
|
2017-12-20 04:40:22 -05:00
|
|
|
static void
|
2019-07-11 05:20:44 -04:00
|
|
|
meta_wayland_shell_surface_surface_apply_state (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending)
|
2017-12-20 04:40:22 -05:00
|
|
|
{
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (surface_role);
|
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
2017-12-22 01:28:28 -05:00
|
|
|
MetaWaylandActorSurface *actor_surface =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE (surface_role);
|
2017-12-20 04:40:22 -05:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class;
|
|
|
|
MetaWindow *window;
|
|
|
|
MetaWaylandBuffer *buffer;
|
2019-07-09 11:29:37 -04:00
|
|
|
double geometry_scale;
|
2017-12-20 04:40:22 -05:00
|
|
|
|
|
|
|
surface_role_class =
|
|
|
|
META_WAYLAND_SURFACE_ROLE_CLASS (meta_wayland_shell_surface_parent_class);
|
2019-07-11 05:20:44 -04:00
|
|
|
surface_role_class->apply_state (surface_role, pending);
|
2017-12-20 04:40:22 -05:00
|
|
|
|
2019-08-13 12:46:36 -04:00
|
|
|
buffer = surface->buffer_ref->buffer;
|
2017-12-20 04:40:22 -05:00
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
window = priv->window;
|
2017-12-20 04:40:22 -05:00
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
2019-07-09 11:29:37 -04:00
|
|
|
geometry_scale = meta_wayland_actor_surface_get_geometry_scale (actor_surface);
|
2017-12-20 04:40:22 -05:00
|
|
|
|
2019-07-09 11:29:37 -04:00
|
|
|
window->buffer_rect.width =
|
|
|
|
meta_wayland_surface_get_width (surface) * geometry_scale;
|
|
|
|
window->buffer_rect.height =
|
|
|
|
meta_wayland_surface_get_height (surface) * geometry_scale;
|
2017-12-20 04:40:22 -05:00
|
|
|
}
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
static MetaWindow *
|
|
|
|
meta_wayland_shell_surface_get_window (MetaWaylandSurfaceRole *surface_role)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (surface_role);
|
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
|
|
|
|
|
|
|
return priv->window;
|
|
|
|
}
|
|
|
|
|
2019-10-08 17:32:37 -04:00
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_notify_subsurface_state_changed (MetaWaylandSurfaceRole *surface_role)
|
|
|
|
{
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaWaylandShellSurface *shell_surface =
|
|
|
|
META_WAYLAND_SHELL_SURFACE (surface_role);
|
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
2019-10-08 17:32:37 -04:00
|
|
|
MetaWindow *window;
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
window = priv->window;
|
2019-10-08 17:32:37 -04:00
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window_actor = meta_window_actor_from_window (window);
|
|
|
|
meta_window_actor_wayland_rebuild_surface_tree (window_actor);
|
|
|
|
}
|
|
|
|
|
2019-09-06 09:13:24 -04:00
|
|
|
static double
|
|
|
|
meta_wayland_shell_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaWindow *toplevel_window;
|
|
|
|
|
|
|
|
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
|
|
|
if (meta_is_stage_views_scaled () || !toplevel_window)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return meta_window_wayland_get_geometry_scale (toplevel_window);
|
|
|
|
}
|
|
|
|
|
2019-04-16 17:35:28 -04:00
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_wayland_shell_surface_parent_class);
|
2019-10-09 03:37:04 -04:00
|
|
|
MetaWindow *toplevel_window;
|
|
|
|
|
|
|
|
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
|
|
|
if (!toplevel_window)
|
|
|
|
return;
|
2019-04-16 17:35:28 -04:00
|
|
|
|
2019-10-09 03:37:04 -04:00
|
|
|
actor_surface_class->sync_actor_state (actor_surface);
|
2019-04-16 17:35:28 -04:00
|
|
|
}
|
|
|
|
|
2019-09-04 12:35:08 -04:00
|
|
|
void
|
|
|
|
meta_wayland_shell_surface_destroy_window (MetaWaylandShellSurface *shell_surface)
|
|
|
|
{
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
MetaWaylandShellSurfacePrivate *priv =
|
|
|
|
meta_wayland_shell_surface_get_instance_private (shell_surface);
|
2019-09-04 12:35:08 -04:00
|
|
|
MetaWindow *window;
|
|
|
|
MetaDisplay *display;
|
|
|
|
uint32_t timestamp;
|
|
|
|
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
window = priv->window;
|
2019-09-04 12:35:08 -04:00
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
display = meta_window_get_display (window);
|
|
|
|
timestamp = meta_display_get_current_time_roundtrip (display);
|
2019-10-09 03:37:04 -04:00
|
|
|
meta_window_unmanage (window, timestamp);
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
g_assert (!priv->window);
|
2019-09-04 12:35:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWaylandShellSurface *shell_surface = META_WAYLAND_SHELL_SURFACE (object);
|
|
|
|
|
|
|
|
meta_wayland_shell_surface_destroy_window (shell_surface);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_wayland_shell_surface_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2017-12-20 04:40:22 -05:00
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_init (MetaWaylandShellSurface *role)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_shell_surface_class_init (MetaWaylandShellSurfaceClass *klass)
|
|
|
|
{
|
2019-09-04 12:35:08 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2017-12-20 04:40:22 -05:00
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class =
|
|
|
|
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
|
2019-04-16 17:35:28 -04:00
|
|
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
|
2017-12-20 04:40:22 -05:00
|
|
|
|
2019-09-04 12:35:08 -04:00
|
|
|
object_class->finalize = meta_wayland_shell_surface_finalize;
|
|
|
|
|
2019-10-09 03:53:23 -04:00
|
|
|
surface_role_class->assigned = meta_wayland_shell_surface_assigned;
|
2019-10-09 03:56:34 -04:00
|
|
|
surface_role_class->pre_apply_state =
|
|
|
|
meta_wayland_shell_surface_surface_pre_apply_state;
|
2019-07-11 05:20:44 -04:00
|
|
|
surface_role_class->apply_state =
|
|
|
|
meta_wayland_shell_surface_surface_apply_state;
|
2019-10-08 17:32:37 -04:00
|
|
|
surface_role_class->notify_subsurface_state_changed =
|
|
|
|
meta_wayland_shell_surface_notify_subsurface_state_changed;
|
wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.
With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.
Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2019-10-09 03:57:40 -04:00
|
|
|
surface_role_class->get_window = meta_wayland_shell_surface_get_window;
|
2019-09-06 09:13:24 -04:00
|
|
|
|
|
|
|
actor_surface_class->get_geometry_scale =
|
|
|
|
meta_wayland_shell_surface_get_geometry_scale;
|
2019-04-16 17:35:28 -04:00
|
|
|
actor_surface_class->sync_actor_state =
|
|
|
|
meta_wayland_shell_surface_sync_actor_state;
|
2017-12-20 04:40:22 -05:00
|
|
|
}
|