2017-12-20 09:40:22 +00: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
|
2023-08-07 09:50:23 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2017-12-20 09:40:22 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "wayland/meta-wayland-actor-surface.h"
|
|
|
|
|
2017-12-22 06:28:28 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
|
|
|
#include "backends/meta-logical-monitor.h"
|
2017-12-20 09:40:22 +00:00
|
|
|
#include "compositor/meta-surface-actor-wayland.h"
|
2019-06-30 13:18:46 +00:00
|
|
|
#include "compositor/meta-window-actor-wayland.h"
|
2017-12-22 06:28:28 +00:00
|
|
|
#include "compositor/region-utils.h"
|
2019-12-06 17:57:10 +00:00
|
|
|
#include "wayland/meta-wayland-buffer.h"
|
2023-10-23 21:59:19 +00:00
|
|
|
#include "wayland/meta-wayland-surface-private.h"
|
2017-12-22 06:28:28 +00:00
|
|
|
#include "wayland/meta-window-wayland.h"
|
2022-06-13 08:09:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_XWAYLAND
|
2020-02-23 15:09:21 +00:00
|
|
|
#include "wayland/meta-xwayland-surface.h"
|
2022-06-13 08:09:26 +00:00
|
|
|
#endif
|
2017-12-20 09:40:22 +00:00
|
|
|
|
2018-04-06 11:27:52 +00:00
|
|
|
typedef struct _MetaWaylandActorSurfacePrivate MetaWaylandActorSurfacePrivate;
|
|
|
|
|
|
|
|
struct _MetaWaylandActorSurfacePrivate
|
|
|
|
{
|
|
|
|
MetaSurfaceActor *actor;
|
2019-10-03 19:44:34 +00:00
|
|
|
|
|
|
|
gulong actor_destroyed_handler_id;
|
2019-10-28 17:20:31 +00:00
|
|
|
|
|
|
|
struct wl_list frame_callback_list;
|
2018-04-06 11:27:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaWaylandActorSurface,
|
|
|
|
meta_wayland_actor_surface,
|
|
|
|
META_TYPE_WAYLAND_SURFACE_ROLE)
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (meta_wayland_actor_surface_parent_class)->constructed (object);
|
|
|
|
|
|
|
|
meta_wayland_actor_surface_reset_actor (META_WAYLAND_ACTOR_SURFACE (object));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-10-03 19:41:48 +00:00
|
|
|
clear_surface_actor (MetaWaylandActorSurface *actor_surface)
|
2018-04-06 11:27:52 +00:00
|
|
|
{
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
2019-10-03 19:41:48 +00:00
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
2018-04-06 11:27:52 +00:00
|
|
|
MetaWaylandSurface *surface =
|
2019-10-03 19:41:48 +00:00
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
|
2019-10-03 19:44:34 +00:00
|
|
|
if (!priv->actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_signal_handler (&priv->actor_destroyed_handler_id, priv->actor);
|
2019-10-03 19:41:48 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (priv->actor,
|
|
|
|
meta_wayland_surface_notify_geometry_changed,
|
|
|
|
surface);
|
2020-03-12 22:35:28 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (priv->actor,
|
|
|
|
meta_wayland_surface_update_outputs,
|
|
|
|
surface);
|
2019-10-03 19:41:48 +00:00
|
|
|
g_clear_object (&priv->actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurface *actor_surface = META_WAYLAND_ACTOR_SURFACE (object);
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
2019-10-28 17:20:31 +00:00
|
|
|
MetaWaylandFrameCallback *cb, *next;
|
2018-04-06 11:27:52 +00:00
|
|
|
|
2018-06-14 10:38:27 +00:00
|
|
|
if (priv->actor)
|
|
|
|
{
|
|
|
|
clutter_actor_set_reactive (CLUTTER_ACTOR (priv->actor), FALSE);
|
2019-10-03 19:41:48 +00:00
|
|
|
clear_surface_actor (actor_surface);
|
2018-06-14 10:38:27 +00:00
|
|
|
}
|
2018-04-06 11:27:52 +00:00
|
|
|
|
2019-10-28 17:20:31 +00:00
|
|
|
wl_list_for_each_safe (cb, next, &priv->frame_callback_list, link)
|
|
|
|
wl_resource_destroy (cb->resource);
|
|
|
|
|
2018-06-14 10:38:27 +00:00
|
|
|
G_OBJECT_CLASS (meta_wayland_actor_surface_parent_class)->dispose (object);
|
2018-04-06 11:27:52 +00:00
|
|
|
}
|
2017-12-20 09:40:22 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_assigned (MetaWaylandSurfaceRole *surface_role)
|
|
|
|
{
|
2018-04-06 11:27:52 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (META_WAYLAND_ACTOR_SURFACE (surface_role));
|
2017-12-20 09:40:22 +00:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
|
2020-04-27 13:43:19 +00:00
|
|
|
if (wl_list_empty (&surface->unassigned.pending_frame_callback_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
wl_list_insert_list (priv->frame_callback_list.prev,
|
|
|
|
&surface->unassigned.pending_frame_callback_list);
|
|
|
|
wl_list_init (&surface->unassigned.pending_frame_callback_list);
|
|
|
|
|
|
|
|
meta_wayland_compositor_add_frame_callback_surface (surface->compositor,
|
|
|
|
surface);
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
|
|
|
|
2018-07-25 09:49:36 +00:00
|
|
|
void
|
|
|
|
meta_wayland_actor_surface_queue_frame_callbacks (MetaWaylandActorSurface *actor_surface,
|
2019-03-13 12:27:25 +00:00
|
|
|
MetaWaylandSurfaceState *pending)
|
2017-12-20 09:40:22 +00:00
|
|
|
{
|
2018-07-25 09:49:36 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
2020-04-27 13:43:19 +00:00
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
2018-07-25 09:49:36 +00:00
|
|
|
|
2020-04-27 13:43:19 +00:00
|
|
|
if (wl_list_empty (&pending->frame_callback_list))
|
2019-10-03 19:44:34 +00:00
|
|
|
return;
|
|
|
|
|
2020-04-27 13:43:19 +00:00
|
|
|
wl_list_insert_list (priv->frame_callback_list.prev,
|
|
|
|
&pending->frame_callback_list);
|
2017-12-20 09:40:22 +00:00
|
|
|
wl_list_init (&pending->frame_callback_list);
|
2020-04-27 13:43:19 +00:00
|
|
|
|
|
|
|
meta_wayland_compositor_add_frame_callback_surface (surface->compositor,
|
|
|
|
surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_actor_surface_emit_frame_callbacks (MetaWaylandActorSurface *actor_surface,
|
|
|
|
uint32_t timestamp_ms)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
|
|
|
|
while (!wl_list_empty (&priv->frame_callback_list))
|
|
|
|
{
|
|
|
|
MetaWaylandFrameCallback *callback =
|
|
|
|
wl_container_of (priv->frame_callback_list.next, callback, link);
|
|
|
|
|
|
|
|
wl_callback_send_done (callback->resource, timestamp_ms);
|
|
|
|
wl_resource_destroy (callback->resource);
|
|
|
|
}
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
|
|
|
|
2022-06-12 12:06:10 +00:00
|
|
|
int
|
2018-08-22 14:22:58 +00:00
|
|
|
meta_wayland_actor_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
2017-12-22 06:28:28 +00:00
|
|
|
{
|
2019-09-06 13:13:24 +00:00
|
|
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE_GET_CLASS (actor_surface);
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2019-09-06 13:13:24 +00:00
|
|
|
return actor_surface_class->get_geometry_scale (actor_surface);
|
2018-08-22 14:22:58 +00:00
|
|
|
}
|
|
|
|
|
2017-12-22 06:28:28 +00:00
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
2018-04-06 11:27:52 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
2017-12-22 06:28:28 +00:00
|
|
|
MetaWaylandSurfaceRole *surface_role =
|
|
|
|
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaSurfaceActor *surface_actor;
|
|
|
|
MetaShapedTexture *stex;
|
2019-12-06 17:57:10 +00:00
|
|
|
MetaWaylandBuffer *buffer;
|
2023-07-19 14:59:04 +00:00
|
|
|
MtkRectangle surface_rect;
|
2019-12-06 17:22:47 +00:00
|
|
|
MetaWaylandSurface *subsurface_surface;
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2018-04-06 11:27:52 +00:00
|
|
|
surface_actor = priv->actor;
|
2017-12-22 06:28:28 +00:00
|
|
|
stex = meta_surface_actor_get_texture (surface_actor);
|
2019-12-06 17:57:10 +00:00
|
|
|
|
wayland/surface: Overhaul handling of buffer use count
Move the use count from a separate MetaWaylandBufferRef struct to the
MetaWaylandBuffer class, and remove the former.
The buffer use count is now incremented already in
meta_wayland_surface_commit, since the Wayland protocol defines the
buffer to be in use by the compositor at that point. If the buffer
attachment ends up being dropped again before it is applied to the
surface state (e.g. because another buffer is committed to a
synchronized sub-surface before the parent surface is committed),
the use count is now decremented, and a buffer release event is sent if
the use count drops to 0.
Buffer release events were previously incorrectly not sent under these
circumstances. Test case: Run the weston-subsurfaces demo with the -r1
and/or -t1 command line parameter. Resize the window. Before this
change, weston-subsurfaces would freeze or abort after a few resize
operations, because mutter failed to send release events and the
client ran out of usable buffers.
v2:
* Handle NULL priv->buffer_ref in
meta_wayland_cursor_surface_apply_state.
v3:
* Remove MetaWaylandBufferRef altogether, move the use count tracking
to MetaWaylandBuffer itself. Much simpler, and doesn't run into
lifetime issues when mutter shuts down.
v4:
* Warn if use count isn't 0 in meta_wayland_buffer_finalize.
* Keep pending_buffer_resource_destroyed for attached but not yet
committed buffers. If the client attaches a buffer and then destroys
it before commit, we ignore the buffer attachement, same as before
this MR.
v5:
* Rebase on top of new commit which splits up surface->texture.
* MetaWaylandSurfaceState::buffer can only be non-NULL if
::newly_attached is TRUE, simplify accordingly.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880>
2022-06-22 16:43:11 +00:00
|
|
|
buffer = meta_wayland_surface_get_buffer (surface);
|
2019-12-06 17:57:10 +00:00
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
CoglSnippet *snippet;
|
|
|
|
gboolean is_y_inverted;
|
2023-05-29 12:41:00 +00:00
|
|
|
MetaMultiTexture *texture;
|
2019-12-06 17:57:10 +00:00
|
|
|
|
|
|
|
snippet = meta_wayland_buffer_create_snippet (buffer);
|
|
|
|
is_y_inverted = meta_wayland_buffer_is_y_inverted (buffer);
|
|
|
|
|
2022-07-13 15:10:05 +00:00
|
|
|
texture = meta_wayland_surface_get_texture (surface);
|
|
|
|
meta_shaped_texture_set_texture (stex, texture);
|
2019-12-06 17:57:10 +00:00
|
|
|
meta_shaped_texture_set_snippet (stex, snippet);
|
|
|
|
meta_shaped_texture_set_is_y_inverted (stex, is_y_inverted);
|
2023-12-18 17:05:21 +00:00
|
|
|
meta_shaped_texture_set_buffer_scale (stex, surface->applied_state.scale);
|
2023-08-17 11:16:14 +00:00
|
|
|
g_clear_object (&snippet);
|
2019-12-06 17:57:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_shaped_texture_set_texture (stex, NULL);
|
|
|
|
}
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2023-07-19 14:59:04 +00:00
|
|
|
surface_rect = (MtkRectangle) {
|
2020-02-04 23:43:16 +00:00
|
|
|
.width = meta_wayland_surface_get_width (surface),
|
|
|
|
.height = meta_wayland_surface_get_height (surface),
|
2018-07-02 10:22:30 +00:00
|
|
|
};
|
|
|
|
|
2022-06-13 08:09:26 +00:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2020-02-23 15:09:21 +00:00
|
|
|
if (!META_IS_XWAYLAND_SURFACE (surface_role))
|
2023-05-25 10:48:22 +00:00
|
|
|
#endif
|
2023-09-04 14:30:38 +00:00
|
|
|
{
|
|
|
|
if (surface->input_region)
|
|
|
|
{
|
|
|
|
g_autoptr (MtkRegion) input_region = NULL;
|
|
|
|
|
|
|
|
input_region = mtk_region_copy (surface->input_region);
|
|
|
|
mtk_region_intersect_rectangle (input_region, &surface_rect);
|
|
|
|
meta_surface_actor_set_input_region (surface_actor, input_region);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_surface_actor_set_input_region (surface_actor, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!meta_shaped_texture_has_alpha (stex))
|
|
|
|
{
|
|
|
|
g_autoptr (MtkRegion) opaque_region = NULL;
|
|
|
|
|
|
|
|
opaque_region = mtk_region_create_rectangle (&surface_rect);
|
|
|
|
meta_surface_actor_set_opaque_region (surface_actor, opaque_region);
|
|
|
|
}
|
|
|
|
else if (surface->opaque_region)
|
|
|
|
{
|
|
|
|
g_autoptr (MtkRegion) opaque_region = NULL;
|
|
|
|
|
|
|
|
opaque_region = mtk_region_copy (surface->opaque_region);
|
|
|
|
mtk_region_intersect_rectangle (opaque_region, &surface_rect);
|
|
|
|
meta_surface_actor_set_opaque_region (surface_actor, opaque_region);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
meta_surface_actor_set_opaque_region (surface_actor, NULL);
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2021-08-28 11:54:12 +00:00
|
|
|
meta_shaped_texture_set_transform (stex, surface->buffer_transform);
|
2018-11-26 18:40:57 +00:00
|
|
|
|
2018-11-24 19:25:38 +00:00
|
|
|
if (surface->viewport.has_src_rect)
|
|
|
|
{
|
2021-08-28 11:54:12 +00:00
|
|
|
meta_shaped_texture_set_viewport_src_rect (stex,
|
|
|
|
&surface->viewport.src_rect);
|
2018-11-24 19:25:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-28 11:54:12 +00:00
|
|
|
meta_shaped_texture_reset_viewport_src_rect (stex);
|
2018-11-24 19:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->viewport.has_dst_size)
|
|
|
|
{
|
2021-08-28 11:54:12 +00:00
|
|
|
meta_shaped_texture_set_viewport_dst_size (stex,
|
|
|
|
surface->viewport.dst_width,
|
|
|
|
surface->viewport.dst_height);
|
2018-11-24 19:25:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-28 11:54:12 +00:00
|
|
|
meta_shaped_texture_reset_viewport_dst_size (stex);
|
2018-11-24 19:25:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-23 13:01:13 +00:00
|
|
|
meta_shaped_texture_ensure_size_valid (stex);
|
|
|
|
|
2023-11-14 10:44:05 +00:00
|
|
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (&surface->applied_state,
|
2021-07-23 14:01:37 +00:00
|
|
|
subsurface_surface)
|
2017-12-22 06:28:28 +00:00
|
|
|
{
|
2019-12-06 17:22:47 +00:00
|
|
|
MetaWaylandActorSurface *actor_surface;
|
2019-06-30 13:18:46 +00:00
|
|
|
|
2019-12-06 17:22:47 +00:00
|
|
|
actor_surface = META_WAYLAND_ACTOR_SURFACE (subsurface_surface->role);
|
|
|
|
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
2017-12-22 06:28:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_actor_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurfaceClass *actor_surface_class =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE_GET_CLASS (actor_surface);
|
|
|
|
|
|
|
|
actor_surface_class->sync_actor_state (actor_surface);
|
|
|
|
}
|
|
|
|
|
2017-12-20 09:40:22 +00:00
|
|
|
static void
|
2019-07-11 09:20:44 +00:00
|
|
|
meta_wayland_actor_surface_apply_state (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaWaylandSurfaceState *pending)
|
2017-12-20 09:40:22 +00:00
|
|
|
{
|
2017-12-22 06:28:28 +00:00
|
|
|
MetaWaylandActorSurface *actor_surface =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE (surface_role);
|
2019-10-03 19:44:34 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
|
2023-02-11 06:03:37 +00:00
|
|
|
if (priv->actor && !wl_list_empty (&pending->frame_callback_list))
|
2019-10-28 17:20:31 +00:00
|
|
|
{
|
2023-02-11 06:03:37 +00:00
|
|
|
ClutterStage *stage;
|
2017-12-20 09:40:22 +00:00
|
|
|
|
2023-02-11 06:03:37 +00:00
|
|
|
stage =
|
|
|
|
CLUTTER_STAGE (clutter_actor_get_stage (CLUTTER_ACTOR (priv->actor)));
|
|
|
|
if (stage)
|
|
|
|
clutter_stage_schedule_update (stage);
|
2020-04-27 13:43:19 +00:00
|
|
|
}
|
2019-10-09 19:53:09 +00:00
|
|
|
|
2018-07-25 09:49:36 +00:00
|
|
|
meta_wayland_actor_surface_queue_frame_callbacks (actor_surface, pending);
|
2017-12-20 09:40:22 +00:00
|
|
|
|
2017-12-22 06:28:28 +00:00
|
|
|
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_wayland_actor_surface_is_on_logical_monitor (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
MetaLogicalMonitor *logical_monitor)
|
|
|
|
{
|
2018-04-06 11:27:52 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (META_WAYLAND_ACTOR_SURFACE (surface_role));
|
2022-05-30 21:48:44 +00:00
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (surface_role);
|
|
|
|
MetaContext *context =
|
|
|
|
meta_wayland_compositor_get_context (surface->compositor);
|
|
|
|
MetaBackend *backend = meta_context_get_backend (context);
|
2022-07-08 21:45:16 +00:00
|
|
|
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
2018-04-06 11:27:52 +00:00
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (priv->actor);
|
2023-07-19 23:46:15 +00:00
|
|
|
MtkRectangle logical_monitor_layout;
|
2022-07-08 21:45:16 +00:00
|
|
|
GList *l;
|
2017-12-22 06:28:28 +00:00
|
|
|
|
|
|
|
logical_monitor_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
|
2022-07-08 21:45:16 +00:00
|
|
|
for (l = meta_renderer_get_views (renderer); l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterStageView *stage_view = l->data;
|
2023-07-19 23:46:15 +00:00
|
|
|
MtkRectangle view_layout;
|
2022-07-08 21:45:16 +00:00
|
|
|
|
|
|
|
clutter_stage_view_get_layout (stage_view, &view_layout);
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2023-07-19 22:55:37 +00:00
|
|
|
if (mtk_rectangle_overlap (&logical_monitor_layout,
|
|
|
|
&view_layout) &&
|
2022-07-08 21:45:16 +00:00
|
|
|
clutter_actor_is_effectively_on_stage_view (CLUTTER_ACTOR (actor),
|
|
|
|
stage_view))
|
|
|
|
return TRUE;
|
|
|
|
}
|
2017-12-22 06:28:28 +00:00
|
|
|
|
2022-07-08 21:45:16 +00:00
|
|
|
return FALSE;
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
|
|
|
|
2019-10-09 07:47:23 +00:00
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_get_relative_coordinates (MetaWaylandSurfaceRole *surface_role,
|
|
|
|
float abs_x,
|
|
|
|
float abs_y,
|
|
|
|
float *out_sx,
|
|
|
|
float *out_sy)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurface *actor_surface =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE (surface_role);
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
|
|
|
|
clutter_actor_transform_stage_point (CLUTTER_ACTOR (priv->actor),
|
|
|
|
abs_x, abs_y,
|
|
|
|
out_sx, out_sy);
|
|
|
|
}
|
|
|
|
|
2017-12-20 09:40:22 +00:00
|
|
|
static void
|
2019-10-28 17:20:31 +00:00
|
|
|
meta_wayland_actor_surface_init (MetaWaylandActorSurface *actor_surface)
|
2017-12-20 09:40:22 +00:00
|
|
|
{
|
2019-10-28 17:20:31 +00:00
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
|
|
|
|
wl_list_init (&priv->frame_callback_list);
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_actor_surface_class_init (MetaWaylandActorSurfaceClass *klass)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceRoleClass *surface_role_class =
|
|
|
|
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
|
2018-04-06 11:27:52 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->constructed = meta_wayland_actor_surface_constructed;
|
2018-06-14 10:38:27 +00:00
|
|
|
object_class->dispose = meta_wayland_actor_surface_dispose;
|
2017-12-20 09:40:22 +00:00
|
|
|
|
|
|
|
surface_role_class->assigned = meta_wayland_actor_surface_assigned;
|
2019-07-11 09:20:44 +00:00
|
|
|
surface_role_class->apply_state = meta_wayland_actor_surface_apply_state;
|
2017-12-20 09:40:22 +00:00
|
|
|
surface_role_class->is_on_logical_monitor =
|
|
|
|
meta_wayland_actor_surface_is_on_logical_monitor;
|
2019-10-09 07:47:23 +00:00
|
|
|
surface_role_class->get_relative_coordinates =
|
|
|
|
meta_wayland_actor_surface_get_relative_coordinates;
|
2017-12-22 06:28:28 +00:00
|
|
|
|
|
|
|
klass->sync_actor_state = meta_wayland_actor_surface_real_sync_actor_state;
|
2017-12-20 09:40:22 +00:00
|
|
|
}
|
2018-04-06 11:27:52 +00:00
|
|
|
|
|
|
|
MetaSurfaceActor *
|
|
|
|
meta_wayland_actor_surface_get_actor (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
|
|
|
|
return priv->actor;
|
|
|
|
}
|
|
|
|
|
2019-10-03 19:44:34 +00:00
|
|
|
static void
|
|
|
|
on_actor_destroyed (ClutterActor *actor,
|
|
|
|
MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
clear_surface_actor (actor_surface);
|
|
|
|
}
|
|
|
|
|
2018-04-06 11:27:52 +00:00
|
|
|
void
|
|
|
|
meta_wayland_actor_surface_reset_actor (MetaWaylandActorSurface *actor_surface)
|
|
|
|
{
|
|
|
|
MetaWaylandActorSurfacePrivate *priv =
|
|
|
|
meta_wayland_actor_surface_get_instance_private (actor_surface);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (actor_surface));
|
2019-12-06 17:43:04 +00:00
|
|
|
MetaWaylandSurface *subsurface_surface;
|
|
|
|
|
2023-11-14 10:44:05 +00:00
|
|
|
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (&surface->applied_state,
|
2021-07-23 14:01:37 +00:00
|
|
|
subsurface_surface)
|
2019-12-06 17:43:04 +00:00
|
|
|
{
|
|
|
|
MetaWaylandActorSurface *actor_surface;
|
|
|
|
|
|
|
|
actor_surface = META_WAYLAND_ACTOR_SURFACE (subsurface_surface->role);
|
|
|
|
meta_wayland_actor_surface_reset_actor (actor_surface);
|
|
|
|
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
|
|
|
}
|
2018-04-06 11:27:52 +00:00
|
|
|
|
2019-10-03 19:41:48 +00:00
|
|
|
clear_surface_actor (actor_surface);
|
2018-04-06 11:27:52 +00:00
|
|
|
|
|
|
|
priv->actor = g_object_ref_sink (meta_surface_actor_wayland_new (surface));
|
2019-10-03 19:44:34 +00:00
|
|
|
priv->actor_destroyed_handler_id =
|
|
|
|
g_signal_connect (priv->actor, "destroy",
|
|
|
|
G_CALLBACK (on_actor_destroyed),
|
2019-10-04 11:45:51 +00:00
|
|
|
actor_surface);
|
2018-04-06 11:27:52 +00:00
|
|
|
|
2023-08-28 14:14:17 +00:00
|
|
|
meta_wayland_surface_notify_actor_changed (surface);
|
|
|
|
|
2018-04-06 11:27:52 +00:00
|
|
|
g_signal_connect_swapped (priv->actor, "notify::allocation",
|
|
|
|
G_CALLBACK (meta_wayland_surface_notify_geometry_changed),
|
|
|
|
surface);
|
|
|
|
g_signal_connect_swapped (priv->actor, "notify::mapped",
|
2020-07-07 14:49:31 +00:00
|
|
|
G_CALLBACK (meta_wayland_surface_update_outputs),
|
2018-04-06 11:27:52 +00:00
|
|
|
surface);
|
2020-03-12 22:35:28 +00:00
|
|
|
g_signal_connect_swapped (priv->actor, "stage-views-changed",
|
|
|
|
G_CALLBACK (meta_wayland_surface_update_outputs),
|
|
|
|
surface);
|
2018-04-06 11:27:52 +00:00
|
|
|
}
|