Rename MetaCursorReference to MetaCursorSprite

It isn't really a reference to a MetaCursor enum, but a reference
counted cursor sprite, and enum value.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
This commit is contained in:
Jonas Ådahl 2015-03-10 11:23:00 +08:00
parent fe8454d13f
commit 4b667d1e09
12 changed files with 172 additions and 166 deletions

View File

@ -40,7 +40,7 @@ typedef struct {
#endif
} MetaCursorImage;
struct _MetaCursorReference {
struct _MetaCursorSprite {
int ref_count;
int current_frame;
@ -49,18 +49,18 @@ struct _MetaCursorReference {
MetaCursorImage image;
};
CoglTexture *meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
int *hot_x,
int *hot_y);
CoglTexture *meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self,
int *hot_x,
int *hot_y);
#ifdef HAVE_NATIVE_BACKEND
struct gbm_bo *meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
int *hot_x,
int *hot_y);
struct gbm_bo *meta_cursor_sprite_get_gbm_bo (MetaCursorSprite *self,
int *hot_x,
int *hot_y);
#endif
gboolean meta_cursor_reference_is_animated (MetaCursorReference *self);
void meta_cursor_reference_tick_frame (MetaCursorReference *self);
guint meta_cursor_reference_get_current_frame_time (MetaCursorReference *self);
gboolean meta_cursor_sprite_is_animated (MetaCursorSprite *self);
void meta_cursor_sprite_tick_frame (MetaCursorSprite *self);
guint meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self);
#endif /* META_CURSOR_PRIVATE_H */

View File

@ -40,7 +40,7 @@ struct _MetaCursorRendererPrivate
int current_x, current_y;
MetaRectangle current_rect;
MetaCursorReference *displayed_cursor;
MetaCursorSprite *displayed_cursor;
gboolean handled_by_backend;
};
typedef struct _MetaCursorRendererPrivate MetaCursorRendererPrivate;
@ -60,7 +60,8 @@ queue_redraw (MetaCursorRenderer *renderer)
return;
if (priv->displayed_cursor && !priv->handled_by_backend)
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, NULL, NULL);
texture = meta_cursor_sprite_get_cogl_texture (priv->displayed_cursor,
NULL, NULL);
else
texture = NULL;
@ -96,7 +97,8 @@ update_cursor (MetaCursorRenderer *renderer)
CoglTexture *texture;
int hot_x, hot_y;
texture = meta_cursor_reference_get_cogl_texture (priv->displayed_cursor, &hot_x, &hot_y);
texture = meta_cursor_sprite_get_cogl_texture (priv->displayed_cursor,
&hot_x, &hot_y);
priv->current_rect.x = priv->current_x - hot_x;
priv->current_rect.y = priv->current_y - hot_y;
@ -132,15 +134,15 @@ meta_cursor_renderer_new (void)
}
void
meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorReference *cursor)
meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite)
{
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
if (priv->displayed_cursor == cursor)
if (priv->displayed_cursor == cursor_sprite)
return;
priv->displayed_cursor = cursor;
priv->displayed_cursor = cursor_sprite;
update_cursor (renderer);
}
@ -165,7 +167,7 @@ meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
update_cursor (renderer);
}
MetaCursorReference *
MetaCursorSprite *
meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer)
{
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);

View File

@ -45,14 +45,14 @@ GType meta_cursor_renderer_get_type (void) G_GNUC_CONST;
MetaCursorRenderer * meta_cursor_renderer_new (void);
void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorReference *cursor);
void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite);
void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
int x, int y);
void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer);
MetaCursorReference * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
const MetaRectangle * meta_cursor_renderer_get_rect (MetaCursorRenderer *renderer);
#endif /* META_CURSOR_RENDERER_H */

View File

@ -34,7 +34,7 @@ struct _MetaCursorTracker {
gboolean is_showing;
MetaCursorReference *displayed_cursor;
MetaCursorSprite *displayed_cursor;
/* Wayland clients can set a NULL buffer as their cursor
* explicitly, which means that we shouldn't display anything.
@ -42,12 +42,12 @@ struct _MetaCursorTracker {
* determine an unset window cursor; we need an extra boolean.
*/
gboolean has_window_cursor;
MetaCursorReference *window_cursor;
MetaCursorSprite *window_cursor;
MetaCursorReference *root_cursor;
MetaCursorSprite *root_cursor;
/* The cursor from the X11 server. */
MetaCursorReference *xfixes_cursor;
MetaCursorSprite *xfixes_cursor;
};
struct _MetaCursorTrackerClass {
@ -57,16 +57,16 @@ struct _MetaCursorTrackerClass {
gboolean meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
XEvent *xevent);
void meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
MetaCursorReference *cursor);
void meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker);
void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
MetaCursorReference *cursor);
void meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
MetaCursorSprite *cursor_sprite);
void meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker);
void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
MetaCursorSprite *cursor_sprite);
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
int new_x,
int new_y);
MetaCursorReference * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
MetaCursorSprite * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
#endif

View File

@ -54,7 +54,7 @@ enum {
static guint signals[LAST_SIGNAL];
static MetaCursorReference *
static MetaCursorSprite *
get_displayed_cursor (MetaCursorTracker *tracker)
{
MetaDisplay *display = meta_get_display ();
@ -80,14 +80,14 @@ update_displayed_cursor (MetaCursorTracker *tracker)
static void
sync_cursor (MetaCursorTracker *tracker)
{
MetaCursorReference *displayed_cursor = get_displayed_cursor (tracker);
MetaCursorSprite *displayed_cursor = get_displayed_cursor (tracker);
if (tracker->displayed_cursor == displayed_cursor)
return;
g_clear_pointer (&tracker->displayed_cursor, meta_cursor_reference_unref);
g_clear_pointer (&tracker->displayed_cursor, meta_cursor_sprite_unref);
if (displayed_cursor)
tracker->displayed_cursor = meta_cursor_reference_ref (displayed_cursor);
tracker->displayed_cursor = meta_cursor_sprite_ref (displayed_cursor);
update_displayed_cursor (tracker);
g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
@ -108,9 +108,9 @@ meta_cursor_tracker_finalize (GObject *object)
MetaCursorTracker *self = META_CURSOR_TRACKER (object);
if (self->displayed_cursor)
meta_cursor_reference_unref (self->displayed_cursor);
meta_cursor_sprite_unref (self->displayed_cursor);
if (self->root_cursor)
meta_cursor_reference_unref (self->root_cursor);
meta_cursor_sprite_unref (self->root_cursor);
G_OBJECT_CLASS (meta_cursor_tracker_parent_class)->finalize (object);
}
@ -156,13 +156,13 @@ meta_cursor_tracker_get_for_screen (MetaScreen *screen)
}
static void
set_window_cursor (MetaCursorTracker *tracker,
gboolean has_cursor,
MetaCursorReference *cursor)
set_window_cursor (MetaCursorTracker *tracker,
gboolean has_cursor,
MetaCursorSprite *cursor_sprite)
{
g_clear_pointer (&tracker->window_cursor, meta_cursor_reference_unref);
if (cursor)
tracker->window_cursor = meta_cursor_reference_ref (cursor);
g_clear_pointer (&tracker->window_cursor, meta_cursor_sprite_unref);
if (cursor_sprite)
tracker->window_cursor = meta_cursor_sprite_ref (cursor_sprite);
tracker->has_window_cursor = has_cursor;
sync_cursor (tracker);
}
@ -184,20 +184,20 @@ meta_cursor_tracker_handle_xevent (MetaCursorTracker *tracker,
if (notify_event->subtype != XFixesDisplayCursorNotify)
return FALSE;
g_clear_pointer (&tracker->xfixes_cursor, meta_cursor_reference_unref);
g_clear_pointer (&tracker->xfixes_cursor, meta_cursor_sprite_unref);
g_signal_emit (tracker, signals[CURSOR_CHANGED], 0);
return TRUE;
}
static MetaCursorReference *
meta_cursor_reference_take_texture (CoglTexture2D *texture,
int hot_x,
int hot_y)
static MetaCursorSprite *
meta_cursor_sprite_take_texture (CoglTexture2D *texture,
int hot_x,
int hot_y)
{
MetaCursorReference *self;
MetaCursorSprite *self;
self = g_slice_new0 (MetaCursorReference);
self = g_slice_new0 (MetaCursorSprite);
self->ref_count = 1;
self->image.texture = texture;
self->image.hot_x = hot_x;
@ -263,10 +263,11 @@ ensure_xfixes_cursor (MetaCursorTracker *tracker)
if (sprite != NULL)
{
MetaCursorReference *cursor = meta_cursor_reference_take_texture (sprite,
cursor_image->xhot,
cursor_image->yhot);
tracker->xfixes_cursor = cursor;
MetaCursorSprite *cursor_sprite =
meta_cursor_sprite_take_texture (sprite,
cursor_image->xhot,
cursor_image->yhot);
tracker->xfixes_cursor = cursor_sprite;
}
XFree (cursor_image);
}
@ -279,22 +280,22 @@ ensure_xfixes_cursor (MetaCursorTracker *tracker)
CoglTexture *
meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker)
{
MetaCursorReference *cursor;
MetaCursorSprite *cursor_sprite;
g_return_val_if_fail (META_IS_CURSOR_TRACKER (tracker), NULL);
if (meta_is_wayland_compositor ())
{
cursor = tracker->displayed_cursor;
cursor_sprite = tracker->displayed_cursor;
}
else
{
ensure_xfixes_cursor (tracker);
cursor = tracker->xfixes_cursor;
cursor_sprite = tracker->xfixes_cursor;
}
if (cursor)
return meta_cursor_reference_get_cogl_texture (cursor, NULL, NULL);
if (cursor_sprite)
return meta_cursor_sprite_get_cogl_texture (cursor_sprite, NULL, NULL);
else
return NULL;
}
@ -311,22 +312,22 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
int *x,
int *y)
{
MetaCursorReference *cursor;
MetaCursorSprite *cursor_sprite;
g_return_if_fail (META_IS_CURSOR_TRACKER (tracker));
if (meta_is_wayland_compositor ())
{
cursor = tracker->displayed_cursor;
cursor_sprite = tracker->displayed_cursor;
}
else
{
ensure_xfixes_cursor (tracker);
cursor = tracker->xfixes_cursor;
cursor_sprite = tracker->xfixes_cursor;
}
if (cursor)
meta_cursor_reference_get_cogl_texture (cursor, x, y);
if (cursor_sprite)
meta_cursor_sprite_get_cogl_texture (cursor_sprite, x, y);
else
{
if (x)
@ -337,10 +338,10 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
}
void
meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
MetaCursorReference *cursor)
meta_cursor_tracker_set_window_cursor (MetaCursorTracker *tracker,
MetaCursorSprite *cursor_sprite)
{
set_window_cursor (tracker, TRUE, cursor);
set_window_cursor (tracker, TRUE, cursor_sprite);
}
void
@ -350,12 +351,12 @@ meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker)
}
void
meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
MetaCursorReference *cursor)
meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
MetaCursorSprite *cursor_sprite)
{
g_clear_pointer (&tracker->root_cursor, meta_cursor_reference_unref);
if (cursor)
tracker->root_cursor = meta_cursor_reference_ref (cursor);
g_clear_pointer (&tracker->root_cursor, meta_cursor_sprite_unref);
if (cursor_sprite)
tracker->root_cursor = meta_cursor_sprite_ref (cursor_sprite);
sync_cursor (tracker);
}
@ -438,7 +439,7 @@ meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
sync_cursor (tracker);
}
MetaCursorReference *
MetaCursorSprite *
meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker)
{
return tracker->displayed_cursor;

View File

@ -43,8 +43,8 @@
#include <cogl/cogl-wayland-server.h>
#endif
MetaCursorReference *
meta_cursor_reference_ref (MetaCursorReference *self)
MetaCursorSprite *
meta_cursor_sprite_ref (MetaCursorSprite *self)
{
g_assert (self->ref_count > 0);
self->ref_count++;
@ -65,21 +65,21 @@ meta_cursor_image_free (MetaCursorImage *image)
}
static void
meta_cursor_reference_free (MetaCursorReference *self)
meta_cursor_sprite_free (MetaCursorSprite *self)
{
if (self->xcursor_images)
XcursorImagesDestroy (self->xcursor_images);
meta_cursor_image_free (&self->image);
g_slice_free (MetaCursorReference, self);
g_slice_free (MetaCursorSprite, self);
}
void
meta_cursor_reference_unref (MetaCursorReference *self)
meta_cursor_sprite_unref (MetaCursorSprite *self)
{
self->ref_count--;
if (self->ref_count == 0)
meta_cursor_reference_free (self);
meta_cursor_sprite_free (self);
}
static const char *
@ -259,17 +259,17 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage *image,
}
static XcursorImage *
meta_cursor_reference_get_current_frame_image (MetaCursorReference *self)
meta_cursor_sprite_get_current_frame_image (MetaCursorSprite *self)
{
return self->xcursor_images->images[self->current_frame];
}
void
meta_cursor_reference_tick_frame (MetaCursorReference *self)
meta_cursor_sprite_tick_frame (MetaCursorSprite *self)
{
XcursorImage *image;
if (!meta_cursor_reference_is_animated (self))
if (!meta_cursor_sprite_is_animated (self))
return;
self->current_frame++;
@ -278,52 +278,52 @@ meta_cursor_reference_tick_frame (MetaCursorReference *self)
self->current_frame = 0;
meta_cursor_image_free (&self->image);
image = meta_cursor_reference_get_current_frame_image (self);
image = meta_cursor_sprite_get_current_frame_image (self);
meta_cursor_image_load_from_xcursor_image (&self->image, image);
}
guint
meta_cursor_reference_get_current_frame_time (MetaCursorReference *self)
meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *self)
{
if (!meta_cursor_reference_is_animated (self))
if (!meta_cursor_sprite_is_animated (self))
return 0;
return self->xcursor_images->images[self->current_frame]->delay;
}
gboolean
meta_cursor_reference_is_animated (MetaCursorReference *self)
meta_cursor_sprite_is_animated (MetaCursorSprite *self)
{
return (self->xcursor_images &&
self->xcursor_images->nimage > 1);
}
static void
load_cursor_image (MetaCursorReference *cursor)
load_cursor_image (MetaCursorSprite *self)
{
XcursorImage *image;
/* Either cursors are loaded from X cursors or buffers. Since
* buffers are converted over immediately, we can make sure to
* load this directly. */
g_assert (cursor->cursor != META_CURSOR_NONE);
g_assert (self->cursor != META_CURSOR_NONE);
if (!cursor->xcursor_images)
if (!self->xcursor_images)
{
cursor->current_frame = 0;
cursor->xcursor_images = load_cursor_on_client (cursor->cursor);
if (!cursor->xcursor_images)
self->current_frame = 0;
self->xcursor_images = load_cursor_on_client (self->cursor);
if (!self->xcursor_images)
meta_fatal ("Could not find cursor. Perhaps set XCURSOR_PATH?");
}
image = meta_cursor_reference_get_current_frame_image (cursor);
meta_cursor_image_load_from_xcursor_image (&cursor->image, image);
image = meta_cursor_sprite_get_current_frame_image (self);
meta_cursor_image_load_from_xcursor_image (&self->image, image);
}
MetaCursorReference *
meta_cursor_reference_from_theme (MetaCursor cursor)
MetaCursorSprite *
meta_cursor_sprite_from_theme (MetaCursor cursor)
{
MetaCursorReference *self = g_slice_new0 (MetaCursorReference);
MetaCursorSprite *self = g_slice_new0 (MetaCursorSprite);
self->ref_count = 1;
self->cursor = cursor;
return self;
@ -419,14 +419,14 @@ meta_cursor_image_load_from_buffer (MetaCursorImage *image,
#endif
}
MetaCursorReference *
meta_cursor_reference_from_buffer (struct wl_resource *buffer,
int hot_x,
int hot_y)
MetaCursorSprite *
meta_cursor_sprite_from_buffer (struct wl_resource *buffer,
int hot_x,
int hot_y)
{
MetaCursorReference *self;
MetaCursorSprite *self;
self = g_slice_new0 (MetaCursorReference);
self = g_slice_new0 (MetaCursorSprite);
self->ref_count = 1;
meta_cursor_image_load_from_buffer (&self->image, buffer, hot_x, hot_y);
@ -435,40 +435,40 @@ meta_cursor_reference_from_buffer (struct wl_resource *buffer,
#endif
CoglTexture *
meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor,
int *hot_x,
int *hot_y)
meta_cursor_sprite_get_cogl_texture (MetaCursorSprite *self,
int *hot_x,
int *hot_y)
{
if (!cursor->image.texture)
load_cursor_image (cursor);
if (!self->image.texture)
load_cursor_image (self);
if (hot_x)
*hot_x = cursor->image.hot_x;
*hot_x = self->image.hot_x;
if (hot_y)
*hot_y = cursor->image.hot_y;
*hot_y = self->image.hot_y;
return COGL_TEXTURE (cursor->image.texture);
return COGL_TEXTURE (self->image.texture);
}
#ifdef HAVE_NATIVE_BACKEND
struct gbm_bo *
meta_cursor_reference_get_gbm_bo (MetaCursorReference *cursor,
int *hot_x,
int *hot_y)
meta_cursor_sprite_get_gbm_bo (MetaCursorSprite *self,
int *hot_x,
int *hot_y)
{
if (!cursor->image.bo)
load_cursor_image (cursor);
if (!self->image.bo)
load_cursor_image (self);
if (hot_x)
*hot_x = cursor->image.hot_x;
*hot_x = self->image.hot_x;
if (hot_y)
*hot_y = cursor->image.hot_y;
return cursor->image.bo;
*hot_y = self->image.hot_y;
return self->image.bo;
}
#endif
MetaCursor
meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor)
meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self)
{
return cursor->cursor;
return self->cursor;
}

View File

@ -22,23 +22,23 @@
#ifndef META_CURSOR_H
#define META_CURSOR_H
typedef struct _MetaCursorReference MetaCursorReference;
typedef struct _MetaCursorSprite MetaCursorSprite;
MetaCursorReference * meta_cursor_reference_ref (MetaCursorReference *cursor);
void meta_cursor_reference_unref (MetaCursorReference *cursor);
MetaCursorSprite * meta_cursor_sprite_ref (MetaCursorSprite *self);
void meta_cursor_sprite_unref (MetaCursorSprite *self);
#include <meta/common.h>
MetaCursorReference * meta_cursor_reference_from_theme (MetaCursor cursor);
MetaCursorSprite * meta_cursor_sprite_from_theme (MetaCursor cursor);
#ifdef HAVE_WAYLAND
#include <wayland-server.h>
MetaCursorReference * meta_cursor_reference_from_buffer (struct wl_resource *buffer,
int hot_x,
int hot_y);
MetaCursorSprite * meta_cursor_sprite_from_buffer (struct wl_resource *buffer,
int hot_x,
int hot_y);
#endif
MetaCursor meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor);
MetaCursor meta_cursor_sprite_get_meta_cursor (MetaCursorSprite *self);
Cursor meta_cursor_create_x_cursor (Display *xdisplay,
MetaCursor cursor);

View File

@ -174,7 +174,7 @@ struct _MetaCRTC
/* Used when changing configuration */
gboolean is_dirty;
MetaCursorReference *cursor;
MetaCursorSprite *cursor;
gpointer driver_private;
GDestroyNotify driver_notify;

View File

@ -43,7 +43,7 @@ struct _MetaCursorRendererNativePrivate
{
gboolean has_hw_cursor;
MetaCursorReference *last_cursor;
MetaCursorSprite *last_cursor;
guint animation_timeout_id;
int drm_fd;
@ -74,23 +74,23 @@ meta_cursor_renderer_native_finalize (GObject *object)
static void
set_crtc_cursor (MetaCursorRendererNative *native,
MetaCRTC *crtc,
MetaCursorReference *cursor,
MetaCursorSprite *cursor_sprite,
gboolean force)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
if (crtc->cursor == cursor && !force)
if (crtc->cursor == cursor_sprite && !force)
return;
crtc->cursor = cursor;
crtc->cursor = cursor_sprite;
if (cursor)
if (cursor_sprite)
{
struct gbm_bo *bo;
union gbm_bo_handle handle;
int hot_x, hot_y;
bo = meta_cursor_reference_get_gbm_bo (cursor, &hot_x, &hot_y);
bo = meta_cursor_sprite_get_gbm_bo (cursor_sprite, &hot_x, &hot_y);
handle = gbm_bo_get_handle (bo);
drmModeSetCursor2 (priv->drm_fd, crtc->crtc_id, handle.u32,
@ -109,7 +109,7 @@ update_hw_cursor (MetaCursorRendererNative *native,
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorRenderer *renderer = META_CURSOR_RENDERER (native);
const MetaRectangle *cursor_rect = meta_cursor_renderer_get_rect (renderer);
MetaCursorReference *cursor = meta_cursor_renderer_get_cursor (renderer);
MetaCursorSprite *cursor_sprite = meta_cursor_renderer_get_cursor (renderer);
MetaMonitorManager *monitors;
MetaCRTC *crtcs;
unsigned int i, n_crtcs;
@ -120,14 +120,14 @@ update_hw_cursor (MetaCursorRendererNative *native,
for (i = 0; i < n_crtcs; i++)
{
gboolean crtc_should_have_cursor;
MetaCursorReference *crtc_cursor;
MetaCursorSprite *crtc_cursor;
MetaRectangle *crtc_rect;
crtc_rect = &crtcs[i].rect;
crtc_should_have_cursor = (priv->has_hw_cursor && meta_rectangle_overlap (cursor_rect, crtc_rect));
if (crtc_should_have_cursor)
crtc_cursor = cursor;
crtc_cursor = cursor_sprite;
else
crtc_cursor = NULL;
@ -145,10 +145,10 @@ update_hw_cursor (MetaCursorRendererNative *native,
static gboolean
should_have_hw_cursor (MetaCursorRenderer *renderer)
{
MetaCursorReference *cursor = meta_cursor_renderer_get_cursor (renderer);
MetaCursorSprite *cursor_sprite = meta_cursor_renderer_get_cursor (renderer);
if (cursor)
return (meta_cursor_reference_get_gbm_bo (cursor, NULL, NULL) != NULL);
if (cursor_sprite)
return (meta_cursor_sprite_get_gbm_bo (cursor_sprite, NULL, NULL) != NULL);
else
return FALSE;
}
@ -157,11 +157,12 @@ static gboolean
meta_cursor_renderer_native_update_animation (MetaCursorRendererNative *native)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorReference *cursor;
MetaCursorSprite *cursor_sprite;
priv->animation_timeout_id = 0;
cursor = meta_cursor_renderer_get_cursor (META_CURSOR_RENDERER (native));
meta_cursor_reference_tick_frame (cursor);
cursor_sprite =
meta_cursor_renderer_get_cursor (META_CURSOR_RENDERER (native));
meta_cursor_sprite_tick_frame (cursor_sprite);
meta_cursor_renderer_force_update (META_CURSOR_RENDERER (native));
meta_cursor_renderer_native_force_update (native);
@ -172,13 +173,14 @@ static void
meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native)
{
MetaCursorRendererNativePrivate *priv = meta_cursor_renderer_native_get_instance_private (native);
MetaCursorReference *cursor;
MetaCursorSprite *cursor_sprite;
gboolean cursor_change;
guint delay;
cursor = meta_cursor_renderer_get_cursor (META_CURSOR_RENDERER (native));
cursor_change = cursor != priv->last_cursor;
priv->last_cursor = cursor;
cursor_sprite =
meta_cursor_renderer_get_cursor (META_CURSOR_RENDERER (native));
cursor_change = cursor_sprite != priv->last_cursor;
priv->last_cursor = cursor_sprite;
if (!cursor_change && priv->animation_timeout_id)
return;
@ -189,9 +191,9 @@ meta_cursor_renderer_native_trigger_frame (MetaCursorRendererNative *native)
priv->animation_timeout_id = 0;
}
if (cursor && meta_cursor_reference_is_animated (cursor))
if (cursor_sprite && meta_cursor_sprite_is_animated (cursor_sprite))
{
delay = meta_cursor_reference_get_current_frame_time (cursor);
delay = meta_cursor_sprite_get_current_frame_time (cursor_sprite);
if (delay == 0)
return;

View File

@ -53,12 +53,12 @@ meta_cursor_renderer_x11_update_cursor (MetaCursorRenderer *renderer)
Display *xdisplay = meta_backend_x11_get_xdisplay (backend);
MetaCursorReference *cursor_ref = meta_cursor_renderer_get_cursor (renderer);
MetaCursorSprite *cursor_sprite = meta_cursor_renderer_get_cursor (renderer);
gboolean has_server_cursor = FALSE;
if (cursor_ref)
if (cursor_sprite)
{
MetaCursor cursor = meta_cursor_reference_get_meta_cursor (cursor_ref);
MetaCursor cursor = meta_cursor_sprite_get_meta_cursor (cursor_sprite);
if (cursor != META_CURSOR_NONE)
{
Cursor xcursor = meta_cursor_create_x_cursor (xdisplay, cursor);

View File

@ -1261,12 +1261,12 @@ meta_screen_update_cursor (MetaScreen *screen)
MetaDisplay *display = screen->display;
MetaCursor cursor = screen->current_cursor;
Cursor xcursor;
MetaCursorReference *cursor_ref;
MetaCursorSprite *cursor_sprite;
MetaCursorTracker *tracker = meta_cursor_tracker_get_for_screen (screen);
cursor_ref = meta_cursor_reference_from_theme (cursor);
meta_cursor_tracker_set_root_cursor (tracker, cursor_ref);
meta_cursor_reference_unref (cursor_ref);
cursor_sprite = meta_cursor_sprite_from_theme (cursor);
meta_cursor_tracker_set_root_cursor (tracker, cursor_sprite);
meta_cursor_sprite_unref (cursor_sprite);
/* Set a cursor for X11 applications that don't specify their own */
xcursor = meta_display_create_x_cursor (display, cursor);

View File

@ -735,22 +735,23 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
if (pointer->current)
{
MetaCursorReference *cursor;
MetaCursorSprite *cursor_sprite;
if (pointer->cursor_surface && pointer->cursor_surface->buffer)
{
struct wl_resource *buffer = pointer->cursor_surface->buffer->resource;
cursor = meta_cursor_reference_from_buffer (buffer,
pointer->hotspot_x,
pointer->hotspot_y);
cursor_sprite = meta_cursor_sprite_from_buffer (buffer,
pointer->hotspot_x,
pointer->hotspot_y);
}
else
cursor = NULL;
cursor_sprite = NULL;
meta_cursor_tracker_set_window_cursor (pointer->cursor_tracker, cursor);
meta_cursor_tracker_set_window_cursor (pointer->cursor_tracker,
cursor_sprite);
if (cursor)
meta_cursor_reference_unref (cursor);
if (cursor_sprite)
meta_cursor_sprite_unref (cursor_sprite);
}
else
{