2014-03-31 14:08:14 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2013 Red Hat, 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Giovanni Campagna <gcampagn@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2015-03-10 02:41:12 -04:00
|
|
|
#include "meta-cursor.h"
|
2014-03-31 14:08:14 -04:00
|
|
|
|
2014-03-31 15:21:19 -04:00
|
|
|
#include <meta/errors.h>
|
|
|
|
|
|
|
|
#include "display-private.h"
|
|
|
|
#include "screen-private.h"
|
2014-08-05 08:11:59 -04:00
|
|
|
#include "meta-backend-private.h"
|
2014-05-29 12:11:26 -04:00
|
|
|
|
2014-03-31 15:21:19 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <X11/cursorfont.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
enum {
|
|
|
|
PREPARE_AT,
|
2017-11-16 13:16:54 -05:00
|
|
|
TEXTURE_CHANGED,
|
2015-07-17 11:16:39 -04:00
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
2014-03-31 15:21:19 -04:00
|
|
|
|
2015-03-10 02:41:12 -04:00
|
|
|
struct _MetaCursorSprite
|
|
|
|
{
|
|
|
|
GObject parent;
|
|
|
|
|
|
|
|
MetaCursor cursor;
|
2015-07-16 23:56:42 -04:00
|
|
|
|
|
|
|
CoglTexture2D *texture;
|
2015-07-17 11:16:39 -04:00
|
|
|
float texture_scale;
|
2015-07-16 23:56:42 -04:00
|
|
|
int hot_x, hot_y;
|
2015-03-10 02:41:12 -04:00
|
|
|
|
|
|
|
int current_frame;
|
|
|
|
XcursorImages *xcursor_images;
|
2015-07-17 11:16:39 -04:00
|
|
|
|
|
|
|
int theme_scale;
|
|
|
|
gboolean theme_dirty;
|
2015-03-10 02:41:12 -04:00
|
|
|
};
|
|
|
|
|
2015-03-10 02:35:49 -04:00
|
|
|
G_DEFINE_TYPE (MetaCursorSprite, meta_cursor_sprite, G_TYPE_OBJECT)
|
2014-03-31 14:08:14 -04:00
|
|
|
|
2014-04-22 11:53:31 -04:00
|
|
|
static const char *
|
|
|
|
translate_meta_cursor (MetaCursor cursor)
|
2014-03-31 15:21:19 -04:00
|
|
|
{
|
|
|
|
switch (cursor)
|
|
|
|
{
|
|
|
|
case META_CURSOR_DEFAULT:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "left_ptr";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_NORTH_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "top_side";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_SOUTH_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "bottom_side";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_WEST_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "left_side";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_EAST_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "right_side";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_SE_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "bottom_right_corner";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_SW_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "bottom_left_corner";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_NE_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "top_right_corner";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_NW_RESIZE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "top_left_corner";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "fleur";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_BUSY:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "watch";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_DND_IN_DRAG:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "dnd-none";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_DND_MOVE:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "dnd-move";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_DND_COPY:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "dnd-copy";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_DND_UNSUPPORTED_TARGET:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "dnd-none";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_POINTING_HAND:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "hand2";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_CROSSHAIR:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "crosshair";
|
2014-03-31 15:21:19 -04:00
|
|
|
case META_CURSOR_IBEAM:
|
2014-04-22 11:53:31 -04:00
|
|
|
return "xterm";
|
2014-03-31 15:21:19 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-04-22 11:53:31 -04:00
|
|
|
g_assert_not_reached ();
|
2014-03-31 15:21:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Cursor
|
2014-04-23 10:41:09 -04:00
|
|
|
meta_cursor_create_x_cursor (Display *xdisplay,
|
|
|
|
MetaCursor cursor)
|
2014-03-31 15:21:19 -04:00
|
|
|
{
|
2014-04-23 10:41:09 -04:00
|
|
|
return XcursorLibraryLoadCursor (xdisplay, translate_meta_cursor (cursor));
|
2014-03-31 15:21:19 -04:00
|
|
|
}
|
|
|
|
|
2015-07-13 14:32:42 -04:00
|
|
|
static XcursorImages *
|
2015-07-17 11:16:39 -04:00
|
|
|
load_cursor_on_client (MetaCursor cursor, int scale)
|
2014-03-31 15:21:19 -04:00
|
|
|
{
|
2015-07-13 14:32:42 -04:00
|
|
|
return XcursorLibraryLoadImages (translate_meta_cursor (cursor),
|
|
|
|
meta_prefs_get_cursor_theme (),
|
2015-07-17 11:16:39 -04:00
|
|
|
meta_prefs_get_cursor_size () * scale);
|
2014-03-31 15:21:19 -04:00
|
|
|
}
|
|
|
|
|
2014-03-31 17:50:15 -04:00
|
|
|
static void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *sprite,
|
2015-03-10 23:16:58 -04:00
|
|
|
XcursorImage *xc_image)
|
2014-04-22 15:23:45 -04:00
|
|
|
{
|
2018-04-23 10:46:44 -04:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
2014-09-24 17:40:09 -04:00
|
|
|
uint width, height, rowstride;
|
2014-03-31 15:21:19 -04:00
|
|
|
CoglPixelFormat cogl_format;
|
|
|
|
ClutterBackend *clutter_backend;
|
|
|
|
CoglContext *cogl_context;
|
2016-05-07 10:21:24 -04:00
|
|
|
CoglTexture2D *texture;
|
2016-04-14 09:30:31 -04:00
|
|
|
CoglError *error = NULL;
|
2014-03-31 15:21:19 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_assert (sprite->texture == NULL);
|
2015-07-16 23:56:42 -04:00
|
|
|
|
2014-03-31 17:13:03 -04:00
|
|
|
width = xc_image->width;
|
|
|
|
height = xc_image->height;
|
2014-03-31 15:21:19 -04:00
|
|
|
rowstride = width * 4;
|
|
|
|
|
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
cogl_format = COGL_PIXEL_FORMAT_BGRA_8888;
|
|
|
|
#else
|
|
|
|
cogl_format = COGL_PIXEL_FORMAT_ARGB_8888;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
clutter_backend = clutter_get_default_backend ();
|
|
|
|
cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
2015-07-17 11:16:39 -04:00
|
|
|
texture = cogl_texture_2d_new_from_data (cogl_context,
|
|
|
|
width, height,
|
|
|
|
cogl_format,
|
|
|
|
rowstride,
|
|
|
|
(uint8_t *) xc_image->pixels,
|
2016-04-14 09:30:31 -04:00
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
meta_warning ("Failed to allocate cursor texture: %s\n", error->message);
|
|
|
|
cogl_error_free (error);
|
|
|
|
}
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_set_texture (sprite, COGL_TEXTURE (texture),
|
2015-07-17 11:16:39 -04:00
|
|
|
xc_image->xhot, xc_image->yhot);
|
2016-04-14 10:21:35 -04:00
|
|
|
|
|
|
|
if (texture)
|
|
|
|
cogl_object_unref (texture);
|
2014-03-31 15:21:19 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, sprite, xc_image);
|
2014-03-31 16:09:32 -04:00
|
|
|
}
|
|
|
|
|
2015-07-13 14:32:42 -04:00
|
|
|
static XcursorImage *
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *sprite)
|
2015-07-13 14:32:42 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
return sprite->xcursor_images->images[sprite->current_frame];
|
2015-07-13 14:32:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite)
|
2015-07-13 14:32:42 -04:00
|
|
|
{
|
|
|
|
XcursorImage *image;
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
if (!meta_cursor_sprite_is_animated (sprite))
|
2015-07-13 14:32:42 -04:00
|
|
|
return;
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->current_frame++;
|
2015-07-13 14:32:42 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->current_frame >= sprite->xcursor_images->nimage)
|
|
|
|
sprite->current_frame = 0;
|
2015-07-13 14:32:42 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
image = meta_cursor_sprite_get_current_frame_image (sprite);
|
2015-07-16 23:56:42 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
|
|
|
meta_cursor_sprite_load_from_xcursor_image (sprite, image);
|
2015-07-13 14:32:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite)
|
2015-07-13 14:32:42 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
if (!meta_cursor_sprite_is_animated (sprite))
|
2015-07-13 14:32:42 -04:00
|
|
|
return 0;
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
return sprite->xcursor_images->images[sprite->current_frame]->delay;
|
2015-07-13 14:32:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
|
2015-07-13 14:32:42 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
return (sprite->xcursor_images &&
|
|
|
|
sprite->xcursor_images->nimage > 1);
|
2015-07-13 14:32:42 -04:00
|
|
|
}
|
|
|
|
|
2015-03-09 23:23:00 -04:00
|
|
|
MetaCursorSprite *
|
2015-07-17 11:16:39 -04:00
|
|
|
meta_cursor_sprite_new (void)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_CURSOR_SPRITE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_load_from_theme (MetaCursorSprite *sprite)
|
2014-11-27 17:34:25 -05:00
|
|
|
{
|
2015-03-10 23:16:58 -04:00
|
|
|
XcursorImage *image;
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_assert (sprite->cursor != META_CURSOR_NONE);
|
2015-07-17 11:16:39 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->theme_dirty = FALSE;
|
2017-11-17 08:07:20 -05:00
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
/* We might be reloading with a different scale. If so clear the old data. */
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->xcursor_images)
|
2015-07-17 11:16:39 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
|
|
|
XcursorImagesDestroy (sprite->xcursor_images);
|
2015-07-17 11:16:39 -04:00
|
|
|
}
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->current_frame = 0;
|
|
|
|
sprite->xcursor_images = load_cursor_on_client (sprite->cursor,
|
|
|
|
sprite->theme_scale);
|
|
|
|
if (!sprite->xcursor_images)
|
2015-03-10 23:16:58 -04:00
|
|
|
meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
image = meta_cursor_sprite_get_current_frame_image (sprite);
|
|
|
|
meta_cursor_sprite_load_from_xcursor_image (sprite, image);
|
2015-03-10 02:35:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaCursorSprite *
|
2015-07-17 11:16:39 -04:00
|
|
|
meta_cursor_sprite_from_theme (MetaCursor cursor)
|
2015-03-10 02:35:49 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
MetaCursorSprite *sprite;
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite = meta_cursor_sprite_new ();
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->cursor = cursor;
|
|
|
|
sprite->theme_dirty = TRUE;
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
return sprite;
|
2014-03-31 15:21:19 -04:00
|
|
|
}
|
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
|
2015-07-17 11:16:39 -04:00
|
|
|
CoglTexture *texture,
|
|
|
|
int hot_x,
|
|
|
|
int hot_y)
|
2014-03-31 15:21:19 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->texture == COGL_TEXTURE_2D (texture) &&
|
|
|
|
sprite->hot_x == hot_x &&
|
|
|
|
sprite->hot_y == hot_y)
|
2017-11-16 13:16:54 -05:00
|
|
|
return;
|
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
2015-07-17 11:16:39 -04:00
|
|
|
if (texture)
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->texture = cogl_object_ref (texture);
|
|
|
|
sprite->hot_x = hot_x;
|
|
|
|
sprite->hot_y = hot_y;
|
2017-11-16 13:16:54 -05:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0);
|
2014-03-31 17:13:03 -04:00
|
|
|
}
|
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
|
2015-07-17 11:16:39 -04:00
|
|
|
float scale)
|
2014-03-31 17:13:03 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->texture_scale = scale;
|
2015-07-17 11:16:39 -04:00
|
|
|
}
|
2014-03-31 15:21:19 -04:00
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_set_theme_scale (MetaCursorSprite *sprite,
|
2015-07-17 11:16:39 -04:00
|
|
|
int theme_scale)
|
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->theme_scale != theme_scale)
|
|
|
|
sprite->theme_dirty = TRUE;
|
|
|
|
sprite->theme_scale = theme_scale;
|
2014-03-31 15:21:19 -04:00
|
|
|
}
|
2014-03-31 15:31:15 -04:00
|
|
|
|
|
|
|
CoglTexture *
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite)
|
2014-03-31 15:31:15 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
return COGL_TEXTURE (sprite->texture);
|
2014-03-31 15:31:15 -04:00
|
|
|
}
|
|
|
|
|
2015-03-10 23:16:58 -04:00
|
|
|
MetaCursor
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *sprite)
|
2014-03-31 15:31:15 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
return sprite->cursor;
|
2015-03-10 23:16:58 -04:00
|
|
|
}
|
2014-11-27 17:34:25 -05:00
|
|
|
|
2015-03-10 23:16:58 -04:00
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
|
2015-03-10 23:16:58 -04:00
|
|
|
int *hot_x,
|
|
|
|
int *hot_y)
|
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
*hot_x = sprite->hot_x;
|
|
|
|
*hot_y = sprite->hot_y;
|
2014-03-31 15:31:15 -04:00
|
|
|
}
|
2014-04-23 11:04:08 -04:00
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
float
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite)
|
2014-04-23 11:04:08 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
return sprite->texture_scale;
|
2015-03-10 23:16:58 -04:00
|
|
|
}
|
|
|
|
|
2015-07-17 11:16:39 -04:00
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
|
2015-07-17 11:16:39 -04:00
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
g_signal_emit (sprite, signals[PREPARE_AT], 0, x, y);
|
2015-07-17 11:16:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite)
|
2015-03-10 23:16:58 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->theme_dirty)
|
|
|
|
meta_cursor_sprite_load_from_theme (sprite);
|
2014-04-23 11:04:08 -04:00
|
|
|
}
|
2015-03-10 02:35:49 -04:00
|
|
|
|
|
|
|
static void
|
2018-04-23 10:44:11 -04:00
|
|
|
meta_cursor_sprite_init (MetaCursorSprite *sprite)
|
2015-03-10 02:35:49 -04:00
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
sprite->texture_scale = 1.0f;
|
2015-03-10 02:35:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_cursor_sprite_finalize (GObject *object)
|
|
|
|
{
|
2018-04-23 10:44:11 -04:00
|
|
|
MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
|
2015-03-10 02:35:49 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
if (sprite->xcursor_images)
|
|
|
|
XcursorImagesDestroy (sprite->xcursor_images);
|
2015-07-16 23:56:42 -04:00
|
|
|
|
2018-04-23 10:44:11 -04:00
|
|
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
2015-03-10 02:35:49 -04:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_cursor_sprite_class_init (MetaCursorSpriteClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = meta_cursor_sprite_finalize;
|
2015-07-17 11:16:39 -04:00
|
|
|
|
|
|
|
signals[PREPARE_AT] = g_signal_new ("prepare-at",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT);
|
2017-11-16 13:16:54 -05:00
|
|
|
signals[TEXTURE_CHANGED] = g_signal_new ("texture-changed",
|
|
|
|
G_TYPE_FROM_CLASS (object_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
2015-03-10 02:35:49 -04:00
|
|
|
}
|