[Spice-devel] [PATCH spice-gtk v2 2/3] Deprecate "cursor-set" signal
Pavel Grunt
pgrunt at redhat.com
Tue May 23 14:56:25 UTC 2017
Use cursor notify instead
Related:
https://bugzilla.redhat.com/show_bug.cgi?id=1411380
---
src/channel-cursor.c | 4 +++-
src/spice-widget.c | 31 +++++++++++++++++--------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/channel-cursor.c b/src/channel-cursor.c
index 53b1ecf..cddba03 100644
--- a/src/channel-cursor.c
+++ b/src/channel-cursor.c
@@ -208,11 +208,13 @@ static void spice_cursor_channel_class_init(SpiceCursorChannelClass *klass)
*
* The #SpiceCursorChannel::cursor-set signal is emitted to modify
* cursor aspect and position on the display area.
+ *
+ * Deprecated: 0.34: Use #SpiceCursorChannel:cursor notify instead.
**/
signals[SPICE_CURSOR_SET] =
g_signal_new("cursor-set",
G_OBJECT_CLASS_TYPE(gobject_class),
- G_SIGNAL_RUN_FIRST,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_DEPRECATED,
G_STRUCT_OFFSET(SpiceCursorChannelClass, cursor_set),
NULL, NULL,
g_cclosure_user_marshal_VOID__INT_INT_INT_INT_POINTER,
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 8203d55..b1c8ab1 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2635,29 +2635,32 @@ static void mark(SpiceDisplay *display, gint mark)
}
static void cursor_set(SpiceCursorChannel *channel,
- gint width, gint height, gint hot_x, gint hot_y,
- gpointer rgba, gpointer data)
+ G_GNUC_UNUSED GParamSpec *pspec,
+ gpointer data)
{
SpiceDisplay *display = data;
SpiceDisplayPrivate *d = display->priv;
GdkCursor *cursor = NULL;
+ SpiceCursorShape *cursor_shape = NULL;
cursor_invalidate(display);
- g_clear_object(&d->mouse_pixbuf);
-
- if (rgba != NULL) {
- d->mouse_pixbuf = gdk_pixbuf_new_from_data(g_memdup(rgba, width * height * 4),
+ g_object_get(G_OBJECT(channel), "cursor", &cursor_shape, NULL);
+ if (cursor_shape != NULL && cursor_shape->data != NULL) {
+ g_clear_object(&d->mouse_pixbuf);
+ d->mouse_pixbuf = gdk_pixbuf_new_from_data(cursor_shape->data,
GDK_COLORSPACE_RGB,
TRUE, 8,
- width,
- height,
- width * 4,
- (GdkPixbufDestroyNotify)g_free, NULL);
- d->mouse_hotspot.x = hot_x;
- d->mouse_hotspot.y = hot_y;
+ cursor_shape->width,
+ cursor_shape->height,
+ cursor_shape->width * 4,
+ NULL, NULL);
+ d->mouse_hotspot.x = cursor_shape->hot_spot_x;
+ d->mouse_hotspot.y = cursor_shape->hot_spot_y;
cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(GTK_WIDGET(display)),
- d->mouse_pixbuf, hot_x, hot_y);
+ d->mouse_pixbuf,
+ d->mouse_hotspot.x,
+ d->mouse_hotspot.y);
} else
g_warn_if_reached();
@@ -2958,7 +2961,7 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
if (id != d->channel_id)
return;
d->cursor = SPICE_CURSOR_CHANNEL(channel);
- spice_g_signal_connect_object(channel, "cursor-set",
+ spice_g_signal_connect_object(channel, "notify::cursor",
G_CALLBACK(cursor_set), display, 0);
spice_g_signal_connect_object(channel, "cursor-move",
G_CALLBACK(cursor_move), display, 0);
--
2.13.0
More information about the Spice-devel
mailing list