From 0efb0b47ebb2712cbd021d26027d8244414dd5c8 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 31 Mar 2014 16:10:58 -0400 Subject: [PATCH] cursor: Move cursor caching layer to meta_cursor_reference_from_theme --- src/core/meta-cursor-tracker-private.h | 2 +- src/core/meta-cursor-tracker.c | 22 ++++------------------ src/core/meta-cursor.c | 3 +++ 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/core/meta-cursor-tracker-private.h b/src/core/meta-cursor-tracker-private.h index 62b32d39f..9da347a3c 100644 --- a/src/core/meta-cursor-tracker-private.h +++ b/src/core/meta-cursor-tracker-private.h @@ -61,7 +61,7 @@ struct _MetaCursorTracker { MetaCursorReference *root_cursor; - MetaCursorReference *default_cursors[META_CURSOR_LAST]; + MetaCursorReference *theme_cursors[META_CURSOR_LAST]; int current_x, current_y; MetaRectangle current_rect; diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c index 7338e2ad5..ebc661b8a 100644 --- a/src/core/meta-cursor-tracker.c +++ b/src/core/meta-cursor-tracker.c @@ -85,8 +85,8 @@ meta_cursor_tracker_finalize (GObject *object) meta_cursor_reference_unref (self->root_cursor); for (i = 0; i < META_CURSOR_LAST; i++) - if (self->default_cursors[i]) - meta_cursor_reference_unref (self->default_cursors[i]); + if (self->theme_cursors[i]) + meta_cursor_reference_unref (self->theme_cursors[i]); if (self->pipeline) cogl_object_unref (self->pipeline); @@ -371,27 +371,13 @@ meta_cursor_tracker_get_hot (MetaCursorTracker *tracker, } } -static MetaCursorReference * -ensure_wayland_cursor (MetaCursorTracker *tracker, - MetaCursor cursor) -{ - if (!tracker->default_cursors[cursor]) - { - tracker->default_cursors[cursor] = meta_cursor_reference_from_theme (tracker, cursor); - if (!tracker->default_cursors[cursor]) - meta_warning ("Failed to load cursor from theme\n"); - } - - return meta_cursor_reference_ref (tracker->default_cursors[cursor]); -} - void meta_cursor_tracker_set_grab_cursor (MetaCursorTracker *tracker, MetaCursor cursor) { g_clear_pointer (&tracker->grab_cursor, meta_cursor_reference_unref); if (cursor != META_CURSOR_DEFAULT) - tracker->grab_cursor = ensure_wayland_cursor (tracker, cursor); + tracker->grab_cursor = meta_cursor_reference_from_theme (tracker, cursor); sync_cursor (tracker); } @@ -435,7 +421,7 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker, if (meta_is_wayland_compositor ()) { g_clear_pointer (&tracker->root_cursor, meta_cursor_reference_unref); - tracker->root_cursor = ensure_wayland_cursor (tracker, cursor); + tracker->root_cursor = meta_cursor_reference_from_theme (tracker, cursor); sync_cursor (tracker); } } diff --git a/src/core/meta-cursor.c b/src/core/meta-cursor.c index 94cf34155..021a20619 100644 --- a/src/core/meta-cursor.c +++ b/src/core/meta-cursor.c @@ -255,6 +255,9 @@ meta_cursor_reference_from_theme (MetaCursorTracker *tracker, MetaCursorReference *self; XcursorImage *image; + if (tracker->theme_cursors[cursor]) + return meta_cursor_reference_ref (tracker->theme_cursors[cursor]); + image = load_cursor_on_client (tracker->screen->display, cursor); if (!image) return NULL;