2009-06-29 14:30:26 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2010-06-29 18:43:56 -04:00
|
|
|
#include <config.h>
|
|
|
|
|
2009-06-29 14:30:26 -04:00
|
|
|
#define _ISOC99_SOURCE /* for roundf */
|
|
|
|
#include <math.h>
|
|
|
|
|
2010-11-13 15:44:59 -05:00
|
|
|
#include <gdk/gdk.h> /* for gdk_rectangle_intersect() */
|
|
|
|
|
2013-01-23 15:54:41 -05:00
|
|
|
#include "clutter-utils.h"
|
2011-08-27 05:43:09 -04:00
|
|
|
#include "compositor-private.h"
|
2010-10-18 13:27:14 -04:00
|
|
|
#include "meta-window-actor-private.h"
|
2018-05-02 12:53:11 -04:00
|
|
|
#include "meta-window-group-private.h"
|
2012-01-07 17:21:32 -05:00
|
|
|
#include "window-private.h"
|
2013-11-21 15:25:08 -05:00
|
|
|
#include "meta-cullable.h"
|
2017-08-26 12:37:29 -04:00
|
|
|
#include "display-private.h"
|
2009-06-29 14:30:26 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
struct _MetaWindowGroupClass
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
2012-01-17 09:16:46 -05:00
|
|
|
ClutterActorClass parent_class;
|
2009-06-29 14:30:26 -04:00
|
|
|
};
|
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
struct _MetaWindowGroup
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
2012-01-17 09:16:46 -05:00
|
|
|
ClutterActor parent;
|
2009-06-29 14:30:26 -04:00
|
|
|
|
|
|
|
MetaScreen *screen;
|
|
|
|
};
|
|
|
|
|
2013-11-21 15:25:08 -05:00
|
|
|
static void cullable_iface_init (MetaCullableInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaWindowGroup, meta_window_group, CLUTTER_TYPE_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
|
2009-06-29 14:30:26 -04:00
|
|
|
|
|
|
|
static void
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_window_group_cull_out (MetaCullable *cullable,
|
|
|
|
cairo_region_t *unobscured_region,
|
|
|
|
cairo_region_t *clip_region)
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_cullable_cull_out_children (cullable, unobscured_region, clip_region);
|
2013-11-25 15:17:14 -05:00
|
|
|
}
|
2009-06-29 14:30:26 -04:00
|
|
|
|
2013-11-25 15:17:14 -05:00
|
|
|
static void
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_window_group_reset_culling (MetaCullable *cullable)
|
2013-11-25 15:17:14 -05:00
|
|
|
{
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_cullable_reset_culling_children (cullable);
|
|
|
|
}
|
2009-06-29 14:30:26 -04:00
|
|
|
|
2013-11-21 15:25:08 -05:00
|
|
|
static void
|
|
|
|
cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
|
|
|
iface->cull_out = meta_window_group_cull_out;
|
|
|
|
iface->reset_culling = meta_window_group_reset_culling;
|
2009-06-29 14:30:26 -04:00
|
|
|
}
|
|
|
|
|
2013-11-25 15:17:14 -05:00
|
|
|
static void
|
|
|
|
meta_window_group_paint (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
cairo_region_t *clip_region;
|
|
|
|
cairo_region_t *unobscured_region;
|
|
|
|
cairo_rectangle_int_t visible_rect, clip_rect;
|
|
|
|
int paint_x_origin, paint_y_origin;
|
2014-08-27 12:44:26 -04:00
|
|
|
int screen_width, screen_height;
|
2013-11-25 15:17:14 -05:00
|
|
|
|
|
|
|
MetaWindowGroup *window_group = META_WINDOW_GROUP (actor);
|
|
|
|
ClutterActor *stage = clutter_actor_get_stage (actor);
|
|
|
|
|
2017-08-26 12:37:29 -04:00
|
|
|
meta_display_get_size (window_group->screen->display, &screen_width, &screen_height);
|
2014-08-27 12:44:26 -04:00
|
|
|
|
2013-11-25 15:17:14 -05:00
|
|
|
/* Normally we expect an actor to be drawn at it's position on the screen.
|
|
|
|
* However, if we're inside the paint of a ClutterClone, that won't be the
|
|
|
|
* case and we need to compensate. We look at the position of the window
|
|
|
|
* group under the current model-view matrix and the position of the actor.
|
|
|
|
* If they are both simply integer translations, then we can compensate
|
|
|
|
* easily, otherwise we give up.
|
|
|
|
*
|
|
|
|
* Possible cleanup: work entirely in paint space - we can compute the
|
|
|
|
* combination of the model-view matrix with the local matrix for each child
|
|
|
|
* actor and get a total transformation for that actor for how we are
|
|
|
|
* painting currently, and never worry about how actors are positioned
|
|
|
|
* on the stage.
|
|
|
|
*/
|
2016-07-15 04:09:41 -04:00
|
|
|
if (clutter_actor_is_in_clone_paint (actor))
|
2013-11-25 15:17:14 -05:00
|
|
|
{
|
2016-07-15 04:09:41 -04:00
|
|
|
if (!meta_actor_painting_untransformed (screen_width,
|
|
|
|
screen_height,
|
|
|
|
&paint_x_origin,
|
|
|
|
&paint_y_origin) ||
|
|
|
|
!meta_actor_is_untransformed (actor, NULL, NULL))
|
|
|
|
{
|
|
|
|
CLUTTER_ACTOR_CLASS (meta_window_group_parent_class)->paint (actor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paint_x_origin = 0;
|
|
|
|
paint_y_origin = 0;
|
2013-11-25 15:17:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
visible_rect.x = visible_rect.y = 0;
|
|
|
|
visible_rect.width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
|
|
|
visible_rect.height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
|
|
unobscured_region = cairo_region_create_rectangle (&visible_rect);
|
|
|
|
|
|
|
|
/* Get the clipped redraw bounds from Clutter so that we can avoid
|
|
|
|
* painting shadows on windows that don't need to be painted in this
|
|
|
|
* frame. In the case of a multihead setup with mismatched monitor
|
|
|
|
* sizes, we could intersect this with an accurate union of the
|
|
|
|
* monitors to avoid painting shadows that are visible only in the
|
|
|
|
* holes. */
|
|
|
|
clutter_stage_get_redraw_clip_bounds (CLUTTER_STAGE (stage),
|
|
|
|
&clip_rect);
|
|
|
|
|
|
|
|
clip_region = cairo_region_create_rectangle (&clip_rect);
|
|
|
|
|
2015-07-06 02:55:43 -04:00
|
|
|
cairo_region_translate (clip_region, -paint_x_origin, -paint_y_origin);
|
2013-11-25 15:17:14 -05:00
|
|
|
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_cullable_cull_out (META_CULLABLE (window_group), unobscured_region, clip_region);
|
2013-11-25 15:17:14 -05:00
|
|
|
|
|
|
|
cairo_region_destroy (unobscured_region);
|
|
|
|
cairo_region_destroy (clip_region);
|
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (meta_window_group_parent_class)->paint (actor);
|
|
|
|
|
2013-11-21 15:25:08 -05:00
|
|
|
meta_cullable_reset_culling (META_CULLABLE (window_group));
|
2013-11-25 15:17:14 -05:00
|
|
|
}
|
|
|
|
|
2013-12-03 00:27:03 -05:00
|
|
|
/* Adapted from clutter_actor_update_default_paint_volume() */
|
2013-03-02 07:04:20 -05:00
|
|
|
static gboolean
|
2013-12-03 00:27:03 -05:00
|
|
|
meta_window_group_get_paint_volume (ClutterActor *self,
|
2013-03-02 07:04:20 -05:00
|
|
|
ClutterPaintVolume *volume)
|
|
|
|
{
|
2013-12-03 00:27:03 -05:00
|
|
|
ClutterActorIter iter;
|
|
|
|
ClutterActor *child;
|
|
|
|
|
|
|
|
clutter_actor_iter_init (&iter, self);
|
|
|
|
while (clutter_actor_iter_next (&iter, &child))
|
|
|
|
{
|
|
|
|
const ClutterPaintVolume *child_volume;
|
|
|
|
|
|
|
|
if (!CLUTTER_ACTOR_IS_MAPPED (child))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
child_volume = clutter_actor_get_transformed_paint_volume (child, self);
|
|
|
|
if (child_volume == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
clutter_paint_volume_union (volume, child_volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2013-03-02 07:04:20 -05:00
|
|
|
}
|
|
|
|
|
2015-07-05 22:18:22 -04:00
|
|
|
/* This is a workaround for Clutter's awful allocation tracking.
|
|
|
|
* Without this, any time the window group changed size, which is
|
|
|
|
* any time windows are dragged around, we'll do a full repaint
|
|
|
|
* of the window group, which includes the background actor, meaning
|
|
|
|
* a full-stage repaint.
|
|
|
|
*
|
|
|
|
* Since actors are allowed to paint outside their allocation, and
|
|
|
|
* since child actors are allowed to be outside their parents, this
|
|
|
|
* doesn't affect anything, but it means that we'll get much more
|
|
|
|
* sane and consistent clipped repaints from Clutter. */
|
|
|
|
static void
|
|
|
|
meta_window_group_get_preferred_width (ClutterActor *actor,
|
|
|
|
gfloat for_height,
|
|
|
|
gfloat *min_width,
|
|
|
|
gfloat *nat_width)
|
|
|
|
{
|
|
|
|
*min_width = 0;
|
|
|
|
*nat_width = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_group_get_preferred_height (ClutterActor *actor,
|
|
|
|
gfloat for_width,
|
|
|
|
gfloat *min_height,
|
|
|
|
gfloat *nat_height)
|
|
|
|
{
|
|
|
|
*min_height = 0;
|
|
|
|
*nat_height = 0;
|
|
|
|
}
|
|
|
|
|
2009-06-29 14:30:26 -04:00
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_group_class_init (MetaWindowGroupClass *klass)
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
|
|
|
|
2015-07-05 22:19:33 -04:00
|
|
|
actor_class->paint = meta_window_group_paint;
|
2013-03-02 07:04:20 -05:00
|
|
|
actor_class->get_paint_volume = meta_window_group_get_paint_volume;
|
2015-07-05 22:18:22 -04:00
|
|
|
actor_class->get_preferred_width = meta_window_group_get_preferred_width;
|
|
|
|
actor_class->get_preferred_height = meta_window_group_get_preferred_height;
|
2009-06-29 14:30:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_group_init (MetaWindowGroup *window_group)
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterActor *
|
2010-10-18 13:27:14 -04:00
|
|
|
meta_window_group_new (MetaScreen *screen)
|
2009-06-29 14:30:26 -04:00
|
|
|
{
|
2010-10-18 13:27:14 -04:00
|
|
|
MetaWindowGroup *window_group;
|
2009-06-29 14:30:26 -04:00
|
|
|
|
2010-10-18 13:27:14 -04:00
|
|
|
window_group = g_object_new (META_TYPE_WINDOW_GROUP, NULL);
|
2009-06-29 14:30:26 -04:00
|
|
|
|
|
|
|
window_group->screen = screen;
|
|
|
|
|
|
|
|
return CLUTTER_ACTOR (window_group);
|
|
|
|
}
|