wayland: Add wl_surface backed cursor sprite implementation

This removes the last use of the non-abstract form of MetaCursorSprite
usage.

https://gitlab.gnome.org/GNOME/mutter/issues/77
This commit is contained in:
Jonas Ådahl 2018-04-30 12:03:31 +02:00
parent b7e9388906
commit 817c8e568c
6 changed files with 105 additions and 14 deletions

View File

@ -374,6 +374,8 @@ if HAVE_WAYLAND
libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
compositor/meta-surface-actor-wayland.c \
compositor/meta-surface-actor-wayland.h \
wayland/meta-cursor-sprite-wayland.c \
wayland/meta-cursor-sprite-wayland.h \
wayland/meta-wayland.c \
wayland/meta-wayland.h \
wayland/meta-wayland-private.h \

View File

@ -46,7 +46,9 @@ typedef struct _MetaCursorSpritePrivate
int hot_x, hot_y;
} MetaCursorSpritePrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaCursorSprite, meta_cursor_sprite, G_TYPE_OBJECT)
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCursorSprite,
meta_cursor_sprite,
G_TYPE_OBJECT)
gboolean
meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
@ -71,12 +73,6 @@ meta_cursor_sprite_get_current_frame_time (MetaCursorSprite *sprite)
return META_CURSOR_SPRITE_GET_CLASS (sprite)->get_current_frame_time (sprite);
}
MetaCursorSprite *
meta_cursor_sprite_new (void)
{
return g_object_new (META_TYPE_CURSOR_SPRITE, NULL);
}
void
meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
{

View File

@ -41,8 +41,6 @@ struct _MetaCursorSpriteClass
unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
};
MetaCursorSprite * meta_cursor_sprite_new (void);
void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
int x,
int y);

View File

@ -0,0 +1,62 @@
/*
* Copyright 2015, 2018 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "wayland/meta-cursor-sprite-wayland.h"
struct _MetaCursorSpriteWayland
{
MetaCursorSprite parent;
};
G_DEFINE_TYPE (MetaCursorSpriteWayland,
meta_cursor_sprite_wayland,
META_TYPE_CURSOR_SPRITE)
static void
meta_cursor_sprite_wayland_realize_texture (MetaCursorSprite *sprite)
{
}
static gboolean
meta_cursor_sprite_wayland_is_animated (MetaCursorSprite *sprite)
{
return FALSE;
}
MetaCursorSpriteWayland *
meta_cursor_sprite_wayland_new (void)
{
return g_object_new (META_TYPE_CURSOR_SPRITE_WAYLAND, NULL);
}
static void
meta_cursor_sprite_wayland_init (MetaCursorSpriteWayland *sprite_wayland)
{
}
static void
meta_cursor_sprite_wayland_class_init (MetaCursorSpriteWaylandClass *klass)
{
MetaCursorSpriteClass *cursor_sprite_class = META_CURSOR_SPRITE_CLASS (klass);
cursor_sprite_class->realize_texture =
meta_cursor_sprite_wayland_realize_texture;
cursor_sprite_class->is_animated = meta_cursor_sprite_wayland_is_animated;
}

View File

@ -0,0 +1,32 @@
/*
* Copyright 2013, 2018 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef META_CURSOR_SPRITE_WAYLAND_H
#define META_CURSOR_SPRITE_WAYLAND_H
#include <glib-object.h>
#include "backends/meta-cursor.h"
#define META_TYPE_CURSOR_SPRITE_WAYLAND meta_cursor_sprite_wayland_get_type ()
G_DECLARE_FINAL_TYPE (MetaCursorSpriteWayland, meta_cursor_sprite_wayland,
META, CURSOR_SPRITE_WAYLAND, MetaCursorSprite)
MetaCursorSpriteWayland * meta_cursor_sprite_wayland_new (void);
#endif /* META_CURSOR_SPRITE_WAYLAND_H */

View File

@ -31,6 +31,7 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-logical-monitor.h"
#include "core/boxes-private.h"
#include "wayland/meta-cursor-sprite-wayland.h"
typedef struct _MetaWaylandCursorSurfacePrivate MetaWaylandCursorSurfacePrivate;
@ -38,7 +39,7 @@ struct _MetaWaylandCursorSurfacePrivate
{
int hot_x;
int hot_y;
MetaCursorSprite *cursor_sprite;
MetaCursorSpriteWayland *cursor_sprite;
MetaCursorRenderer *cursor_renderer;
MetaWaylandBuffer *buffer;
struct wl_list frame_callbacks;
@ -57,7 +58,7 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (cursor_surface));
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
MetaCursorSprite *cursor_sprite = priv->cursor_sprite;
MetaCursorSprite *cursor_sprite = META_CURSOR_SPRITE (priv->cursor_sprite);
g_return_if_fail (!buffer || buffer->texture);
@ -267,7 +268,7 @@ meta_wayland_cursor_surface_init (MetaWaylandCursorSurface *role)
MetaWaylandCursorSurfacePrivate *priv =
meta_wayland_cursor_surface_get_instance_private (role);
priv->cursor_sprite = meta_cursor_sprite_new ();
priv->cursor_sprite = meta_cursor_sprite_wayland_new ();
g_signal_connect_object (priv->cursor_sprite,
"prepare-at",
G_CALLBACK (cursor_sprite_prepare_at),
@ -299,7 +300,7 @@ meta_wayland_cursor_surface_get_sprite (MetaWaylandCursorSurface *cursor_surface
MetaWaylandCursorSurfacePrivate *priv =
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
return priv->cursor_sprite;
return META_CURSOR_SPRITE (priv->cursor_sprite);
}
void
@ -342,7 +343,7 @@ on_cursor_painted (MetaCursorRenderer *renderer,
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
guint32 time = (guint32) (g_get_monotonic_time () / 1000);
if (displayed_sprite != priv->cursor_sprite)
if (displayed_sprite != META_CURSOR_SPRITE (priv->cursor_sprite))
return;
while (!wl_list_empty (&priv->frame_callbacks))