A few Spice cursor fixes for non-QXL
cover A few Spice cursor fixes for non-QXL
Hi
Since 5643fc0, qemu learned to set Spice cursor when using non-QXL card, this is a few improvements:
Marc-André Lureau (3):
spice: fix mouse cursor position
spice: set pointer position on hotspot
spice: learn to hide cursor
include/ui/spice-display.h | 3 ++- ui/spice-display.c | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/3 spice: fix mouse cursor position
--- ui/spice-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/spice-display.c +1 -1
@@ -717,7 +717,7 @@ static void display_mouse_set(DisplayChangeListener *dcl,qemu_mutex_lock (&ssd->lock); ssd->ptr_x = x; - ssd->ptr_y = x; + ssd->ptr_y = y;if (ssd->ptr_move) {g_free (ssd->ptr_move); }
Signature · 1 line
2.1.0
PATCH 2/3 spice: set pointer position on hotspot
In reply to Marc-André LureauThe Spice protocol uses cursor position on hotspot: the client is applying hotspot offset when drawing the cursor.
--- include/ui/spice-display.h | 3 ++- ui/spice-display.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
include/ui/spice-display.h +2 -1
@@ -97,7 +97,8 @@ struct SimpleSpiceDisplay {/* cursor (without qxl): displaychangelistener -> spice server */ SimpleSpiceCursor *ptr_define;SimpleSpiceCursor *ptr_move; -uint16_t ptr_x, ptr_y; +int16_t ptr_x, ptr_y; +int16_t hot_x, hot_y;/* cursor (with qxl): qxl local renderer -> displaychangelistener */ QEMUCursor *cursor;
ui/spice-display.c +6 -4
@@ -284,8 +284,8 @@ qemu_spice_create_cursor_update(SimpleSpiceDisplay *ssd,if (c) { ccmd->type =QXL_CURSOR_SET ; - ccmd->u.set.position.x = ssd->ptr_x; - ccmd->u.set.position.y = ssd->ptr_y; + ccmd->u.set.position.x = ssd->ptr_x + ssd->hot_x; + ccmd->u.set.position.y = ssd->ptr_y + ssd->hot_y; ccmd->u.set.visible = true; ccmd->u.set.shape = (uintptr_t )cursor; cursor->header.unique = ssd->unique++;
@@ -299,8 +299,8 @@ qemu_spice_create_cursor_update(SimpleSpiceDisplay *ssd,memcpy (cursor->chunk.data, c->data, size); }else { ccmd->type =QXL_CURSOR_MOVE ; - ccmd->u.position.x = ssd->ptr_x; - ccmd->u.position.y = ssd->ptr_y; + ccmd->u.position.x = ssd->ptr_x + ssd->hot_x; + ccmd->u.position.y = ssd->ptr_y + ssd->hot_y; } ccmd->release_info.id = (uintptr_t )(&update->ext);
@@ -731,6 +731,8 @@ static void display_mouse_define(DisplayChangeListener *dcl,SimpleSpiceDisplay *ssd =container_of (dcl, SimpleSpiceDisplay, dcl);qemu_mutex_lock (&ssd->lock); + ssd->hot_x = c->hot_x; + ssd->hot_y = c->hot_y;if (ssd->ptr_move) {g_free (ssd->ptr_move); ssd->ptr_move =NULL ;
Signature · 1 line
2.1.0
PATCH 3/3 spice: learn to hide cursor
In reply to Marc-André Lureau--- ui/spice-display.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
ui/spice-display.c +6 -3
@@ -269,7 +269,8 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)static SimpleSpiceCursor *qemu_spice_create_cursor_update (SimpleSpiceDisplay *ssd, -QEMUCursor *c) +QEMUCursor *c, +int on) {size_t size = c ? c->width * c->height *4 :0 ;SimpleSpiceCursor *update;
@@ -297,6 +298,8 @@ qemu_spice_create_cursor_update(SimpleSpiceDisplay *ssd, cursor->data_size = size; cursor->chunk.data_size = size;memcpy (cursor->chunk.data, c->data, size); + }else if (!on) { + ccmd->type =QXL_CURSOR_HIDE ; }else { ccmd->type =QXL_CURSOR_MOVE ; ccmd->u.position.x = ssd->ptr_x + ssd->hot_x;
@@ -721,7 +724,7 @@ static void display_mouse_set(DisplayChangeListener *dcl,if (ssd->ptr_move) {g_free (ssd->ptr_move); } - ssd->ptr_move =qemu_spice_create_cursor_update (ssd,NULL ); + ssd->ptr_move =qemu_spice_create_cursor_update (ssd,NULL , on);qemu_mutex_unlock (&ssd->lock); }
@@ -740,7 +743,7 @@ static void display_mouse_define(DisplayChangeListener *dcl,if (ssd->ptr_define) {g_free (ssd->ptr_define); } - ssd->ptr_define =qemu_spice_create_cursor_update (ssd, c); + ssd->ptr_define =qemu_spice_create_cursor_update (ssd, c,0 );qemu_mutex_unlock (&ssd->lock); }
Signature · 1 line
2.1.0