2018-12-21 20:35:18 +00: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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Georges Basile Stavracas Neto <gbsneto@gnome.org>
|
|
|
|
*/
|
|
|
|
|
2022-05-30 21:14:05 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
#include "compositor/clutter-utils.h"
|
2022-03-15 10:34:26 +00:00
|
|
|
#include "compositor/meta-cullable.h"
|
2019-06-30 13:18:46 +00:00
|
|
|
#include "compositor/meta-surface-actor-wayland.h"
|
2018-12-21 20:35:18 +00:00
|
|
|
#include "compositor/meta-window-actor-wayland.h"
|
2022-05-03 16:47:57 +00:00
|
|
|
#include "compositor/region-utils.h"
|
2018-12-21 20:35:18 +00:00
|
|
|
#include "meta/meta-window-actor.h"
|
2019-06-30 13:18:46 +00:00
|
|
|
#include "wayland/meta-wayland-surface.h"
|
2022-05-03 16:47:57 +00: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 20:35:18 +00:00
|
|
|
|
|
|
|
struct _MetaWindowActorWayland
|
|
|
|
{
|
|
|
|
MetaWindowActor parent;
|
2022-05-03 16:47:57 +00:00
|
|
|
ClutterActor *background;
|
|
|
|
MetaSurfaceContainerActorWayland *surface_container;
|
2018-12-21 20:35:18 +00:00
|
|
|
};
|
|
|
|
|
2022-03-15 10:34:26 +00: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 20:35:18 +00:00
|
|
|
|
2021-04-16 13:15:41 +00:00
|
|
|
typedef struct _SurfaceTreeTraverseData
|
2019-06-30 13:18:46 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
ClutterActor *surface_container;
|
2021-04-16 13:15:41 +00:00
|
|
|
int index;
|
|
|
|
} SurfaceTreeTraverseData;
|
2019-06-30 13:18:46 +00:00
|
|
|
|
2022-05-03 16:47:57 +00: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
|
|
|
|
surface_container_cull_out (MetaCullable *cullable,
|
|
|
|
cairo_region_t *unobscured_region,
|
|
|
|
cairo_region_t *clip_region)
|
|
|
|
{
|
|
|
|
meta_cullable_cull_out_children (cullable, unobscured_region, clip_region);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
surface_container_is_untransformed (MetaCullable *cullable)
|
|
|
|
{
|
|
|
|
MetaSurfaceContainerActorWayland *surface_container =
|
|
|
|
META_SURFACE_CONTAINER_ACTOR_WAYLAND (cullable);
|
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (cullable);
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
float width, height;
|
|
|
|
graphene_point3d_t verts[4];
|
|
|
|
int geometry_scale;
|
|
|
|
|
|
|
|
clutter_actor_get_size (actor, &width, &height);
|
|
|
|
clutter_actor_get_abs_allocation_vertices (actor, verts);
|
|
|
|
|
|
|
|
window_actor = surface_container->window_actor;
|
|
|
|
geometry_scale = meta_window_actor_get_geometry_scale (window_actor);
|
|
|
|
|
|
|
|
return meta_actor_vertices_are_untransformed (verts,
|
|
|
|
width * geometry_scale,
|
|
|
|
height * geometry_scale,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_container_reset_culling (MetaCullable *cullable)
|
|
|
|
{
|
|
|
|
meta_cullable_reset_culling_children (cullable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
surface_container_cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
|
|
|
iface->cull_out = surface_container_cull_out;
|
|
|
|
iface->is_untransformed = surface_container_is_untransformed;
|
|
|
|
iface->reset_culling = surface_container_reset_culling;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->dispose = surface_container_dispose;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_surface_container_actor_wayland_init (MetaSurfaceContainerActorWayland *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-07-08 19:03:52 +00: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 13:18:46 +00:00
|
|
|
static gboolean
|
2021-04-16 13:15:41 +00:00
|
|
|
set_surface_actor_index (GNode *node,
|
|
|
|
gpointer data)
|
2019-06-30 13:18:46 +00:00
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = node->data;
|
2021-04-16 13:15:41 +00:00
|
|
|
SurfaceTreeTraverseData *traverse_data = data;
|
2022-05-03 16:47:57 +00:00
|
|
|
ClutterActor *container = traverse_data->surface_container;
|
2022-07-09 12:27:35 +00:00
|
|
|
ClutterActor *surface_actor =
|
|
|
|
CLUTTER_ACTOR (meta_wayland_surface_get_actor (surface));
|
2021-04-16 13:15:41 +00:00
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
if (clutter_actor_contains (container, surface_actor))
|
2021-04-16 13:15:41 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
if (clutter_actor_get_child_at_index (container, traverse_data->index) !=
|
2022-07-09 12:27:35 +00:00
|
|
|
surface_actor)
|
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
clutter_actor_set_child_at_index (container,
|
2022-07-09 12:27:35 +00:00
|
|
|
surface_actor,
|
|
|
|
traverse_data->index);
|
|
|
|
}
|
2021-04-16 13:15:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
clutter_actor_insert_child_at_index (container,
|
2022-07-09 12:27:35 +00:00
|
|
|
surface_actor,
|
|
|
|
traverse_data->index);
|
2021-04-16 13:15:41 +00:00
|
|
|
}
|
|
|
|
traverse_data->index++;
|
2019-06-30 13:18:46 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_actor_wayland_rebuild_surface_tree (MetaWindowActor *actor)
|
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
2019-06-30 13:18:46 +00: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 14:01:37 +00:00
|
|
|
GNode *root_node = surface->output_state.subsurface_branch_node;
|
2022-07-08 19:03:52 +00:00
|
|
|
g_autoptr (GList) surface_actors = NULL;
|
|
|
|
g_autoptr (GList) children = NULL;
|
|
|
|
GList *l;
|
2021-04-16 13:15:41 +00:00
|
|
|
SurfaceTreeTraverseData traverse_data;
|
2019-06-30 13:18:46 +00:00
|
|
|
|
2022-07-08 19:03:52 +00:00
|
|
|
g_node_traverse (root_node,
|
|
|
|
G_IN_ORDER,
|
|
|
|
G_TRAVERSE_LEAVES,
|
|
|
|
-1,
|
|
|
|
get_surface_actor_list,
|
|
|
|
&surface_actors);
|
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
children =
|
|
|
|
clutter_actor_get_children (CLUTTER_ACTOR (self->surface_container));
|
2022-07-08 19:03:52 +00:00
|
|
|
for (l = children; l; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterActor *child_actor = l->data;
|
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
if (!g_list_find (surface_actors, child_actor))
|
|
|
|
{
|
|
|
|
clutter_actor_remove_child (CLUTTER_ACTOR (self->surface_container),
|
|
|
|
child_actor);
|
|
|
|
}
|
2022-07-08 19:03:52 +00:00
|
|
|
}
|
|
|
|
|
2021-04-16 13:15:41 +00:00
|
|
|
traverse_data = (SurfaceTreeTraverseData) {
|
2022-05-03 16:47:57 +00:00
|
|
|
.surface_container = CLUTTER_ACTOR (self->surface_container),
|
2021-04-16 13:15:41 +00:00
|
|
|
.index = 0,
|
|
|
|
};
|
2019-06-30 13:18:46 +00:00
|
|
|
g_node_traverse (root_node,
|
|
|
|
G_IN_ORDER,
|
|
|
|
G_TRAVERSE_LEAVES,
|
|
|
|
-1,
|
2021-04-16 13:15:41 +00:00
|
|
|
set_surface_actor_index,
|
|
|
|
&traverse_data);
|
2019-06-30 13:18:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
static cairo_region_t *
|
|
|
|
calculate_background_cull_region (MetaWindowActorWayland *self)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor = META_WINDOW_ACTOR (self);
|
|
|
|
int geometry_scale;
|
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
|
|
|
geometry_scale = meta_window_actor_get_geometry_scale (window_actor);
|
|
|
|
rect = (cairo_rectangle_int_t) {
|
|
|
|
.x = 0,
|
|
|
|
.y = 0,
|
|
|
|
.width = clutter_actor_get_width (self->background) * geometry_scale,
|
|
|
|
.height = clutter_actor_get_height (self->background) * geometry_scale,
|
|
|
|
};
|
|
|
|
|
|
|
|
return cairo_region_create_rectangle (&rect);
|
|
|
|
}
|
|
|
|
|
2022-03-15 10:34:26 +00:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_cull_out (MetaCullable *cullable,
|
|
|
|
cairo_region_t *unobscured_region,
|
|
|
|
cairo_region_t *clip_region)
|
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
MetaWindowActorWayland *self =
|
|
|
|
META_WINDOW_ACTOR_WAYLAND (cullable);
|
|
|
|
|
|
|
|
meta_cullable_cull_out_children (META_CULLABLE (self),
|
2022-03-15 10:34:26 +00:00
|
|
|
unobscured_region,
|
|
|
|
clip_region);
|
2022-05-03 16:47:57 +00:00
|
|
|
if (self->background)
|
|
|
|
{
|
|
|
|
cairo_region_t *background_cull_region;
|
|
|
|
|
|
|
|
background_cull_region = calculate_background_cull_region (self);
|
|
|
|
|
|
|
|
if (unobscured_region)
|
|
|
|
cairo_region_subtract (unobscured_region, background_cull_region);
|
|
|
|
if (clip_region)
|
|
|
|
cairo_region_subtract (clip_region, background_cull_region);
|
|
|
|
|
|
|
|
cairo_region_destroy (background_cull_region);
|
|
|
|
}
|
2022-03-15 10:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_reset_culling (MetaCullable *cullable)
|
|
|
|
{
|
|
|
|
meta_cullable_reset_culling_children (cullable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
|
|
|
iface->cull_out = meta_window_actor_wayland_cull_out;
|
|
|
|
iface->reset_culling = meta_window_actor_wayland_reset_culling;
|
|
|
|
}
|
|
|
|
|
2022-01-05 21:05:50 +00:00
|
|
|
static MetaSurfaceActor *
|
2022-05-11 20:32:33 +00:00
|
|
|
meta_window_actor_wayland_get_scanout_candidate (MetaWindowActor *actor)
|
2022-01-05 21:05:50 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
MetaWindowActorWayland *self = META_WINDOW_ACTOR_WAYLAND (actor);
|
|
|
|
ClutterActor *surface_container = CLUTTER_ACTOR (self->surface_container);
|
2022-01-05 21:05:50 +00:00
|
|
|
ClutterActor *child_actor;
|
2022-12-09 20:47:32 +00:00
|
|
|
ClutterActorIter iter;
|
|
|
|
MetaSurfaceActor *topmost_surface_actor = NULL;
|
2022-05-11 20:49:08 +00:00
|
|
|
MetaWindow *window;
|
2022-12-09 20:47:32 +00:00
|
|
|
int n_mapped_surfaces = 0;
|
2022-01-05 21:05:50 +00:00
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
if (clutter_actor_get_last_child (CLUTTER_ACTOR (self)) != surface_container)
|
2022-10-28 21:03:42 +00:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"Top child of window-actor not a surface");
|
2022-12-16 19:42:10 +00:00
|
|
|
return NULL;
|
2022-10-28 21:03:42 +00:00
|
|
|
}
|
2022-05-03 16:47:57 +00:00
|
|
|
|
2022-12-09 20:47:32 +00: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 21:03:42 +00:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"No surface-actor for window-actor");
|
2022-12-16 19:42:10 +00:00
|
|
|
return NULL;
|
2022-10-28 21:03:42 +00:00
|
|
|
}
|
2022-05-11 20:32:33 +00:00
|
|
|
|
2022-05-11 20:49:08 +00:00
|
|
|
window = meta_window_actor_get_meta_window (actor);
|
2022-05-03 16:47:57 +00:00
|
|
|
if (!meta_surface_actor_is_opaque (topmost_surface_actor) &&
|
2022-12-09 20:47:32 +00:00
|
|
|
!(meta_window_is_fullscreen (window) && n_mapped_surfaces == 1))
|
2022-10-28 21:03:42 +00:00
|
|
|
{
|
|
|
|
meta_topic (META_DEBUG_RENDER,
|
|
|
|
"Window-actor is not opaque");
|
2022-12-16 19:42:10 +00:00
|
|
|
return NULL;
|
2022-10-28 21:03:42 +00:00
|
|
|
}
|
2022-05-11 20:49:08 +00:00
|
|
|
|
2022-05-11 20:32:33 +00:00
|
|
|
return topmost_surface_actor;
|
2022-01-05 21:05:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 13:18:46 +00: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 08:00:46 +00:00
|
|
|
g_warn_if_fail (!meta_window_actor_get_surface (actor));
|
|
|
|
|
2019-06-30 13:18:46 +00:00
|
|
|
parent_class->assign_surface_actor (actor, surface_actor);
|
|
|
|
|
|
|
|
meta_window_actor_wayland_rebuild_surface_tree (actor);
|
|
|
|
}
|
|
|
|
|
2018-12-21 20:51:02 +00: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-29 22:27:56 +00:00
|
|
|
meta_window_actor_wayland_before_paint (MetaWindowActor *actor,
|
|
|
|
ClutterStageView *stage_view)
|
2018-12-21 20:51:02 +00: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-29 22:27:56 +00:00
|
|
|
meta_window_actor_wayland_after_paint (MetaWindowActor *actor,
|
|
|
|
ClutterStageView *stage_view)
|
2018-12-21 20:51:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_queue_destroy (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-12-09 14:06:58 +00:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_set_frozen (MetaWindowActor *actor,
|
|
|
|
gboolean frozen)
|
|
|
|
{
|
2022-05-03 16:47:57 +00: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 14:06:58 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 09:26:54 +00:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_update_regions (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-22 15:26:17 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_actor_wayland_can_freeze_commits (MetaWindowActor *actor)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-03-15 11:21:17 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_actor_wayland_is_single_surface_actor (MetaWindowActor *actor)
|
|
|
|
{
|
2022-05-03 16:47:57 +00: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;
|
|
|
|
MetaRectangle fullscreen_layout;
|
|
|
|
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-14 23:46:14 +00:00
|
|
|
return FALSE;
|
2022-05-03 16:47:57 +00:00
|
|
|
|
|
|
|
geometry_scale = meta_window_actor_get_geometry_scale (window_actor);
|
|
|
|
|
|
|
|
logical_monitor = meta_window_get_main_logical_monitor (window);
|
2022-11-14 23:46:14 +00:00
|
|
|
if (!logical_monitor)
|
|
|
|
return FALSE;
|
|
|
|
|
2022-05-03 16:47:57 +00: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))
|
|
|
|
{
|
|
|
|
float child_width, child_height;
|
|
|
|
|
|
|
|
clutter_actor_get_size (child, &child_width, &child_height);
|
|
|
|
|
|
|
|
if (META_IS_SURFACE_ACTOR (child) &&
|
|
|
|
meta_surface_actor_is_opaque (META_SURFACE_ACTOR (child)) &&
|
|
|
|
G_APPROX_VALUE (clutter_actor_get_x (child), 0,
|
|
|
|
CLUTTER_COORDINATE_EPSILON) &&
|
|
|
|
G_APPROX_VALUE (clutter_actor_get_y (child), 0,
|
|
|
|
CLUTTER_COORDINATE_EPSILON) &&
|
|
|
|
G_APPROX_VALUE (child_width, fullscreen_layout.width,
|
|
|
|
CLUTTER_COORDINATE_EPSILON) &&
|
|
|
|
G_APPROX_VALUE (child_height, fullscreen_layout.height,
|
|
|
|
CLUTTER_COORDINATE_EPSILON))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
max_width = MAX (max_width, child_width);
|
|
|
|
max_height = MAX (max_height, child_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
*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 11:21:17 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 11:09:04 +00:00
|
|
|
static void
|
2022-05-03 16:47:57 +00:00
|
|
|
meta_window_actor_wayland_sync_geometry (MetaWindowActor *actor,
|
|
|
|
const MetaRectangle *actor_rect)
|
2021-08-06 11:09:04 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00: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 11:09:04 +00:00
|
|
|
|
2022-05-03 16:47:57 +00: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 11:09:04 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
int geometry_scale;
|
|
|
|
int child_actor_width, child_actor_height;
|
2021-08-06 11:09:04 +00:00
|
|
|
|
2022-05-03 16:47:57 +00: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 11:09:04 +00:00
|
|
|
|
2022-05-03 16:47:57 +00: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 11:09:04 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 20:35:18 +00:00
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
|
|
|
|
{
|
2018-12-21 20:51:02 +00:00
|
|
|
MetaWindowActorClass *window_actor_class = META_WINDOW_ACTOR_CLASS (klass);
|
|
|
|
|
2022-05-11 20:32:33 +00:00
|
|
|
window_actor_class->get_scanout_candidate = meta_window_actor_wayland_get_scanout_candidate;
|
2019-06-30 13:18:46 +00:00
|
|
|
window_actor_class->assign_surface_actor = meta_window_actor_wayland_assign_surface_actor;
|
2018-12-21 20:51:02 +00: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-29 22:02:42 +00: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 20:51:02 +00:00
|
|
|
window_actor_class->queue_destroy = meta_window_actor_wayland_queue_destroy;
|
2019-12-09 14:06:58 +00:00
|
|
|
window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
|
2020-03-03 09:26:54 +00:00
|
|
|
window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
|
2021-01-22 15:26:17 +00:00
|
|
|
window_actor_class->can_freeze_commits = meta_window_actor_wayland_can_freeze_commits;
|
2022-05-03 16:47:57 +00:00
|
|
|
window_actor_class->sync_geometry = meta_window_actor_wayland_sync_geometry;
|
2022-03-15 11:21:17 +00:00
|
|
|
window_actor_class->is_single_surface_actor = meta_window_actor_wayland_is_single_surface_actor;
|
2018-12-21 20:35:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_actor_wayland_init (MetaWindowActorWayland *self)
|
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
self->surface_container = surface_container_new (META_WINDOW_ACTOR (self));
|
|
|
|
|
|
|
|
clutter_actor_add_child (CLUTTER_ACTOR (self),
|
|
|
|
CLUTTER_ACTOR (self->surface_container));
|
2018-12-21 20:35:18 +00:00
|
|
|
}
|