backends/cursor: Change variable name from 'self' to 'sprite'
This makes it somewhat more descriptive. https://gitlab.gnome.org/GNOME/mutter/issues/77
This commit is contained in:
parent
50ff9d4c71
commit
65c02e26db
@ -127,7 +127,7 @@ load_cursor_on_client (MetaCursor cursor, int scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *self,
|
meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *sprite,
|
||||||
XcursorImage *xc_image)
|
XcursorImage *xc_image)
|
||||||
{
|
{
|
||||||
MetaBackend *meta_backend = meta_get_backend ();
|
MetaBackend *meta_backend = meta_get_backend ();
|
||||||
@ -139,7 +139,7 @@ meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *self,
|
|||||||
CoglTexture2D *texture;
|
CoglTexture2D *texture;
|
||||||
CoglError *error = NULL;
|
CoglError *error = NULL;
|
||||||
|
|
||||||
g_assert (self->texture == NULL);
|
g_assert (sprite->texture == NULL);
|
||||||
|
|
||||||
width = xc_image->width;
|
width = xc_image->width;
|
||||||
height = xc_image->height;
|
height = xc_image->height;
|
||||||
@ -166,54 +166,54 @@ meta_cursor_sprite_load_from_xcursor_image (MetaCursorSprite *self,
|
|||||||
cogl_error_free (error);
|
cogl_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_cursor_sprite_set_texture (self, COGL_TEXTURE (texture),
|
meta_cursor_sprite_set_texture (sprite, COGL_TEXTURE (texture),
|
||||||
xc_image->xhot, xc_image->yhot);
|
xc_image->xhot, xc_image->yhot);
|
||||||
|
|
||||||
if (texture)
|
if (texture)
|
||||||
cogl_object_unref (texture);
|
cogl_object_unref (texture);
|
||||||
|
|
||||||
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, self, xc_image);
|
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, sprite, xc_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
static XcursorImage *
|
static XcursorImage *
|
||||||
meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *self)
|
meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
return self->xcursor_images->images[self->current_frame];
|
return sprite->xcursor_images->images[sprite->current_frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_tick_frame (MetaCursorSprite *self)
|
meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
XcursorImage *image;
|
XcursorImage *image;
|
||||||
|
|
||||||
if (!meta_cursor_sprite_is_animated (self))
|
if (!meta_cursor_sprite_is_animated (sprite))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self->current_frame++;
|
sprite->current_frame++;
|
||||||
|
|
||||||
if (self->current_frame >= self->xcursor_images->nimage)
|
if (sprite->current_frame >= sprite->xcursor_images->nimage)
|
||||||
self->current_frame = 0;
|
sprite->current_frame = 0;
|
||||||
|
|
||||||
image = meta_cursor_sprite_get_current_frame_image (self);
|
image = meta_cursor_sprite_get_current_frame_image (sprite);
|
||||||
|
|
||||||
g_clear_pointer (&self->texture, cogl_object_unref);
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
||||||
meta_cursor_sprite_load_from_xcursor_image (self, image);
|
meta_cursor_sprite_load_from_xcursor_image (sprite, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self)
|
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
if (!meta_cursor_sprite_is_animated (self))
|
if (!meta_cursor_sprite_is_animated (sprite))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return self->xcursor_images->images[self->current_frame]->delay;
|
return sprite->xcursor_images->images[sprite->current_frame]->delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_cursor_sprite_is_animated (MetaCursorSprite *self)
|
meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
return (self->xcursor_images &&
|
return (sprite->xcursor_images &&
|
||||||
self->xcursor_images->nimage > 1);
|
sprite->xcursor_images->nimage > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorSprite *
|
MetaCursorSprite *
|
||||||
@ -223,137 +223,137 @@ meta_cursor_sprite_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_sprite_load_from_theme (MetaCursorSprite *self)
|
meta_cursor_sprite_load_from_theme (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
XcursorImage *image;
|
XcursorImage *image;
|
||||||
|
|
||||||
g_assert (self->cursor != META_CURSOR_NONE);
|
g_assert (sprite->cursor != META_CURSOR_NONE);
|
||||||
|
|
||||||
self->theme_dirty = FALSE;
|
sprite->theme_dirty = FALSE;
|
||||||
|
|
||||||
/* We might be reloading with a different scale. If so clear the old data. */
|
/* We might be reloading with a different scale. If so clear the old data. */
|
||||||
if (self->xcursor_images)
|
if (sprite->xcursor_images)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&self->texture, cogl_object_unref);
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
||||||
XcursorImagesDestroy (self->xcursor_images);
|
XcursorImagesDestroy (sprite->xcursor_images);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->current_frame = 0;
|
sprite->current_frame = 0;
|
||||||
self->xcursor_images = load_cursor_on_client (self->cursor,
|
sprite->xcursor_images = load_cursor_on_client (sprite->cursor,
|
||||||
self->theme_scale);
|
sprite->theme_scale);
|
||||||
if (!self->xcursor_images)
|
if (!sprite->xcursor_images)
|
||||||
meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
||||||
|
|
||||||
image = meta_cursor_sprite_get_current_frame_image (self);
|
image = meta_cursor_sprite_get_current_frame_image (sprite);
|
||||||
meta_cursor_sprite_load_from_xcursor_image (self, image);
|
meta_cursor_sprite_load_from_xcursor_image (sprite, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCursorSprite *
|
MetaCursorSprite *
|
||||||
meta_cursor_sprite_from_theme (MetaCursor cursor)
|
meta_cursor_sprite_from_theme (MetaCursor cursor)
|
||||||
{
|
{
|
||||||
MetaCursorSprite *self;
|
MetaCursorSprite *sprite;
|
||||||
|
|
||||||
self = meta_cursor_sprite_new ();
|
sprite = meta_cursor_sprite_new ();
|
||||||
|
|
||||||
self->cursor = cursor;
|
sprite->cursor = cursor;
|
||||||
self->theme_dirty = TRUE;
|
sprite->theme_dirty = TRUE;
|
||||||
|
|
||||||
return self;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_set_texture (MetaCursorSprite *self,
|
meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
|
||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
int hot_x,
|
int hot_x,
|
||||||
int hot_y)
|
int hot_y)
|
||||||
{
|
{
|
||||||
if (self->texture == COGL_TEXTURE_2D (texture) &&
|
if (sprite->texture == COGL_TEXTURE_2D (texture) &&
|
||||||
self->hot_x == hot_x &&
|
sprite->hot_x == hot_x &&
|
||||||
self->hot_y == hot_y)
|
sprite->hot_y == hot_y)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_clear_pointer (&self->texture, cogl_object_unref);
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
||||||
if (texture)
|
if (texture)
|
||||||
self->texture = cogl_object_ref (texture);
|
sprite->texture = cogl_object_ref (texture);
|
||||||
self->hot_x = hot_x;
|
sprite->hot_x = hot_x;
|
||||||
self->hot_y = hot_y;
|
sprite->hot_y = hot_y;
|
||||||
|
|
||||||
g_signal_emit (self, signals[TEXTURE_CHANGED], 0);
|
g_signal_emit (sprite, signals[TEXTURE_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
|
meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
|
||||||
float scale)
|
float scale)
|
||||||
{
|
{
|
||||||
self->texture_scale = scale;
|
sprite->texture_scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
|
meta_cursor_sprite_set_theme_scale (MetaCursorSprite *sprite,
|
||||||
int theme_scale)
|
int theme_scale)
|
||||||
{
|
{
|
||||||
if (self->theme_scale != theme_scale)
|
if (sprite->theme_scale != theme_scale)
|
||||||
self->theme_dirty = TRUE;
|
sprite->theme_dirty = TRUE;
|
||||||
self->theme_scale = theme_scale;
|
sprite->theme_scale = theme_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglTexture *
|
CoglTexture *
|
||||||
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self)
|
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
return COGL_TEXTURE (self->texture);
|
return COGL_TEXTURE (sprite->texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaCursor
|
MetaCursor
|
||||||
meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self)
|
meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
return self->cursor;
|
return sprite->cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
|
meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
|
||||||
int *hot_x,
|
int *hot_x,
|
||||||
int *hot_y)
|
int *hot_y)
|
||||||
{
|
{
|
||||||
*hot_x = self->hot_x;
|
*hot_x = sprite->hot_x;
|
||||||
*hot_y = self->hot_y;
|
*hot_y = sprite->hot_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self)
|
meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
return self->texture_scale;
|
return sprite->texture_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
|
meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
g_signal_emit (self, signals[PREPARE_AT], 0, x, y);
|
g_signal_emit (sprite, signals[PREPARE_AT], 0, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_sprite_realize_texture (MetaCursorSprite *self)
|
meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
if (self->theme_dirty)
|
if (sprite->theme_dirty)
|
||||||
meta_cursor_sprite_load_from_theme (self);
|
meta_cursor_sprite_load_from_theme (sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_sprite_init (MetaCursorSprite *self)
|
meta_cursor_sprite_init (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
self->texture_scale = 1.0f;
|
sprite->texture_scale = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_sprite_finalize (GObject *object)
|
meta_cursor_sprite_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
MetaCursorSprite *self = META_CURSOR_SPRITE (object);
|
MetaCursorSprite *sprite = META_CURSOR_SPRITE (object);
|
||||||
|
|
||||||
if (self->xcursor_images)
|
if (sprite->xcursor_images)
|
||||||
XcursorImagesDestroy (self->xcursor_images);
|
XcursorImagesDestroy (sprite->xcursor_images);
|
||||||
|
|
||||||
g_clear_pointer (&self->texture, cogl_object_unref);
|
g_clear_pointer (&sprite->texture, cogl_object_unref);
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
|
G_OBJECT_CLASS (meta_cursor_sprite_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -38,38 +38,41 @@ MetaCursorSprite * meta_cursor_sprite_new (void);
|
|||||||
MetaCursorSprite * meta_cursor_sprite_from_theme (MetaCursor cursor);
|
MetaCursorSprite * meta_cursor_sprite_from_theme (MetaCursor cursor);
|
||||||
|
|
||||||
|
|
||||||
void meta_cursor_sprite_set_theme_scale (MetaCursorSprite *self,
|
void meta_cursor_sprite_set_theme_scale (MetaCursorSprite *sprite,
|
||||||
int scale);
|
int scale);
|
||||||
|
|
||||||
MetaCursor meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self);
|
MetaCursor meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
Cursor meta_cursor_create_x_cursor (Display *xdisplay,
|
Cursor meta_cursor_create_x_cursor (Display *xdisplay,
|
||||||
MetaCursor cursor);
|
MetaCursor cursor);
|
||||||
|
|
||||||
void meta_cursor_sprite_prepare_at (MetaCursorSprite *self,
|
void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
void meta_cursor_sprite_realize_texture (MetaCursorSprite *self);
|
void meta_cursor_sprite_realize_texture (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
void meta_cursor_sprite_set_texture (MetaCursorSprite *self,
|
|
||||||
|
void meta_cursor_sprite_set_texture (MetaCursorSprite *sprite,
|
||||||
CoglTexture *texture,
|
CoglTexture *texture,
|
||||||
int hot_x,
|
int hot_x,
|
||||||
int hot_y);
|
int hot_y);
|
||||||
|
|
||||||
void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *self,
|
void meta_cursor_sprite_set_texture_scale (MetaCursorSprite *sprite,
|
||||||
float scale);
|
float scale);
|
||||||
|
|
||||||
CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self);
|
CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
void meta_cursor_sprite_get_hotspot (MetaCursorSprite *self,
|
void meta_cursor_sprite_get_hotspot (MetaCursorSprite *sprite,
|
||||||
int *hot_x,
|
int *hot_x,
|
||||||
int *hot_y);
|
int *hot_y);
|
||||||
|
|
||||||
float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *self);
|
float meta_cursor_sprite_get_texture_scale (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *self);
|
gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *sprite);
|
||||||
void meta_cursor_sprite_tick_frame (MetaCursorSprite *self);
|
|
||||||
guint meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self);
|
void meta_cursor_sprite_tick_frame (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
|
unsigned int meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite);
|
||||||
|
|
||||||
#endif /* META_CURSOR_H */
|
#endif /* META_CURSOR_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user