Patchwork [Spice-devel] Problem to render cursor in SDL/VNC using QXL driver

login
register
mail settings
Submitter Fabiano Fidêncio
Date Feb. 22, 2012, 4:53 a.m.
Message ID <CAK9pz9Le5Wsq6my4E79TbgNOHwr+dk0BbfJP9qMd0jo3WQshtQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/9198/
State New
Headers show

Comments

Fabiano Fidêncio - Feb. 22, 2012, 4:53 a.m.
Howdy!

I found out the problem. It was a regression introduced by commit
075360945860ad9bdd491921954b383bf762b0e5, in QEMU (almost had a
birthday).
There's one attached patch, that reverts the problematic commit and
fixes the conflicts. So, could you take a look and apply?

Best Regards,
--
Fabiano Fidêncio
David Jaša - Feb. 22, 2012, 1:03 p.m.
Fabiano Fidêncio píše v St 22. 02. 2012 v 02:53 -0200:
> Howdy!
> 
> I found out the problem. It was a regression introduced by commit
> 075360945860ad9bdd491921954b383bf762b0e5, in QEMU (almost had a
> birthday).
> There's one attached patch, that reverts the problematic commit and
> fixes the conflicts. So, could you take a look and apply?
> 

Hi Fabiano,

I guess that you should send the patch to qemu-devel@nongnu.org and only
CC this list in order to get it pushed to qemu.

David

> Best Regards,
> --
> Fabiano Fidêncio
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Patch

From 503679f3e1bab80e1bbb465d5b3532fe2aae3c4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?=
 <Fabiano.Fidencio@fit-tecnologia.org.br>
Date: Wed, 22 Feb 2012 01:56:03 -0200
Subject: [PATCH] Revert "spice: don't call displaystate callbacks from spice
 server context."

    This reverts commit 075360945860ad9bdd491921954b383bf762b0e5, that
    introduce a bug in SDL/VNC, where cursor is not being rendered.

    This bug occurs because cursor_define() and mouse_set() callbacks are
    being called only locally, in spice-display.c
    So, until we find out a good solution for all displaystates, let's
    revert it.
---
 hw/qxl-render.c    |   25 +++++++++++++------------
 ui/spice-display.c |   12 ------------
 ui/spice-display.h |    3 ---
 3 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index 133d093..d34ec8b 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -197,6 +197,7 @@  void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
     QXLCursorCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
     QXLCursor *cursor;
     QEMUCursor *c;
+    int x = -1, y = -1;
 
     if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
         return;
@@ -209,6 +210,8 @@  void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
     }
     switch (cmd->type) {
     case QXL_CURSOR_SET:
+        x = cmd->u.set.position.x;
+        y = cmd->u.set.position.y;
         cursor = qxl_phys2virt(qxl, cmd->u.set.shape, ext->group_id);
         if (cursor->chunk.data_size != cursor->data_size) {
             fprintf(stderr, "%s: multiple chunks\n", __FUNCTION__);
@@ -218,20 +221,18 @@  void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
         if (c == NULL) {
             c = cursor_builtin_left_ptr();
         }
-        qemu_mutex_lock(&qxl->ssd.lock);
-        if (qxl->ssd.cursor) {
-            cursor_put(qxl->ssd.cursor);
-        }
-        qxl->ssd.cursor = c;
-        qxl->ssd.mouse_x = cmd->u.set.position.x;
-        qxl->ssd.mouse_y = cmd->u.set.position.y;
-        qemu_mutex_unlock(&qxl->ssd.lock);
+        qemu_mutex_lock_iothread();
+        qxl->ssd.ds->cursor_define(c);
+        qxl->ssd.ds->mouse_set(x, y, 1);
+        qemu_mutex_unlock_iothread();
+        cursor_put(c);
         break;
     case QXL_CURSOR_MOVE:
-        qemu_mutex_lock(&qxl->ssd.lock);
-        qxl->ssd.mouse_x = cmd->u.position.x;
-        qxl->ssd.mouse_y = cmd->u.position.y;
-        qemu_mutex_unlock(&qxl->ssd.lock);
+        x = cmd->u.position.x;
+        y = cmd->u.position.y;
+        qemu_mutex_lock_iothread();
+        qxl->ssd.ds->mouse_set(x, y, 1);
+        qemu_mutex_unlock_iothread();
         break;
     }
 }
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 6c302a3..a99328f 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -271,8 +271,6 @@  void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
 {
     ssd->ds = ds;
     qemu_mutex_init(&ssd->lock);
-    ssd->mouse_x = -1;
-    ssd->mouse_y = -1;
     ssd->bufsize = (16 * 1024 * 1024);
     ssd->buf = g_malloc(ssd->bufsize);
 }
@@ -327,16 +325,6 @@  void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
         ssd->update = qemu_spice_create_update(ssd);
         ssd->notify++;
     }
-    if (ssd->cursor) {
-        ssd->ds->cursor_define(ssd->cursor);
-        cursor_put(ssd->cursor);
-        ssd->cursor = NULL;
-    }
-    if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
-        ssd->ds->mouse_set(ssd->mouse_x, ssd->mouse_y, 1);
-        ssd->mouse_x = -1;
-        ssd->mouse_y = -1;
-    }
     qemu_mutex_unlock(&ssd->lock);
 
     if (ssd->notify) {
diff --git a/ui/spice-display.h b/ui/spice-display.h
index 5e52df9..2f95005 100644
--- a/ui/spice-display.h
+++ b/ui/spice-display.h
@@ -20,7 +20,6 @@ 
 #include <spice/qxl_dev.h>
 
 #include "qemu-thread.h"
-#include "console.h"
 #include "pflib.h"
 #include "sysemu.h"
 
@@ -71,8 +70,6 @@  struct SimpleSpiceDisplay {
      */
     QemuMutex lock;
     SimpleSpiceUpdate *update;
-    QEMUCursor *cursor;
-    int mouse_x, mouse_y;
 };
 
 struct SimpleSpiceUpdate {
-- 
1.7.7.6