mirror of
https://github.com/brl/mutter.git
synced 2025-02-19 14:44:10 +00:00
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:
parent
b7e9388906
commit
817c8e568c
@ -374,6 +374,8 @@ if HAVE_WAYLAND
|
|||||||
libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
|
libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
|
||||||
compositor/meta-surface-actor-wayland.c \
|
compositor/meta-surface-actor-wayland.c \
|
||||||
compositor/meta-surface-actor-wayland.h \
|
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.c \
|
||||||
wayland/meta-wayland.h \
|
wayland/meta-wayland.h \
|
||||||
wayland/meta-wayland-private.h \
|
wayland/meta-wayland-private.h \
|
||||||
|
@ -46,7 +46,9 @@ typedef struct _MetaCursorSpritePrivate
|
|||||||
int hot_x, hot_y;
|
int hot_x, hot_y;
|
||||||
} MetaCursorSpritePrivate;
|
} 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
|
gboolean
|
||||||
meta_cursor_sprite_is_animated (MetaCursorSprite *sprite)
|
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);
|
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
|
void
|
||||||
meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
|
meta_cursor_sprite_clear_texture (MetaCursorSprite *sprite)
|
||||||
{
|
{
|
||||||
|
@ -41,8 +41,6 @@ struct _MetaCursorSpriteClass
|
|||||||
unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
|
unsigned int (* get_current_frame_time) (MetaCursorSprite *sprite);
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaCursorSprite * meta_cursor_sprite_new (void);
|
|
||||||
|
|
||||||
void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
|
void meta_cursor_sprite_prepare_at (MetaCursorSprite *sprite,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
62
src/wayland/meta-cursor-sprite-wayland.c
Normal file
62
src/wayland/meta-cursor-sprite-wayland.c
Normal 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;
|
||||||
|
}
|
32
src/wayland/meta-cursor-sprite-wayland.h
Normal file
32
src/wayland/meta-cursor-sprite-wayland.h
Normal 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 */
|
@ -31,6 +31,7 @@
|
|||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-logical-monitor.h"
|
#include "backends/meta-logical-monitor.h"
|
||||||
#include "core/boxes-private.h"
|
#include "core/boxes-private.h"
|
||||||
|
#include "wayland/meta-cursor-sprite-wayland.h"
|
||||||
|
|
||||||
typedef struct _MetaWaylandCursorSurfacePrivate MetaWaylandCursorSurfacePrivate;
|
typedef struct _MetaWaylandCursorSurfacePrivate MetaWaylandCursorSurfacePrivate;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ struct _MetaWaylandCursorSurfacePrivate
|
|||||||
{
|
{
|
||||||
int hot_x;
|
int hot_x;
|
||||||
int hot_y;
|
int hot_y;
|
||||||
MetaCursorSprite *cursor_sprite;
|
MetaCursorSpriteWayland *cursor_sprite;
|
||||||
MetaCursorRenderer *cursor_renderer;
|
MetaCursorRenderer *cursor_renderer;
|
||||||
MetaWaylandBuffer *buffer;
|
MetaWaylandBuffer *buffer;
|
||||||
struct wl_list frame_callbacks;
|
struct wl_list frame_callbacks;
|
||||||
@ -57,7 +58,7 @@ update_cursor_sprite_texture (MetaWaylandCursorSurface *cursor_surface)
|
|||||||
MetaWaylandSurface *surface =
|
MetaWaylandSurface *surface =
|
||||||
meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (cursor_surface));
|
meta_wayland_surface_role_get_surface (META_WAYLAND_SURFACE_ROLE (cursor_surface));
|
||||||
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (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);
|
g_return_if_fail (!buffer || buffer->texture);
|
||||||
|
|
||||||
@ -267,7 +268,7 @@ meta_wayland_cursor_surface_init (MetaWaylandCursorSurface *role)
|
|||||||
MetaWaylandCursorSurfacePrivate *priv =
|
MetaWaylandCursorSurfacePrivate *priv =
|
||||||
meta_wayland_cursor_surface_get_instance_private (role);
|
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,
|
g_signal_connect_object (priv->cursor_sprite,
|
||||||
"prepare-at",
|
"prepare-at",
|
||||||
G_CALLBACK (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 =
|
MetaWaylandCursorSurfacePrivate *priv =
|
||||||
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
|
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
|
||||||
|
|
||||||
return priv->cursor_sprite;
|
return META_CURSOR_SPRITE (priv->cursor_sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -342,7 +343,7 @@ on_cursor_painted (MetaCursorRenderer *renderer,
|
|||||||
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
|
meta_wayland_cursor_surface_get_instance_private (cursor_surface);
|
||||||
guint32 time = (guint32) (g_get_monotonic_time () / 1000);
|
guint32 time = (guint32) (g_get_monotonic_time () / 1000);
|
||||||
|
|
||||||
if (displayed_sprite != priv->cursor_sprite)
|
if (displayed_sprite != META_CURSOR_SPRITE (priv->cursor_sprite))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!wl_list_empty (&priv->frame_callbacks))
|
while (!wl_list_empty (&priv->frame_callbacks))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user