2010-11-14 17:37:17 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
/*
|
|
|
|
* Copyright 2009 Sander Dijkhuis
|
2014-08-10 15:26:14 +00:00
|
|
|
* Copyright 2014 Red Hat, Inc.
|
2010-11-14 17:37:17 +00:00
|
|
|
*
|
|
|
|
* 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
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-11-14 17:37:17 +00:00
|
|
|
*
|
|
|
|
* Portions adapted from gnome-shell/src/shell-global.c
|
|
|
|
*/
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "config.h"
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "compositor/meta-background-actor-private.h"
|
2020-06-09 01:02:34 +00:00
|
|
|
#include "compositor/meta-background-content-private.h"
|
2012-02-21 16:31:53 +00:00
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "compositor/meta-cullable.h"
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2014-08-10 15:26:14 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-08-26 19:43:17 +00:00
|
|
|
PROP_META_DISPLAY = 1,
|
2014-08-10 15:26:14 +00:00
|
|
|
PROP_MONITOR,
|
|
|
|
};
|
|
|
|
|
2018-10-31 10:47:17 +00:00
|
|
|
struct _MetaBackgroundActor
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
2018-10-31 10:47:17 +00:00
|
|
|
ClutterActor parent;
|
|
|
|
|
2017-08-26 19:43:17 +00:00
|
|
|
MetaDisplay *display;
|
2014-08-10 15:26:14 +00:00
|
|
|
int monitor;
|
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
MetaBackgroundContent *content;
|
2010-11-14 17:37:17 +00:00
|
|
|
};
|
|
|
|
|
2013-11-21 20:25:08 +00:00
|
|
|
static void cullable_iface_init (MetaCullableInterface *iface);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (MetaBackgroundActor, meta_background_actor, CLUTTER_TYPE_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (META_TYPE_CULLABLE, cullable_iface_init));
|
|
|
|
|
|
|
|
static void
|
2020-06-09 01:02:34 +00:00
|
|
|
maybe_create_content (MetaBackgroundActor *self)
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
2020-06-09 01:02:34 +00:00
|
|
|
g_autoptr (ClutterContent) content = NULL;
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
if (self->content || !self->display || self->monitor == -1)
|
2019-01-27 14:49:41 +00:00
|
|
|
return;
|
2019-10-21 16:57:10 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
content = meta_background_content_new (self->display, self->monitor);
|
|
|
|
self->content = META_BACKGROUND_CONTENT (content);
|
|
|
|
clutter_actor_set_content (CLUTTER_ACTOR (self), content);
|
2014-08-10 15:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_background_actor_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2017-08-26 19:43:17 +00:00
|
|
|
case PROP_META_DISPLAY:
|
2018-10-31 10:47:17 +00:00
|
|
|
self->display = g_value_get_object (value);
|
2020-06-09 01:02:34 +00:00
|
|
|
maybe_create_content (self);
|
2014-08-10 15:26:14 +00:00
|
|
|
break;
|
|
|
|
case PROP_MONITOR:
|
2020-06-09 01:02:34 +00:00
|
|
|
self->monitor = g_value_get_int (value);
|
|
|
|
maybe_create_content (self);
|
2014-09-03 01:51:10 +00:00
|
|
|
break;
|
2014-08-10 15:26:14 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_background_actor_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2018-10-31 10:47:17 +00:00
|
|
|
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (object);
|
2014-08-10 15:26:14 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2017-08-26 19:43:17 +00:00
|
|
|
case PROP_META_DISPLAY:
|
2018-10-31 10:47:17 +00:00
|
|
|
g_value_set_object (value, self->display);
|
2014-08-10 15:26:14 +00:00
|
|
|
break;
|
|
|
|
case PROP_MONITOR:
|
2018-10-31 10:47:17 +00:00
|
|
|
g_value_set_int (value, self->monitor);
|
2014-08-10 15:26:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-14 17:37:17 +00:00
|
|
|
static void
|
|
|
|
meta_background_actor_class_init (MetaBackgroundActorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2014-08-10 15:26:14 +00:00
|
|
|
GParamSpec *param_spec;
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2014-08-10 15:26:14 +00:00
|
|
|
object_class->set_property = meta_background_actor_set_property;
|
|
|
|
object_class->get_property = meta_background_actor_get_property;
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2023-06-28 12:02:43 +00:00
|
|
|
param_spec = g_param_spec_object ("meta-display", NULL, NULL,
|
2017-08-26 19:43:17 +00:00
|
|
|
META_TYPE_DISPLAY,
|
2014-08-10 15:26:14 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2017-08-26 19:43:17 +00:00
|
|
|
PROP_META_DISPLAY,
|
2014-08-10 15:26:14 +00:00
|
|
|
param_spec);
|
|
|
|
|
2023-06-28 12:02:43 +00:00
|
|
|
param_spec = g_param_spec_int ("monitor", NULL, NULL,
|
2014-08-10 15:26:14 +00:00
|
|
|
0, G_MAXINT, 0,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_MONITOR,
|
|
|
|
param_spec);
|
2010-11-14 17:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-08-26 18:01:00 +00:00
|
|
|
meta_background_actor_init (MetaBackgroundActor *self)
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
2020-06-09 01:02:34 +00:00
|
|
|
self->monitor = -1;
|
2017-08-20 11:34:54 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
clutter_actor_set_request_mode (CLUTTER_ACTOR (self),
|
|
|
|
CLUTTER_REQUEST_CONTENT_SIZE);
|
2010-11-14 17:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* meta_background_actor_new:
|
2014-08-10 15:26:14 +00:00
|
|
|
* @monitor: Index of the monitor for which to draw the background
|
2010-11-14 17:37:17 +00:00
|
|
|
*
|
2013-01-23 20:54:41 +00:00
|
|
|
* Creates a new actor to draw the background for the given monitor.
|
2010-11-14 17:37:17 +00:00
|
|
|
*
|
2011-08-29 01:20:29 +00:00
|
|
|
* Return value: the newly created background actor
|
2010-11-14 17:37:17 +00:00
|
|
|
*/
|
|
|
|
ClutterActor *
|
2017-08-26 19:43:17 +00:00
|
|
|
meta_background_actor_new (MetaDisplay *display,
|
|
|
|
int monitor)
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
|
|
|
MetaBackgroundActor *self;
|
|
|
|
|
2014-08-10 15:26:14 +00:00
|
|
|
self = g_object_new (META_TYPE_BACKGROUND_ACTOR,
|
2017-08-26 19:43:17 +00:00
|
|
|
"meta-display", display,
|
2014-08-10 15:26:14 +00:00
|
|
|
"monitor", monitor,
|
|
|
|
NULL);
|
2010-11-14 17:37:17 +00:00
|
|
|
|
|
|
|
return CLUTTER_ACTOR (self);
|
|
|
|
}
|
|
|
|
|
2013-11-21 20:25:08 +00:00
|
|
|
static void
|
|
|
|
meta_background_actor_cull_out (MetaCullable *cullable,
|
|
|
|
cairo_region_t *unobscured_region,
|
|
|
|
cairo_region_t *clip_region)
|
2010-11-14 17:37:17 +00:00
|
|
|
{
|
2013-11-21 20:25:08 +00:00
|
|
|
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (cullable);
|
2019-01-27 14:49:41 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
if (!self->content)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_background_content_cull_out (self->content,
|
|
|
|
unobscured_region,
|
|
|
|
clip_region);
|
2013-11-21 20:25:08 +00:00
|
|
|
}
|
2011-08-29 01:20:29 +00:00
|
|
|
|
2013-11-21 20:25:08 +00:00
|
|
|
static void
|
|
|
|
meta_background_actor_reset_culling (MetaCullable *cullable)
|
|
|
|
{
|
|
|
|
MetaBackgroundActor *self = META_BACKGROUND_ACTOR (cullable);
|
2019-01-27 14:49:41 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
if (!self->content)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_background_content_reset_culling (self->content);
|
2013-11-21 20:25:08 +00:00
|
|
|
}
|
2010-11-14 17:37:17 +00:00
|
|
|
|
2013-11-21 20:25:08 +00:00
|
|
|
static void
|
|
|
|
cullable_iface_init (MetaCullableInterface *iface)
|
|
|
|
{
|
|
|
|
iface->cull_out = meta_background_actor_cull_out;
|
|
|
|
iface->reset_culling = meta_background_actor_reset_culling;
|
2010-11-15 21:19:28 +00:00
|
|
|
}
|
2012-08-29 23:45:17 +00:00
|
|
|
|
|
|
|
/**
|
2013-08-27 14:30:39 +00:00
|
|
|
* meta_background_actor_get_clip_region:
|
2013-01-23 20:54:41 +00:00
|
|
|
* @self: a #MetaBackgroundActor
|
2012-08-29 23:45:17 +00:00
|
|
|
*
|
2014-08-07 18:58:18 +00:00
|
|
|
* Return value (transfer none): a #cairo_region_t that represents the part of
|
2013-01-23 20:54:41 +00:00
|
|
|
* the background not obscured by other #MetaBackgroundActor or
|
|
|
|
* #MetaWindowActor objects.
|
2012-08-29 23:45:17 +00:00
|
|
|
*/
|
2013-01-23 20:54:41 +00:00
|
|
|
cairo_region_t *
|
2013-08-27 14:30:39 +00:00
|
|
|
meta_background_actor_get_clip_region (MetaBackgroundActor *self)
|
2012-08-29 23:45:17 +00:00
|
|
|
{
|
2020-06-09 01:02:34 +00:00
|
|
|
if (!self->content)
|
|
|
|
return NULL;
|
2014-08-10 15:26:14 +00:00
|
|
|
|
2020-06-09 01:02:34 +00:00
|
|
|
return meta_background_content_get_clip_region (self->content);
|
2014-08-10 15:26:14 +00:00
|
|
|
}
|