Hardcoding Single Cursor theme

Hello,

Does anyone know a good way to hardcode a cursor theme in gnome/mutter, so that regardless of the cursor theme source it always remains the same?

Regardless of Wayland themed cursors, hardware vs software cursors, Xwayland apps, X11 apps running on wayland.

Looking in the code, it seems like a good place is:
mutter/src/backends/meta-cursor-renderer.c

In the function: meta_cursor_renderer_update_cursor()

    static void
meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
                                    ClutterCursor      *cursor)
{
  MetaCursorRendererPrivate *priv =
    meta_cursor_renderer_get_instance_private (renderer);

  if (cursor)
    {
      float scale = find_highest_logical_monitor_scale (renderer, cursor);
      clutter_cursor_prepare_at (cursor,
                                 MAX (1, scale),
                                 (int) priv->current_x,
                                 (int) priv->current_y);
    }

  priv->needs_overlay =
    META_CURSOR_RENDERER_GET_CLASS (renderer)->update_cursor (renderer, cursor);

  meta_cursor_renderer_update_stage_overlay (renderer, cursor);
}

This seems like a good choice because it’s closer to the rendering of the end result of what the user sees (avoiding potential complications by which code path supplies the cursor being used (wayland vs xcursor, …)

meta_cursor_renderer_update_cursor() is included in several important functions like:

meta_cursor_renderer_set_cursor()

meta_cursor_renderer_force_update()

meta_cursor_renderer_update_position()

meta_cursor_renderer_set_sprite()

Would this update_cursor() function be good for the task? If so, there’s 2 function arguments:

MetaCursorRenderer *renderer - to the best of my knowledge this handles things like cursor position and ultimately drawing the cursor, so it doesn’t need to be touched

ClutterCursor *cursor - handles cursor theme, hotspot, and items located in the struct definition:

 struct _ClutterCursorClass
{
  GObjectClass parent_class;

  CoglTexture * (* get_texture) (ClutterCursor *cursor,
                                 int           *hot_x,
                                 int           *hot_y);

  void (* invalidate) (ClutterCursor *cursor);

  gboolean (* realize_texture) (ClutterCursor *cursor);

  gboolean (* is_animated) (ClutterCursor *cursor);

  void (* tick_frame) (ClutterCursor *cursor);

  unsigned int (* get_current_frame_time) (ClutterCursor *cursor);

  void (* prepare_at) (ClutterCursor *cursor,
                       float          best_scale,
                       int            x,
                       int            y);
};

this is located in:

mutter/clutter/clutter/clutter-cursor.h

Would a function that creates an object satisfying ClutterCursorClass struct be sufficient for the meta_cursor_renderer_update_cursor() function? Is there some function which already exists in the code that will take care of that?

I’ve looked so far at functions like:

mutter/src/backends/native/meta-clutter-backend-native.c

 static void
ensure_pointer_sprite (ClutterBackend *clutter_backend)
{
  MetaClutterBackendNative *clutter_backend_native =
    META_CLUTTER_BACKEND_NATIVE (clutter_backend);

  if (!clutter_backend_native->pointer_sprite)
    {
      MetaBackend *backend = clutter_backend_native->backend;
      ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));

      clutter_backend_native->pointer_sprite =
        g_object_new (META_TYPE_SPRITE_NATIVE,
                      "backend", backend,
                      "stage", stage,
                      "role", CLUTTER_SPRITE_ROLE_POINTER,
                      NULL);
    }
}

Since this uses g_object_new() to instantiate this kind of object, but to the best of my knowledge it’s empty of data and I can’t find where it gets populated.

I’ve also tried expanding macros such as
CLUTTER_EXPORT

G_DECLARE_DERIVABLE_TYPE ()./src/backends/native/meta-clutter-backend-native.c

But I still haven’t figured out the actual pointer where different pieces of data are all added into a compatible object that will work with the ClutterCursor *cursor argument of meta_cursor_renderer_update_cursor() function.

Is the update_cursor() function a good place for this? If so, where is a good place to generate a valid parameter that will maintain a constant cursor theme?