2018-12-21 18:35:18 -02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Endless, 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 11:50:23 +02:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2018-12-21 18:35:18 -02:00
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Georges Basile Stavracas Neto <gbsneto@gnome.org>
|
|
|
|
*/
|
|
|
|
|
2022-05-30 23:14:05 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
#include "compositor/clutter-utils.h"
|
2022-03-15 11:34:26 +01:00
|
|
|
#include "compositor/meta-cullable.h"
|
2019-06-30 15:18:46 +02:00
|
|
|
#include "compositor/meta-surface-actor-wayland.h"
|
2018-12-21 18:35:18 -02:00
|
|
|
#include "compositor/meta-window-actor-wayland.h"
|
2022-05-03 18:47:57 +02:00
|
|
|
#include "compositor/region-utils.h"
|
2018-12-21 18:35:18 -02:00
|
|
|
#include "meta/meta-window-actor.h"
|
2023-10-23 23:59:19 +02:00
|
|
|
#include "wayland/meta-wayland-surface-private.h"
|
2022-05-03 18:47:57 +02:00
|
|
|
#include "wayland/meta-window-wayland.h"
|
|
|
|
|
|
|
|
struct _MetaSurfaceContainerActorWayland
|
|
|
|
{
|
|
|
|
ClutterActor parent;
|
|
|
|
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void surface_container_cullable_iface_init (MetaCullableInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaSurfaceContainerActorWayland,
|
|
|
|
meta_surface_container_actor_wayland,
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE,
|
|
|
|
surface_container_cullable_iface_init))
|
2018-12-21 18:35:18 -02:00
|
|
|
|
|
|
|
struct _MetaWindowActorWayland
|
|
|
|
{
|
|
|
|
MetaWindowActor parent;
|
2022-05-03 18:47:57 +02:00
|
|
|
ClutterActor *background;
|
|
|
|
MetaSurfaceContainerActorWayland *surface_container;
|
2022-11-26 16:22:05 +07:00
|
|
|
gulong highest_scale_monitor_handler_id;
|
2018-12-21 18:35:18 -02:00
|
|
|
};
|
|
|
|
|
2022-03-15 11:34:26 +01:00
|
|
|
static void cullable_iface_init (MetaCullableInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaWindowActorWayland, meta_window_actor_wayland,
|
|
|
|
META_TYPE_WINDOW_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE,
|
|
|
|
cullable_iface_init))
|
2018-12-21 18:35:18 -02:00
|
|
|
|
2021-04-16 15:15:41 +02:00
|
|
|
typedef struct _SurfaceTreeTraverseData
|
2019-06-30 15:18:46 +02:00
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
ClutterActor *surface_container;
|
2021-04-16 15:15:41 +02:00
|
|
|
int index;
|
|
|
|
} SurfaceTreeTraverseData;
|
2019-06-30 15:18:46 +02:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
static MetaSurfaceContainerActorWayland *
|
|
|
|
surface_container_new (MetaWindowActor *window_actor)
|
|
|
|
{
|
|
|
|
MetaSurfaceContainerActorWayland *surface_container;
|
|
|
|
|
|
|
|
surface_container = g_object_new (META_TYPE_SURFACE_CONTAINER_ACTOR_WAYLAND,
|
|
|
|
NULL);
|
|
|
|
surface_container->window_actor = window_actor;
|
|
|
|
|
|
|
|
return surface_container;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-09-04 16:30:38 +02:00
|
|
|
surface_container_cull_unobscured (MetaCullable *cullable,
|
|
|
|
MtkRegion *unobscured_region)
|
2022-05-03 18:47:57 +02:00
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
meta_cullable_cull_unobscured_children (cullable, unobscured_region);
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-09-04 16:30:38 +02:00
|
|
|
surface_container_cull_redraw_clip (MetaCullable *cullable,
|
|
|
|
MtkRegion *clip_region)
|
2022-05-03 18:47:57 +02:00
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
meta_cullable_cull_redraw_clip_children (cullable, clip_region);
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_container_cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
iface->cull_unobscured = surface_container_cull_unobscured;
|
|
|
|
iface->cull_redraw_clip = surface_container_cull_redraw_clip;
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
|
|
|
|
2022-11-26 16:22:05 +07:00
|
|
|
static void
|
|
|
|
surface_container_apply_transform (ClutterActor *actor,
|
|
|
|
graphene_matrix_t *matrix)
|
|
|
|
{
|
|
|
|
ClutterActor *parent = clutter_actor_get_parent (actor);
|
|
|
|
ClutterActorClass *parent_class =
|
|
|
|
CLUTTER_ACTOR_CLASS (meta_surface_container_actor_wayland_parent_class);
|
|
|
|
MetaWindow *window;
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
2023-07-20 01:46:15 +02:00
|
|
|
MtkRectangle monitor_rect;
|
2022-11-26 16:22:05 +07:00
|
|
|
float scale;
|
|
|
|
float rel_x, rel_y;
|
|
|
|
float abs_x, abs_y;
|
|
|
|
float adj_rel_x, adj_rel_y;
|
|
|
|
float x_off, y_off;
|
|
|
|
|
|
|
|
parent_class->apply_transform (actor, matrix);
|
|
|
|
|
|
|
|
if (!parent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window = meta_window_actor_get_meta_window (META_WINDOW_ACTOR (parent));
|
|
|
|
if (!window)
|
|
|
|
return;
|
|
|
|
|
|
|
|
logical_monitor = meta_window_get_highest_scale_monitor (window);
|
|
|
|
if (!logical_monitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
scale = meta_logical_monitor_get_scale (logical_monitor);
|
|
|
|
monitor_rect = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
|
|
|
|
abs_x = clutter_actor_get_x (parent) + clutter_actor_get_x (actor);
|
|
|
|
abs_y = clutter_actor_get_y (parent) + clutter_actor_get_y (actor);
|
|
|
|
|
|
|
|
rel_x = abs_x - monitor_rect.x;
|
|
|
|
rel_y = abs_y - monitor_rect.y;
|
|
|
|
|
|
|
|
adj_rel_x = roundf (rel_x * scale) / scale;
|
|
|
|
adj_rel_y = roundf (rel_y * scale) / scale;
|
|
|
|
|
|
|
|
x_off = adj_rel_x - rel_x;
|
|
|
|
y_off = adj_rel_y - rel_y;
|
|
|
|
|
|
|
|
if (!G_APPROX_VALUE (x_off, 0.0, FLT_EPSILON) ||
|
|
|
|
!G_APPROX_VALUE (y_off, 0.0, FLT_EPSILON))
|
|
|
|
{
|
|
|
|
graphene_matrix_translate (matrix,
|
|
|
|
&GRAPHENE_POINT3D_INIT (x_off, y_off, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
static void
|
|
|
|
surface_container_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
MetaSurfaceContainerActorWayland *self = META_SURFACE_CONTAINER_ACTOR_WAYLAND (object);
|
|
|
|
|
|
|
|
clutter_actor_remove_all_children (CLUTTER_ACTOR (self));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_surface_container_actor_wayland_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_surface_container_actor_wayland_class_init (MetaSurfaceContainerActorWaylandClass *klass)
|
|
|
|
{
|
2022-11-26 16:22:05 +07:00
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
2022-05-03 18:47:57 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2022-11-26 16:22:05 +07:00
|
|
|
actor_class->apply_transform = surface_container_apply_transform;
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
object_class->dispose = surface_container_dispose;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_surface_container_actor_wayland_init (MetaSurfaceContainerActorWayland *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-07-08 21:03:52 +02:00
|
|
|
static gboolean
|
|
|
|
get_surface_actor_list (GNode *node,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = node->data;
|
|
|
|
MetaSurfaceActor *surface_actor = meta_wayland_surface_get_actor (surface);
|
|
|
|
GList **surface_actors = data;
|
|
|
|
|
|
|
|
*surface_actors = g_list_prepend (*surface_actors, surface_actor);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-06-30 15:18:46 +02:00
|
|
|
static gboolean
|
2021-04-16 15:15:41 +02:00
|
|
|
set_surface_actor_index (GNode *node,
|
|
|
|
gpointer data)
|
2019-06-30 15:18:46 +02:00
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = node->data;
|
2021-04-16 15:15:41 +02:00
|
|
|
SurfaceTreeTraverseData *traverse_data = data;
|
2022-05-03 18:47:57 +02:00
|
|
|
ClutterActor *container = traverse_data->surface_container;
|
2022-07-09 14:27:35 +02:00
|
|
|
ClutterActor *surface_actor =
|
|
|
|
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
|
2023-05-24 14:37:18 +02:00
|
|
|
MetaSurfaceContainerActorWayland *surface_container =
|
|
|
|
META_SURFACE_CONTAINER_ACTOR_WAYLAND (container);
|
|
|
|
MetaWindowActor *window_actor = surface_container->window_actor;
|
2021-04-16 15:15:41 +02:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
if (clutter_actor_contains (container, surface_actor))
|
2021-04-16 15:15:41 +02:00
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
if (clutter_actor_get_child_at_index (container, traverse_data->index) !=
|
2022-07-09 14:27:35 +02:00
|
|
|
surface_actor)
|
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
clutter_actor_set_child_at_index (container,
|
2022-07-09 14:27:35 +02:00
|
|
|
surface_actor,
|
|
|
|
traverse_data->index);
|
|
|
|
}
|
2021-04-16 15:15:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-24 14:37:18 +02:00
|
|
|
meta_window_actor_add_surface_actor (window_actor,
|
|
|
|
META_SURFACE_ACTOR (surface_actor));
|
2022-05-03 18:47:57 +02:00
|
|
|
clutter_actor_insert_child_at_index (container,
|
2022-07-09 14:27:35 +02:00
|
|
|
surface_actor,
|
|
|
|
traverse_data->index);
|
2021-04-16 15:15:41 +02:00
|
|
|
}
|
|
|
|
traverse_data->index++;
|
2019-06-30 15:18:46 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor)
|
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
2019-06-30 15:18:46 +02:00
|
|
|
MetaSurfaceActor *surface_actor =
|
|
|
|
meta_window_actor_get_surface (actor);
|
|
|
|
MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (
|
|
|
|
META_SURFACE_ACTOR_WAYLAND (surface_actor));
|
2021-07-23 16:01:37 +02:00
|
|
|
GNode *root_node = surface->output_state.subsurface_branch_node;
|
2022-07-08 21:03:52 +02:00
|
|
|
g_autoptr (GList) surface_actors = NULL;
|
|
|
|
g_autoptr (GList) children = NULL;
|
|
|
|
GList *l;
|
2021-04-16 15:15:41 +02:00
|
|
|
SurfaceTreeTraverseData traverse_data;
|
2019-06-30 15:18:46 +02:00
|
|
|
|
2022-07-08 21:03:52 +02:00
|
|
|
g_node_traverse (root_node,
|
|
|
|
G_IN_ORDER,
|
|
|
|
G_TRAVERSE_LEAVES,
|
|
|
|
-1,
|
|
|
|
get_surface_actor_list,
|
|
|
|
&surface_actors);
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
children =
|
|
|
|
clutter_actor_get_children (CLUTTER_ACTOR (self->surface_container));
|
2022-07-08 21:03:52 +02:00
|
|
|
for (l = children; l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterActor *child_actor = l->data;
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
if (!g_list_find (surface_actors, child_actor))
|
|
|
|
{
|
2023-05-24 14:37:18 +02:00
|
|
|
MetaSurfaceActor *surface_actor = META_SURFACE_ACTOR (child_actor);
|
|
|
|
|
|
|
|
meta_window_actor_remove_surface_actor (actor, surface_actor);
|
2022-05-03 18:47:57 +02:00
|
|
|
clutter_actor_remove_child (CLUTTER_ACTOR (self->surface_container),
|
|
|
|
child_actor);
|
|
|
|
}
|
2022-07-08 21:03:52 +02:00
|
|
|
}
|
|
|
|
|
2021-04-16 15:15:41 +02:00
|
|
|
traverse_data = (SurfaceTreeTraverseData) {
|
2022-05-03 18:47:57 +02:00
|
|
|
.surface_container = CLUTTER_ACTOR (self->surface_container),
|
2021-04-16 15:15:41 +02:00
|
|
|
.index = 0,
|
|
|
|
};
|
2019-06-30 15:18:46 +02:00
|
|
|
g_node_traverse (root_node,
|
|
|
|
G_IN_ORDER,
|
|
|
|
G_TRAVERSE_LEAVES,
|
|
|
|
-1,
|
2021-04-16 15:15:41 +02:00
|
|
|
set_surface_actor_index,
|
|
|
|
&traverse_data);
|
2019-06-30 15:18:46 +02:00
|
|
|
}
|
|
|
|
|
2023-09-04 16:30:38 +02:00
|
|
|
static MtkRegion *
|
2022-05-03 18:47:57 +02:00
|
|
|
calculate_background_cull_region (MetaWindowActorWayland *self)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (self);
|
|
|
|
int geometry_scale;
|
2023-07-19 16:59:04 +02:00
|
|
|
MtkRectangle rect;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
|
|
|
geometry_scale = meta_window_actor_get_geometry_scale (window_actor);
|
2023-07-19 16:59:04 +02:00
|
|
|
rect = (MtkRectangle) {
|
2022-05-03 18:47:57 +02:00
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.width = clutter_actor_get_width (self->background) * geometry_scale,
|
|
|
|
.height = clutter_actor_get_height (self->background) * geometry_scale,
|
|
|
|
};
|
|
|
|
|
2023-09-04 16:30:38 +02:00
|
|
|
return mtk_region_create_rectangle (&rect);
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
|
|
|
|
2022-03-15 11:34:26 +01:00
|
|
|
static void
|
2023-06-11 13:18:29 +07:00
|
|
|
subtract_background_opaque_region (MetaWindowActorWayland *self,
|
2023-09-04 16:30:38 +02:00
|
|
|
MtkRegion *region)
|
2022-03-15 11:34:26 +01:00
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
if (!region)
|
|
|
|
return;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
2023-04-08 14:51:21 +07:00
|
|
|
if (self->background &&
|
|
|
|
clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self)) == 0xff)
|
2022-05-03 18:47:57 +02:00
|
|
|
{
|
2023-09-04 16:30:38 +02:00
|
|
|
g_autoptr (MtkRegion) background_cull_region = NULL;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
|
|
|
background_cull_region = calculate_background_cull_region (self);
|
|
|
|
|
2023-09-04 16:30:38 +02:00
|
|
|
mtk_region_subtract (region, background_cull_region);
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
2022-03-15 11:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-09-04 16:30:38 +02:00
|
|
|
meta_window_actor_wayland_cull_unobscured (MetaCullable *cullable,
|
|
|
|
MtkRegion *unobscured_region)
|
2022-03-15 11:34:26 +01:00
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
MetaWindowActorWayland *self =
|
|
|
|
META_WINDOW_ACTOR_WAYLAND (cullable);
|
|
|
|
|
|
|
|
meta_cullable_cull_unobscured_children (META_CULLABLE (self), unobscured_region);
|
|
|
|
|
|
|
|
subtract_background_opaque_region (self, unobscured_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2023-09-04 16:30:38 +02:00
|
|
|
meta_window_actor_wayland_cull_redraw_clip (MetaCullable *cullable,
|
|
|
|
MtkRegion *clip_region)
|
2023-06-11 13:18:29 +07:00
|
|
|
{
|
|
|
|
MetaWindowActorWayland *self =
|
|
|
|
META_WINDOW_ACTOR_WAYLAND (cullable);
|
|
|
|
|
|
|
|
meta_cullable_cull_redraw_clip_children (META_CULLABLE (self), clip_region);
|
|
|
|
|
|
|
|
subtract_background_opaque_region (self, clip_region);
|
2022-03-15 11:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
2023-06-11 13:18:29 +07:00
|
|
|
iface->cull_unobscured = meta_window_actor_wayland_cull_unobscured;
|
|
|
|
iface->cull_redraw_clip = meta_window_actor_wayland_cull_redraw_clip;
|
2022-03-15 11:34:26 +01:00
|
|
|
}
|
|
|
|
|
2022-01-05 22:05:50 +01:00
|
|
|
static MetaSurfaceActor *
|
2022-05-11 22:32:33 +02:00
|
|
|
meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor)
|
2022-01-05 22:05:50 +01:00
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
|
|
|
ClutterActor *surface_container = CLUTTER_ACTOR (self->surface_container);
|
2022-01-05 22:05:50 +01:00
|
|
|
ClutterActor *child_actor;
|
2022-12-09 21:47:32 +01:00
|
|
|
ClutterActorIter iter;
|
|
|
|
MetaSurfaceActor *topmost_surface_actor = NULL;
|
2022-05-11 22:49:08 +02:00
|
|
|
MetaWindow *window;
|
2022-12-09 21:47:32 +01:00
|
|
|
int n_mapped_surfaces = 0;
|
2022-01-05 22:05:50 +01:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
if (clutter_actor_get_last_child (CLUTTER_ACTOR (self)) != surface_container)
|
2022-10-28 23:03:42 +02:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"Top child of window-actor not a surface");
|
2022-12-16 20:42:10 +01:00
|
|
|
return NULL;
|
2022-10-28 23:03:42 +02:00
|
|
|
}
|
2022-05-03 18:47:57 +02:00
|
|
|
|
2022-12-09 21:47:32 +01:00
|
|
|
clutter_actor_iter_init (&iter, surface_container);
|
|
|
|
while (clutter_actor_iter_next (&iter, &child_actor))
|
|
|
|
{
|
|
|
|
if (!clutter_actor_is_mapped (child_actor))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
topmost_surface_actor = META_SURFACE_ACTOR (child_actor);
|
|
|
|
n_mapped_surfaces++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!topmost_surface_actor)
|
2022-10-28 23:03:42 +02:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"No surface-actor for window-actor");
|
2022-12-16 20:42:10 +01:00
|
|
|
return NULL;
|
2022-10-28 23:03:42 +02:00
|
|
|
}
|
2022-05-11 22:32:33 +02:00
|
|
|
|
2022-05-11 22:49:08 +02:00
|
|
|
window = meta_window_actor_get_meta_window (actor);
|
2022-05-03 18:47:57 +02:00
|
|
|
if (!meta_surface_actor_is_opaque (topmost_surface_actor) &&
|
2022-12-09 21:47:32 +01:00
|
|
|
!(meta_window_is_fullscreen (window) && n_mapped_surfaces == 1))
|
2022-10-28 23:03:42 +02:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"Window-actor is not opaque");
|
2022-12-16 20:42:10 +01:00
|
|
|
return NULL;
|
2022-10-28 23:03:42 +02:00
|
|
|
}
|
2022-05-11 22:49:08 +02:00
|
|
|
|
2022-05-11 22:32:33 +02:00
|
|
|
return topmost_surface_actor;
|
2022-01-05 22:05:50 +01:00
|
|
|
}
|
|
|
|
|
2019-06-30 15:18:46 +02:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_assign_surface_actor (MetaWindowActor *actor,
|
|
|
|
MetaSurfaceActor *surface_actor)
|
|
|
|
{
|
|
|
|
MetaWindowActorClass *parent_class =
|
|
|
|
META_WINDOW_ACTOR_CLASS (meta_window_actor_wayland_parent_class);
|
|
|
|
|
2019-08-17 10:00:46 +02:00
|
|
|
g_warn_if_fail (!meta_window_actor_get_surface (actor));
|
|
|
|
|
2019-06-30 15:18:46 +02:00
|
|
|
parent_class->assign_surface_actor (actor, surface_actor);
|
|
|
|
|
|
|
|
meta_window_actor_wayland_rebuild_surface_tree (actor);
|
|
|
|
}
|
|
|
|
|
2018-12-21 18:51:02 -02:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_frame_complete (MetaWindowActor *actor,
|
|
|
|
ClutterFrameInfo *frame_info,
|
|
|
|
int64_t presentation_time)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_queue_frame_drawn (MetaWindowActor *actor,
|
|
|
|
gboolean skip_sync_delay)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-30 00:27:56 +02:00
|
|
|
meta_window_actor_wayland_before_paint (MetaWindowActor *actor,
|
|
|
|
ClutterStageView *stage_view)
|
2018-12-21 18:51:02 -02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
clutter: Paint views with individual frame clocks
Replace the default master clock with multiple frame clocks, each
driving its own stage view. As each stage view represents one CRTC, this
means we draw each CRTC with its own designated frame clock,
disconnected from all the others.
For example this means we when using the native backend will never need
to wait for one monitor to vsync before painting another, so e.g. having
a 144 Hz monitor next to a 60 Hz monitor, things including both Wayland
and X11 applications and shell UI will be able to render at the
corresponding monitor refresh rate.
This also changes a warning about missed frames when sending
_NETWM_FRAME_TIMINGS messages to a debug log entry, as it's expected
that we'll start missing frames e.g. when a X11 window (via Xwayland) is
exclusively within a stage view that was not painted, while another one
was, still increasing the global frame clock.
Addititonally, this also requires the X11 window actor to schedule
timeouts for _NET_WM_FRAME_DRAWN/_NET_WM_FRAME_TIMINGS event emitting,
if the actor wasn't on any stage views, as now we'll only get the frame
callbacks on actors when they actually were painted, while in the past,
we'd invoke that vfunc when anything was painted.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/903
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-05-30 00:27:56 +02:00
|
|
|
meta_window_actor_wayland_after_paint (MetaWindowActor *actor,
|
|
|
|
ClutterStageView *stage_view)
|
2018-12-21 18:51:02 -02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_queue_destroy (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-09 15:06:58 +01:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_set_frozen (MetaWindowActor *actor,
|
|
|
|
gboolean frozen)
|
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
|
|
|
ClutterActor *child;
|
|
|
|
ClutterActorIter iter;
|
|
|
|
|
|
|
|
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (self->surface_container));
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
meta_surface_actor_set_frozen (META_SURFACE_ACTOR (child), frozen);
|
2019-12-09 15:06:58 +01:00
|
|
|
}
|
|
|
|
|
2020-03-03 10:26:54 +01:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_update_regions (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-22 16:26:17 +01:00
|
|
|
static gboolean
|
|
|
|
meta_window_actor_wayland_can_freeze_commits (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-03-15 12:21:17 +01:00
|
|
|
static gboolean
|
|
|
|
meta_window_actor_wayland_is_single_surface_actor (MetaWindowActor *actor)
|
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
|
|
|
ClutterActor *surface_container = CLUTTER_ACTOR (self->surface_container);
|
|
|
|
|
|
|
|
return clutter_actor_get_n_children (surface_container) == 1 &&
|
|
|
|
!self->background;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
maybe_configure_black_background (MetaWindowActorWayland *self,
|
|
|
|
float *surfaces_width,
|
|
|
|
float *surfaces_height,
|
|
|
|
float *background_width,
|
|
|
|
float *background_height)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (self);
|
|
|
|
MetaWindow *window = meta_window_actor_get_meta_window (window_actor);
|
|
|
|
MetaLogicalMonitor *logical_monitor;
|
|
|
|
int geometry_scale;
|
2023-07-20 01:46:15 +02:00
|
|
|
MtkRectangle fullscreen_layout;
|
2022-05-03 18:47:57 +02:00
|
|
|
ClutterActor *child;
|
|
|
|
ClutterActorIter iter;
|
|
|
|
float max_width = 0;
|
|
|
|
float max_height = 0;
|
|
|
|
|
|
|
|
if (!meta_window_wayland_is_acked_fullscreen (META_WINDOW_WAYLAND (window)))
|
2022-11-15 00:46:14 +01:00
|
|
|
return FALSE;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
|
|
|
geometry_scale = meta_window_actor_get_geometry_scale (window_actor);
|
|
|
|
|
|
|
|
logical_monitor = meta_window_get_main_logical_monitor (window);
|
2022-11-15 00:46:14 +01:00
|
|
|
if (!logical_monitor)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
fullscreen_layout = meta_logical_monitor_get_layout (logical_monitor);
|
|
|
|
|
|
|
|
clutter_actor_iter_init (&iter, CLUTTER_ACTOR (self->surface_container));
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
{
|
2023-10-04 22:45:13 +02:00
|
|
|
ClutterActorBox actor_box;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
2023-10-04 22:45:13 +02:00
|
|
|
if (!clutter_actor_is_mapped (child))
|
|
|
|
continue;
|
2022-05-03 18:47:57 +02:00
|
|
|
|
2023-10-04 22:45:13 +02:00
|
|
|
clutter_actor_get_allocation_box (child, &actor_box);
|
|
|
|
if (meta_surface_actor_is_opaque (META_SURFACE_ACTOR (child)) &&
|
|
|
|
G_APPROX_VALUE (actor_box.x1, 0, CLUTTER_COORDINATE_EPSILON) &&
|
|
|
|
G_APPROX_VALUE (actor_box.y1, 0, CLUTTER_COORDINATE_EPSILON) &&
|
|
|
|
G_APPROX_VALUE (actor_box.x2, fullscreen_layout.width,
|
2022-05-03 18:47:57 +02:00
|
|
|
CLUTTER_COORDINATE_EPSILON) &&
|
2023-10-04 22:45:13 +02:00
|
|
|
G_APPROX_VALUE (actor_box.y2, fullscreen_layout.height,
|
2022-05-03 18:47:57 +02:00
|
|
|
CLUTTER_COORDINATE_EPSILON))
|
|
|
|
return FALSE;
|
|
|
|
|
2023-10-04 22:45:13 +02:00
|
|
|
max_width = MAX (max_width, actor_box.x2 - actor_box.x1);
|
|
|
|
max_height = MAX (max_height, actor_box.y2 - actor_box.y1);
|
2022-05-03 18:47:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*surfaces_width = max_width;
|
|
|
|
*surfaces_height = max_height;
|
|
|
|
*background_width = window->rect.width / geometry_scale;
|
|
|
|
*background_height = window->rect.height / geometry_scale;
|
|
|
|
return TRUE;
|
2022-03-15 12:21:17 +01:00
|
|
|
}
|
|
|
|
|
2021-08-06 13:09:04 +02:00
|
|
|
static void
|
2023-07-20 01:46:15 +02:00
|
|
|
meta_window_actor_wayland_sync_geometry (MetaWindowActor *actor,
|
|
|
|
const MtkRectangle *actor_rect)
|
2021-08-06 13:09:04 +02:00
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
|
|
|
ClutterActor *surface_container = CLUTTER_ACTOR (self->surface_container);
|
|
|
|
MetaWindow *window;
|
|
|
|
float surfaces_width, surfaces_height;
|
|
|
|
float background_width, background_height;
|
2021-08-06 13:09:04 +02:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
window = meta_window_actor_get_meta_window (actor);
|
|
|
|
if (window->unmanaging)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (maybe_configure_black_background (self,
|
|
|
|
&surfaces_width, &surfaces_height,
|
|
|
|
&background_width, &background_height))
|
2021-08-06 13:09:04 +02:00
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
int geometry_scale;
|
|
|
|
int child_actor_width, child_actor_height;
|
2021-08-06 13:09:04 +02:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
if (!self->background)
|
|
|
|
{
|
|
|
|
self->background = clutter_actor_new ();
|
|
|
|
clutter_actor_set_background_color (self->background,
|
|
|
|
CLUTTER_COLOR_Black);
|
|
|
|
clutter_actor_set_reactive (self->background, TRUE);
|
|
|
|
clutter_actor_insert_child_below (CLUTTER_ACTOR (self),
|
|
|
|
self->background,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
geometry_scale =
|
|
|
|
meta_window_actor_get_geometry_scale (actor);
|
|
|
|
child_actor_width = actor_rect->width / geometry_scale;
|
|
|
|
child_actor_height = actor_rect->height / geometry_scale;
|
2021-08-06 13:09:04 +02:00
|
|
|
|
2022-05-03 18:47:57 +02:00
|
|
|
clutter_actor_set_size (self->background,
|
|
|
|
background_width, background_height);
|
|
|
|
clutter_actor_set_position (surface_container,
|
|
|
|
(child_actor_width - surfaces_width) / 2,
|
|
|
|
(child_actor_height - surfaces_height) / 2);
|
|
|
|
}
|
|
|
|
else if (self->background)
|
|
|
|
{
|
|
|
|
clutter_actor_set_position (surface_container, 0, 0);
|
|
|
|
g_clear_pointer (&self->background, clutter_actor_destroy);
|
|
|
|
}
|
2021-08-06 13:09:04 +02:00
|
|
|
}
|
|
|
|
|
2022-11-26 16:22:05 +07:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (object);
|
|
|
|
MetaWindow *window = meta_window_actor_get_meta_window (META_WINDOW_ACTOR (self));
|
|
|
|
GObjectClass *parent_class =
|
|
|
|
G_OBJECT_CLASS (meta_window_actor_wayland_parent_class);
|
|
|
|
|
|
|
|
g_clear_signal_handler (&self->highest_scale_monitor_handler_id,
|
|
|
|
window);
|
|
|
|
|
|
|
|
parent_class->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (object);
|
|
|
|
MetaWindow *window = meta_window_actor_get_meta_window (META_WINDOW_ACTOR (self));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_window_actor_wayland_parent_class)->constructed (object);
|
|
|
|
|
|
|
|
self->highest_scale_monitor_handler_id =
|
|
|
|
g_signal_connect_swapped (window, "highest-scale-monitor-changed",
|
|
|
|
G_CALLBACK (clutter_actor_notify_transform_invalid),
|
|
|
|
self->surface_container);
|
|
|
|
}
|
|
|
|
|
2018-12-21 18:35:18 -02:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
|
|
|
|
{
|
2018-12-21 18:51:02 -02:00
|
|
|
MetaWindowActorClass *window_actor_class = META_WINDOW_ACTOR_CLASS (klass);
|
2022-11-26 16:22:05 +07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2018-12-21 18:51:02 -02:00
|
|
|
|
2022-05-11 22:32:33 +02:00
|
|
|
window_actor_class->get_scanout_candidate = meta_window_actor_wayland_get_scanout_candidate;
|
2019-06-30 15:18:46 +02:00
|
|
|
window_actor_class->assign_surface_actor = meta_window_actor_wayland_assign_surface_actor;
|
2018-12-21 18:51:02 -02:00
|
|
|
window_actor_class->frame_complete = meta_window_actor_wayland_frame_complete;
|
|
|
|
window_actor_class->queue_frame_drawn = meta_window_actor_wayland_queue_frame_drawn;
|
2020-05-30 00:02:42 +02:00
|
|
|
window_actor_class->before_paint = meta_window_actor_wayland_before_paint;
|
|
|
|
window_actor_class->after_paint = meta_window_actor_wayland_after_paint;
|
2018-12-21 18:51:02 -02:00
|
|
|
window_actor_class->queue_destroy = meta_window_actor_wayland_queue_destroy;
|
2019-12-09 15:06:58 +01:00
|
|
|
window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
|
2020-03-03 10:26:54 +01:00
|
|
|
window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
|
2021-01-22 16:26:17 +01:00
|
|
|
window_actor_class->can_freeze_commits = meta_window_actor_wayland_can_freeze_commits;
|
2022-05-03 18:47:57 +02:00
|
|
|
window_actor_class->sync_geometry = meta_window_actor_wayland_sync_geometry;
|
2022-03-15 12:21:17 +01:00
|
|
|
window_actor_class->is_single_surface_actor = meta_window_actor_wayland_is_single_surface_actor;
|
2022-11-26 16:22:05 +07:00
|
|
|
|
|
|
|
object_class->constructed = meta_window_actor_wayland_constructed;
|
|
|
|
object_class->dispose = meta_window_actor_wayland_dispose;
|
2018-12-21 18:35:18 -02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_init (MetaWindowActorWayland *self)
|
|
|
|
{
|
2022-05-03 18:47:57 +02:00
|
|
|
self->surface_container = surface_container_new (META_WINDOW_ACTOR (self));
|
|
|
|
|
|
|
|
clutter_actor_add_child (CLUTTER_ACTOR (self),
|
|
|
|
CLUTTER_ACTOR (self->surface_container));
|
2022-11-26 16:22:05 +07:00
|
|
|
|
|
|
|
g_signal_connect_swapped (self, "notify::allocation",
|
|
|
|
G_CALLBACK (clutter_actor_notify_transform_invalid),
|
|
|
|
self->surface_container);
|
2018-12-21 18:35:18 -02:00
|
|
|
}
|