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
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSpriteXcursor *sprite_xcursor)
|
||||||
XcursorImage *xc_image)
|
|
||||||
{
|
{
|
||||||
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
|
MetaCursorRendererClass *renderer_class = META_CURSOR_RENDERER_GET_CLASS (renderer);
|
||||||
|
|
||||||
if (renderer_class->realize_cursor_from_xcursor)
|
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
|
#define META_CURSOR_RENDERER_H
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <X11/Xcursor/Xcursor.h>
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <meta/screen.h>
|
#include <meta/screen.h>
|
||||||
#include "meta-cursor.h"
|
#include "meta-cursor.h"
|
||||||
|
#include "backends/meta-cursor-sprite-xcursor.h"
|
||||||
|
|
||||||
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
|
#define META_TYPE_CURSOR_RENDERER (meta_cursor_renderer_get_type ())
|
||||||
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
G_DECLARE_DERIVABLE_TYPE (MetaCursorRenderer, meta_cursor_renderer,
|
||||||
@ -49,9 +49,8 @@ struct _MetaCursorRendererClass
|
|||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSprite *cursor_sprite,
|
||||||
struct wl_resource *buffer);
|
struct wl_resource *buffer);
|
||||||
#endif
|
#endif
|
||||||
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
|
void (* realize_cursor_from_xcursor) (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSpriteXcursor *sprite_xcursor);
|
||||||
XcursorImage *xc_image);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaCursorRenderer * meta_cursor_renderer_new (void);
|
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);
|
struct wl_resource *buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
void meta_cursor_renderer_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSpriteXcursor *sprite_xcursor);
|
||||||
XcursorImage *xc_image);
|
|
||||||
|
|
||||||
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite);
|
MetaCursorSprite *cursor_sprite);
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include "backends/meta-cursor-sprite-xcursor.h"
|
#include "backends/meta-cursor-sprite-xcursor.h"
|
||||||
|
|
||||||
#include <X11/Xcursor/Xcursor.h>
|
|
||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-cursor.h"
|
#include "backends/meta-cursor.h"
|
||||||
#include "backends/meta-cursor-renderer.h"
|
#include "backends/meta-cursor-renderer.h"
|
||||||
@ -117,11 +115,11 @@ load_cursor_on_client (MetaCursor cursor, int scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_from_xcursor_image (MetaCursorSprite *sprite,
|
load_from_current_xcursor_image (MetaCursorSpriteXcursor *sprite_xcursor)
|
||||||
XcursorImage *xc_image)
|
|
||||||
{
|
{
|
||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
MetaCursorRenderer *renderer = meta_backend_get_cursor_renderer (backend);
|
||||||
|
XcursorImage *xc_image;
|
||||||
int width, height, rowstride;
|
int width, height, rowstride;
|
||||||
CoglPixelFormat cogl_format;
|
CoglPixelFormat cogl_format;
|
||||||
ClutterBackend *clutter_backend;
|
ClutterBackend *clutter_backend;
|
||||||
@ -129,8 +127,9 @@ load_from_xcursor_image (MetaCursorSprite *sprite,
|
|||||||
CoglTexture2D *texture;
|
CoglTexture2D *texture;
|
||||||
CoglError *error = NULL;
|
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;
|
width = (int) xc_image->width;
|
||||||
height = (int) xc_image->height;
|
height = (int) xc_image->height;
|
||||||
rowstride = width * 4;
|
rowstride = width * 4;
|
||||||
@ -156,12 +155,13 @@ load_from_xcursor_image (MetaCursorSprite *sprite,
|
|||||||
cogl_error_free (error);
|
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);
|
xc_image->xhot, xc_image->yhot);
|
||||||
|
|
||||||
g_clear_pointer (&texture, cogl_object_unref);
|
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
|
void
|
||||||
@ -182,11 +182,9 @@ meta_cursor_sprite_xcursor_is_animated (MetaCursorSprite *sprite)
|
|||||||
sprite_xcursor->xcursor_images->nimage > 1);
|
sprite_xcursor->xcursor_images->nimage > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static XcursorImage *
|
XcursorImage *
|
||||||
get_current_frame_image (MetaCursorSprite *sprite)
|
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];
|
return sprite_xcursor->xcursor_images->images[sprite_xcursor->current_frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +192,6 @@ static void
|
|||||||
meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
|
meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
||||||
XcursorImage *image;
|
|
||||||
|
|
||||||
if (!meta_cursor_sprite_is_animated (sprite))
|
if (!meta_cursor_sprite_is_animated (sprite))
|
||||||
return;
|
return;
|
||||||
@ -204,10 +201,8 @@ meta_cursor_sprite_xcursor_tick_frame (MetaCursorSprite *sprite)
|
|||||||
if (sprite_xcursor->current_frame >= sprite_xcursor->xcursor_images->nimage)
|
if (sprite_xcursor->current_frame >= sprite_xcursor->xcursor_images->nimage)
|
||||||
sprite_xcursor->current_frame = 0;
|
sprite_xcursor->current_frame = 0;
|
||||||
|
|
||||||
image = get_current_frame_image (sprite);
|
|
||||||
|
|
||||||
meta_cursor_sprite_clear_texture (sprite);
|
meta_cursor_sprite_clear_texture (sprite);
|
||||||
load_from_xcursor_image (sprite, image);
|
load_from_current_xcursor_image (sprite_xcursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
@ -226,7 +221,6 @@ static void
|
|||||||
load_cursor_from_theme (MetaCursorSprite *sprite)
|
load_cursor_from_theme (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
MetaCursorSpriteXcursor *sprite_xcursor = META_CURSOR_SPRITE_XCURSOR (sprite);
|
||||||
XcursorImage *image;
|
|
||||||
|
|
||||||
g_assert (sprite_xcursor->cursor != META_CURSOR_NONE);
|
g_assert (sprite_xcursor->cursor != META_CURSOR_NONE);
|
||||||
|
|
||||||
@ -246,8 +240,7 @@ load_cursor_from_theme (MetaCursorSprite *sprite)
|
|||||||
if (!sprite_xcursor->xcursor_images)
|
if (!sprite_xcursor->xcursor_images)
|
||||||
g_error ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
g_error ("Could not find cursor. Perhaps set XCURSOR_PATH?");
|
||||||
|
|
||||||
image = get_current_frame_image (sprite);
|
load_from_current_xcursor_image (sprite_xcursor);
|
||||||
load_from_xcursor_image (sprite, image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#define META_CURSOR_SPRITE_XCURSOR_H
|
#define META_CURSOR_SPRITE_XCURSOR_H
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <X11/Xcursor/Xcursor.h>
|
||||||
|
|
||||||
#include "backends/meta-cursor.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);
|
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,
|
Cursor meta_create_x_cursor (Display *xdisplay,
|
||||||
MetaCursor cursor);
|
MetaCursor cursor);
|
||||||
|
|
||||||
|
@ -954,13 +954,14 @@ meta_cursor_renderer_native_realize_cursor_from_wl_buffer (MetaCursorRenderer *r
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (MetaCursorRenderer *renderer,
|
||||||
MetaGpuKms *gpu_kms,
|
MetaGpuKms *gpu_kms,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSpriteXcursor *sprite_xcursor,
|
||||||
XcursorImage *xc_image)
|
XcursorImage *xc_image)
|
||||||
{
|
{
|
||||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||||
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
|
MetaCursorRendererNativeGpuData *cursor_renderer_gpu_data;
|
||||||
|
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (sprite_xcursor);
|
||||||
|
|
||||||
cursor_renderer_gpu_data =
|
cursor_renderer_gpu_data =
|
||||||
meta_cursor_renderer_native_gpu_data_from_gpu (gpu_kms);
|
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
|
static void
|
||||||
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
meta_cursor_renderer_native_realize_cursor_from_xcursor (MetaCursorRenderer *renderer,
|
||||||
MetaCursorSprite *cursor_sprite,
|
MetaCursorSpriteXcursor *sprite_xcursor)
|
||||||
XcursorImage *xc_image)
|
|
||||||
{
|
{
|
||||||
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
MetaCursorRendererNative *native = META_CURSOR_RENDERER_NATIVE (renderer);
|
||||||
MetaCursorRendererNativePrivate *priv =
|
MetaCursorRendererNativePrivate *priv =
|
||||||
meta_cursor_renderer_native_get_instance_private (native);
|
meta_cursor_renderer_native_get_instance_private (native);
|
||||||
|
XcursorImage *xc_image;
|
||||||
GList *gpus;
|
GList *gpus;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
|
xc_image = meta_cursor_sprite_xcursor_get_current_image (sprite_xcursor);
|
||||||
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
|
gpus = meta_monitor_manager_get_gpus (priv->monitor_manager);
|
||||||
for (l = gpus; l; l = l->next)
|
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 (
|
meta_cursor_renderer_native_realize_cursor_from_xcursor_for_gpu (
|
||||||
renderer,
|
renderer,
|
||||||
gpu_kms,
|
gpu_kms,
|
||||||
cursor_sprite,
|
sprite_xcursor,
|
||||||
xc_image);
|
xc_image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
|
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
|
||||||
|
|
||||||
|
#include <X11/Xcursor/Xcursor.h>
|
||||||
|
|
||||||
#include "backends/x11/meta-backend-x11.h"
|
#include "backends/x11/meta-backend-x11.h"
|
||||||
|
|
||||||
struct _MetaCursorRendererX11Nested
|
struct _MetaCursorRendererX11Nested
|
||||||
|
Loading…
Reference in New Issue
Block a user