2014-04-21 18:05:59 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Red Hat
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
* Jasper St. Pierre <jstpierre@mecheye.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-cursor-renderer.h"
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2016-04-19 05:33:14 -04:00
|
|
|
#include <math.h>
|
2014-08-13 19:46:32 -04:00
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "backends/meta-stage-private.h"
|
|
|
|
#include "clutter/clutter.h"
|
2019-05-06 09:25:16 -04:00
|
|
|
#include "clutter/clutter-mutter.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "cogl/cogl.h"
|
|
|
|
#include "meta/meta-backend.h"
|
|
|
|
#include "meta/util.h"
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2018-09-13 05:28:51 -04:00
|
|
|
G_DEFINE_INTERFACE (MetaHwCursorInhibitor, meta_hw_cursor_inhibitor,
|
|
|
|
G_TYPE_OBJECT)
|
|
|
|
|
2020-05-27 03:29:04 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_BACKEND,
|
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[N_PROPS];
|
|
|
|
|
2014-04-21 18:05:59 -04:00
|
|
|
struct _MetaCursorRendererPrivate
|
|
|
|
{
|
2020-05-27 03:29:04 -04:00
|
|
|
MetaBackend *backend;
|
|
|
|
|
2017-06-08 10:13:16 -04:00
|
|
|
float current_x;
|
|
|
|
float current_y;
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2015-03-09 23:23:00 -04:00
|
|
|
MetaCursorSprite *displayed_cursor;
|
2016-05-02 07:49:13 -04:00
|
|
|
MetaOverlay *stage_overlay;
|
2014-05-17 11:22:05 -04:00
|
|
|
gboolean handled_by_backend;
|
2016-01-10 11:28:54 -05:00
|
|
|
guint post_paint_func_id;
|
2018-09-13 05:28:51 -04:00
|
|
|
|
|
|
|
GList *hw_cursor_inhibitors;
|
2014-04-21 18:05:59 -04:00
|
|
|
};
|
|
|
|
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
|
|
|
|
|
2018-12-19 03:04:25 -05:00
|
|
|
enum
|
|
|
|
{
|
2016-01-10 11:28:54 -05:00
|
|
|
CURSOR_PAINTED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
2014-04-21 18:05:59 -04:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorRenderer, meta_cursor_renderer, G_TYPE_OBJECT);
|
|
|
|
|
2018-09-13 05:28:51 -04:00
|
|
|
static gboolean
|
|
|
|
meta_hw_cursor_inhibitor_is_cursor_sprite_inhibited (MetaHwCursorInhibitor *inhibitor,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
|
|
|
{
|
|
|
|
MetaHwCursorInhibitorInterface *iface =
|
|
|
|
META_HW_CURSOR_INHIBITOR_GET_IFACE (inhibitor);
|
|
|
|
|
|
|
|
return iface->is_cursor_sprite_inhibited (inhibitor, cursor_sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_hw_cursor_inhibitor_default_init (MetaHwCursorInhibitorInterface *iface)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-10 11:28:54 -05:00
|
|
|
void
|
|
|
|
meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
|
|
|
{
|
|
|
|
g_signal_emit (renderer, signals[CURSOR_PAINTED], 0, cursor_sprite);
|
|
|
|
}
|
|
|
|
|
2019-05-06 09:25:16 -04:00
|
|
|
static void
|
|
|
|
align_cursor_position (MetaCursorRenderer *renderer,
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t *rect)
|
2019-05-06 09:25:16 -04:00
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
2020-05-27 03:29:04 -04:00
|
|
|
ClutterActor *stage = meta_backend_get_stage (priv->backend);
|
2019-05-06 09:25:16 -04:00
|
|
|
ClutterStageView *view;
|
|
|
|
cairo_rectangle_int_t view_layout;
|
|
|
|
float view_scale;
|
|
|
|
|
|
|
|
view = clutter_stage_get_view_at (CLUTTER_STAGE (stage),
|
|
|
|
priv->current_x,
|
|
|
|
priv->current_y);
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clutter_stage_view_get_layout (view, &view_layout);
|
|
|
|
view_scale = clutter_stage_view_get_scale (view);
|
|
|
|
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_offset (rect, -view_layout.x, -view_layout.y);
|
2019-05-06 09:25:16 -04:00
|
|
|
rect->origin.x = floorf (rect->origin.x * view_scale) / view_scale;
|
|
|
|
rect->origin.y = floorf (rect->origin.y * view_scale) / view_scale;
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_offset (rect, view_layout.x, view_layout.y);
|
2019-05-06 09:25:16 -04:00
|
|
|
}
|
|
|
|
|
2014-04-21 18:05:59 -04:00
|
|
|
static void
|
2015-07-17 11:16:39 -04:00
|
|
|
queue_redraw (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
2020-05-27 03:29:04 -04:00
|
|
|
ClutterActor *stage = meta_backend_get_stage (priv->backend);
|
2014-08-21 15:00:03 -04:00
|
|
|
CoglTexture *texture;
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t rect = GRAPHENE_RECT_INIT_ZERO;
|
2015-07-17 11:16:39 -04:00
|
|
|
|
2014-04-22 14:43:46 -04:00
|
|
|
/* During early initialization, we can have no stage */
|
|
|
|
if (!stage)
|
|
|
|
return;
|
|
|
|
|
2019-05-06 09:25:16 -04:00
|
|
|
if (cursor_sprite)
|
|
|
|
{
|
|
|
|
rect = meta_cursor_renderer_calculate_rect (renderer, cursor_sprite);
|
|
|
|
align_cursor_position (renderer, &rect);
|
|
|
|
}
|
|
|
|
|
2016-05-02 07:49:13 -04:00
|
|
|
if (!priv->stage_overlay)
|
|
|
|
priv->stage_overlay = meta_stage_create_cursor_overlay (META_STAGE (stage));
|
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
if (cursor_sprite && !priv->handled_by_backend)
|
|
|
|
texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
2014-05-17 11:22:05 -04:00
|
|
|
else
|
2014-08-21 15:00:03 -04:00
|
|
|
texture = NULL;
|
|
|
|
|
2016-05-02 07:49:13 -04:00
|
|
|
meta_stage_update_cursor_overlay (META_STAGE (stage), priv->stage_overlay,
|
|
|
|
texture, &rect);
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
|
|
|
|
2016-01-10 11:28:54 -05:00
|
|
|
static gboolean
|
|
|
|
meta_cursor_renderer_post_paint (gpointer data)
|
|
|
|
{
|
|
|
|
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (data);
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
if (priv->displayed_cursor && !priv->handled_by_backend)
|
|
|
|
meta_cursor_renderer_emit_painted (renderer, priv->displayed_cursor);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-17 11:22:05 -04:00
|
|
|
static gboolean
|
2015-07-17 11:16:39 -04:00
|
|
|
meta_cursor_renderer_real_update_cursor (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
2014-04-22 15:39:09 -04:00
|
|
|
{
|
2015-10-22 08:43:46 -04:00
|
|
|
if (cursor_sprite)
|
|
|
|
meta_cursor_sprite_realize_texture (cursor_sprite);
|
|
|
|
|
2014-05-17 11:22:05 -04:00
|
|
|
return FALSE;
|
2014-04-22 15:15:11 -04:00
|
|
|
}
|
2014-04-22 15:39:09 -04:00
|
|
|
|
2020-05-27 03:29:04 -04:00
|
|
|
static void
|
|
|
|
meta_cursor_renderer_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_BACKEND:
|
|
|
|
g_value_set_object (value, priv->backend);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_cursor_renderer_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_BACKEND:
|
|
|
|
priv->backend = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-02 07:49:13 -04:00
|
|
|
static void
|
|
|
|
meta_cursor_renderer_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (object);
|
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
2020-05-27 03:29:04 -04:00
|
|
|
ClutterActor *stage = meta_backend_get_stage (priv->backend);
|
2016-05-02 07:49:13 -04:00
|
|
|
|
|
|
|
if (priv->stage_overlay)
|
|
|
|
meta_stage_remove_cursor_overlay (META_STAGE (stage), priv->stage_overlay);
|
|
|
|
|
2016-01-10 11:28:54 -05:00
|
|
|
clutter_threads_remove_repaint_func (priv->post_paint_func_id);
|
|
|
|
|
2016-05-02 07:49:13 -04:00
|
|
|
G_OBJECT_CLASS (meta_cursor_renderer_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2014-04-22 15:15:11 -04:00
|
|
|
static void
|
|
|
|
meta_cursor_renderer_class_init (MetaCursorRendererClass *klass)
|
|
|
|
{
|
2016-05-02 07:49:13 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2020-05-27 03:29:04 -04:00
|
|
|
object_class->get_property = meta_cursor_renderer_get_property;
|
|
|
|
object_class->set_property = meta_cursor_renderer_set_property;
|
2016-05-02 07:49:13 -04:00
|
|
|
object_class->finalize = meta_cursor_renderer_finalize;
|
2014-04-22 15:15:11 -04:00
|
|
|
klass->update_cursor = meta_cursor_renderer_real_update_cursor;
|
2016-01-10 11:28:54 -05:00
|
|
|
|
2020-05-27 03:29:04 -04:00
|
|
|
obj_props[PROP_BACKEND] =
|
|
|
|
g_param_spec_object ("backend",
|
|
|
|
"backend",
|
|
|
|
"MetaBackend",
|
|
|
|
META_TYPE_BACKEND,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
|
|
|
|
2016-01-10 11:28:54 -05:00
|
|
|
signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_POINTER);
|
2014-04-22 15:15:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_cursor_renderer_init (MetaCursorRenderer *renderer)
|
|
|
|
{
|
2016-01-10 11:28:54 -05:00
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
priv->post_paint_func_id =
|
|
|
|
clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
|
|
|
|
meta_cursor_renderer_post_paint,
|
|
|
|
renderer,
|
|
|
|
NULL);
|
2014-04-22 15:39:09 -04:00
|
|
|
}
|
|
|
|
|
2019-02-20 10:23:04 -05:00
|
|
|
graphene_rect_t
|
2015-07-17 11:16:39 -04:00
|
|
|
meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
CoglTexture *texture;
|
|
|
|
int hot_x, hot_y;
|
|
|
|
int width, height;
|
|
|
|
float texture_scale;
|
|
|
|
|
|
|
|
texture = meta_cursor_sprite_get_cogl_texture (cursor_sprite);
|
|
|
|
if (!texture)
|
2019-02-20 10:23:04 -05:00
|
|
|
return (graphene_rect_t) GRAPHENE_RECT_INIT_ZERO;
|
2015-07-17 11:16:39 -04:00
|
|
|
|
|
|
|
meta_cursor_sprite_get_hotspot (cursor_sprite, &hot_x, &hot_y);
|
|
|
|
texture_scale = meta_cursor_sprite_get_texture_scale (cursor_sprite);
|
|
|
|
width = cogl_texture_get_width (texture);
|
|
|
|
height = cogl_texture_get_height (texture);
|
|
|
|
|
2019-02-20 10:23:04 -05:00
|
|
|
return (graphene_rect_t) {
|
2017-06-08 10:13:16 -04:00
|
|
|
.origin = {
|
|
|
|
.x = priv->current_x - (hot_x * texture_scale),
|
|
|
|
.y = priv->current_y - (hot_y * texture_scale)
|
|
|
|
},
|
|
|
|
.size = {
|
|
|
|
.width = width * texture_scale,
|
|
|
|
.height = height * texture_scale
|
|
|
|
}
|
2015-07-17 11:16:39 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-04-21 18:05:59 -04:00
|
|
|
static void
|
2018-05-09 11:59:32 -04:00
|
|
|
meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
2014-05-17 11:22:05 -04:00
|
|
|
gboolean handled_by_backend;
|
|
|
|
gboolean should_redraw = FALSE;
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
if (cursor_sprite)
|
|
|
|
meta_cursor_sprite_prepare_at (cursor_sprite,
|
2017-06-08 10:13:16 -04:00
|
|
|
(int) priv->current_x,
|
|
|
|
(int) priv->current_y);
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
handled_by_backend =
|
|
|
|
META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer,
|
|
|
|
cursor_sprite);
|
2014-05-17 11:22:05 -04:00
|
|
|
if (handled_by_backend != priv->handled_by_backend)
|
|
|
|
{
|
|
|
|
priv->handled_by_backend = handled_by_backend;
|
|
|
|
should_redraw = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handled_by_backend)
|
|
|
|
should_redraw = TRUE;
|
|
|
|
|
|
|
|
if (should_redraw)
|
2015-07-17 11:16:39 -04:00
|
|
|
queue_redraw (renderer, cursor_sprite);
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaCursorRenderer *
|
2020-05-27 03:29:04 -04:00
|
|
|
meta_cursor_renderer_new (MetaBackend *backend)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
2020-05-27 03:29:04 -04:00
|
|
|
return g_object_new (META_TYPE_CURSOR_RENDERER,
|
|
|
|
"backend", backend,
|
|
|
|
NULL);
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-03-09 23:23:00 -04:00
|
|
|
meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
2015-03-09 23:23:00 -04:00
|
|
|
if (priv->displayed_cursor == cursor_sprite)
|
2014-04-21 18:05:59 -04:00
|
|
|
return;
|
2015-03-09 23:23:00 -04:00
|
|
|
priv->displayed_cursor = cursor_sprite;
|
2015-07-17 11:16:39 -04:00
|
|
|
|
2018-05-09 11:59:32 -04:00
|
|
|
meta_cursor_renderer_update_cursor (renderer, cursor_sprite);
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
|
|
|
|
2015-07-13 14:36:05 -04:00
|
|
|
void
|
|
|
|
meta_cursor_renderer_force_update (MetaCursorRenderer *renderer)
|
|
|
|
{
|
2015-07-17 11:16:39 -04:00
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
2018-05-09 11:59:32 -04:00
|
|
|
meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
|
2015-07-13 14:36:05 -04:00
|
|
|
}
|
|
|
|
|
2014-04-21 18:05:59 -04:00
|
|
|
void
|
|
|
|
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
2017-06-08 10:13:16 -04:00
|
|
|
float x,
|
|
|
|
float y)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
g_assert (meta_is_wayland_compositor ());
|
|
|
|
|
|
|
|
priv->current_x = x;
|
|
|
|
priv->current_y = y;
|
|
|
|
|
2018-05-09 11:59:32 -04:00
|
|
|
meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
graphene_point_t
|
2018-03-23 08:05:12 -04:00
|
|
|
meta_cursor_renderer_get_position (MetaCursorRenderer *renderer)
|
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
2019-02-20 09:53:44 -05:00
|
|
|
return (graphene_point_t) {
|
2018-03-23 08:05:12 -04:00
|
|
|
.x = priv->current_x,
|
|
|
|
.y = priv->current_y
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-09 23:23:00 -04:00
|
|
|
MetaCursorSprite *
|
2014-04-22 15:15:11 -04:00
|
|
|
meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
|
2014-04-21 18:05:59 -04:00
|
|
|
{
|
2014-04-22 15:15:11 -04:00
|
|
|
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
2014-04-21 18:05:59 -04:00
|
|
|
|
2014-04-22 15:15:11 -04:00
|
|
|
return priv->displayed_cursor;
|
2014-04-21 18:05:59 -04:00
|
|
|
}
|
2018-09-13 05:28:51 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_cursor_renderer_add_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
|
|
|
MetaHwCursorInhibitor *inhibitor)
|
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
priv->hw_cursor_inhibitors = g_list_prepend (priv->hw_cursor_inhibitors,
|
|
|
|
inhibitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_cursor_renderer_remove_hw_cursor_inhibitor (MetaCursorRenderer *renderer,
|
|
|
|
MetaHwCursorInhibitor *inhibitor)
|
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
|
|
|
|
priv->hw_cursor_inhibitors = g_list_remove (priv->hw_cursor_inhibitors,
|
|
|
|
inhibitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer,
|
|
|
|
MetaCursorSprite *cursor_sprite)
|
|
|
|
{
|
|
|
|
MetaCursorRendererPrivate *priv =
|
|
|
|
meta_cursor_renderer_get_instance_private (renderer);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = priv->hw_cursor_inhibitors; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaHwCursorInhibitor *inhibitor = l->data;
|
|
|
|
|
|
|
|
if (meta_hw_cursor_inhibitor_is_cursor_sprite_inhibited (inhibitor,
|
|
|
|
cursor_sprite))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|