cursor-renderer: Fetch instead of pass Xcursor image when realizing
The end goal here is to being able to realize at any point in time through a single API, so start by moving state into the cursor sprite implementation. https://gitlab.gnome.org/GNOME/mutter/issues/77
This commit is contained in:
parent
817c8e568c
commit
c80fd487f1
@ -299,12 +299,11 @@ meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *renderer
|
||||
#endif
|
||||
|
||||
void
|
||||
meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
XcursorImage *xc_image)
|
||||
meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
{
|
||||
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
|
||||
|
||||
if (renderer_class->realize_cursor_from_xcursor)
|
||||
renderer_class->realize_cursor_from_xcursor (renderer, cursor_sprite, xc_image);
|
||||
renderer_class->realize_cursor_from_xcursor (renderer, sprite_xcursor);
|
||||
}
|
||||
|
@ -26,13 +26,13 @@
|
||||
#define META_CURSOR_RENDERER_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#ifdef HAVE_WAYLAND
|
||||
#include <wayland-server.h>
|
||||
#endif
|
||||
|
||||
#include <meta/screen.h>
|
||||
#include "meta-cursor.h"
|
||||
#include "backends/meta-cursor-sprite-xcursor.h"
|
||||
|
||||
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
||||
@ -49,9 +49,8 @@ struct _MetaCursorRendererClass
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
struct wl_resource *buffer);
|
||||
#endif
|
||||
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
XcursorImage *xc_image);
|
||||
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
|
||||
MetaCursorSpriteXcursor *sprite_xcursor);
|
||||
};
|
||||
|
||||
MetaCursorRenderer * meta_cursor_renderer_new (void);
|
||||
@ -76,9 +75,8 @@ void meta_cursor_renderer_realize_cursor_from_wl_buffer (MetaCursorRenderer *ren
|
||||
struct wl_resource *buffer);
|
||||
#endif
|
||||
|
||||
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
XcursorImage *xc_image);
|
||||
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSpriteXcursor *sprite_xcursor);
|
||||
|
||||
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite);
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
#include "backends/meta-cursor-sprite-xcursor.h"
|
||||
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-cursor.h"
|
||||
#include "backends/meta-cursor-renderer.h"
|
||||
@ -117,11 +115,11 @@ load_cursor_on_client (MetaCursor cursor, int scale)
|
||||
}
|
||||
|
||||
static void
|
||||
load_from_xcursor_image (MetaCursorSprite *sprite,
|
||||
XcursorImage *xc_image)
|
||||
load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
||||
XcursorImage *xc_image;
|
||||
int width, height, rowstride;
|
||||
CoglPixelFormat cogl_format;
|
||||
ClutterBackend *clutter_backend;
|
||||
@ -129,8 +127,9 @@ load_from_xcursor_image (MetaCursorSprite *sprite,
|
||||
CoglTexture2D *texture;
|
||||
CoglError *error = NULL;
|
||||
|
||||
g_assert (!meta_cursor_sprite_get_cogl_texture (sprite));
|
||||
g_assert (!meta_cursor_sprite_get_cogl_texture (META_CURSOR_SPRITE (sprite_xcursor)));
|
||||
|
||||
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
|
||||
width = (int) xc_image->width;
|
||||
height = (int) xc_image->height;
|
||||
rowstride = width * 4;
|
||||
@ -156,12 +155,13 @@ load_from_xcursor_image (MetaCursorSprite *sprite,
|
||||
cogl_error_free (error);
|
||||
}
|
||||
|
||||
meta_cursor_sprite_set_texture (sprite, COGL_TEXTURE (texture),
|
||||
meta_cursor_sprite_set_texture (META_CURSOR_SPRITE (sprite_xcursor),
|
||||
COGL_TEXTURE (texture),
|
||||
xc_image->xhot, xc_image->yhot);
|
||||
|
||||
g_clear_pointer (&texture, cogl_object_unref);
|
||||
|
||||
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, sprite, xc_image);
|
||||
meta_cursor_renderer_realize_cursor_from_xcursor (renderer, sprite_xcursor);
|
||||
}
|
||||
|
||||
void
|
||||
@ -182,11 +182,9 @@ meta_cursor_sprite_xcursor_is_animated (MetaCursorSprite *sprite)
|
||||
sprite_xcursor->xcursor_images->nimage > 1);
|
||||
}
|
||||
|
||||
static XcursorImage *
|
||||
get_current_frame_image (MetaCursorSprite *sprite)
|
||||
XcursorImage *
|
||||
meta_cursor_sprite_xcursor_get_current_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
{
|
||||
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
||||
|
||||
return sprite_xcursor->xcursor_images->images[sprite_xcursor->current_frame];
|
||||
}
|
||||
|
||||
@ -194,7 +192,6 @@ static void
|
||||
meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
|
||||
{
|
||||
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
||||
XcursorImage *image;
|
||||
|
||||
if (!meta_cursor_sprite_is_animated (sprite))
|
||||
return;
|
||||
@ -204,10 +201,8 @@ meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
|
||||
if (sprite_xcursor->current_frame >= sprite_xcursor->xcursor_images->nimage)
|
||||
sprite_xcursor->current_frame = 0;
|
||||
|
||||
image = get_current_frame_image (sprite);
|
||||
|
||||
meta_cursor_sprite_clear_texture (sprite);
|
||||
load_from_xcursor_image (sprite, image);
|
||||
load_from_current_xcursor_image (sprite_xcursor);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
@ -226,7 +221,6 @@ static void
|
||||
load_cursor_from_theme (MetaCursorSprite *sprite)
|
||||
{
|
||||
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
||||
XcursorImage *image;
|
||||
|
||||
g_assert (sprite_xcursor->cursor != META_CURSOR_NONE);
|
||||
|
||||
@ -246,8 +240,7 @@ load_cursor_from_theme (MetaCursorSprite *sprite)
|
||||
if (!sprite_xcursor->xcursor_images)
|
||||
g_error ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
||||
|
||||
image = get_current_frame_image (sprite);
|
||||
load_from_xcursor_image (sprite, image);
|
||||
load_from_current_xcursor_image (sprite_xcursor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define META_CURSOR_SPRITE_XCURSOR_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include "backends/meta-cursor.h"
|
||||
|
||||
@ -34,6 +35,8 @@ void meta_cursor_sprite_xcursor_set_theme_scale (MetaCursorSpriteXcursor *sprite
|
||||
|
||||
MetaCursor meta_cursor_sprite_xcursor_get_cursor (MetaCursorSpriteXcursor *sprite_xcusror);
|
||||
|
||||
XcursorImage * meta_cursor_sprite_xcursor_get_current_image (MetaCursorSpriteXcursor *sprite_xcursor);
|
||||
|
||||
Cursor meta_create_x_cursor (Display *xdisplay,
|
||||
MetaCursor cursor);
|
||||
|
||||
|
@ -954,13 +954,14 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *r
|
||||
#endif
|
||||
|
||||
static void
|
||||
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
|
||||
MetaGpuKms *gpu_kms,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
XcursorImage *xc_image)
|
||||
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
|
||||
MetaGpuKms *gpu_kms,
|
||||
MetaCursorSpriteXcursor *sprite_xcursor,
|
||||
XcursorImage *xc_image)
|
||||
{
|
||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
|
||||
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
|
||||
|
||||
cursor_renderer_gpu_data =
|
||||
meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
|
||||
@ -980,16 +981,17 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRende
|
||||
}
|
||||
|
||||
static void
|
||||
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite,
|
||||
XcursorImage *xc_image)
|
||||
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSpriteXcursor *sprite_xcursor)
|
||||
{
|
||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||
MetaCursorRendererNativePrivate *priv =
|
||||
meta_cursor_renderer_native_get_instance_private (native);
|
||||
XcursorImage *xc_image;
|
||||
GList *gpus;
|
||||
GList *l;
|
||||
|
||||
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
|
||||
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
|
||||
for (l = gpus; l; l = l->next)
|
||||
{
|
||||
@ -998,7 +1000,7 @@ meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *ren
|
||||
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (
|
||||
renderer,
|
||||
gpu_kms,
|
||||
cursor_sprite,
|
||||
sprite_xcursor,
|
||||
xc_image);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
|
||||
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include "backends/x11/meta-backend-x11.h"
|
||||
|
||||
struct _MetaCursorRendererX11Nested
|
||||
|
Loading…
Reference in New Issue
Block a user