[Spice-devel] [PATCH spice-server v3] gl: fix client mouse mode
Frediano Ziglio
fziglio at redhat.com
Wed Oct 4 08:50:35 UTC 2017
Since 2.8, QEMU no longer creates QXL primary surfaces when using GL.
This change broke client-side mouse mode, because Spice server relies on
having a primary surface.
When GL is enabled, use GL scanout informations.
Mouse mode is always client when GL surfaces are used.
This patch and most of the message are based on a patch from
Marc-André Lureau, just moving responsibility from reds to RedQxl.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-qxl.c | 31 +++++++++++++++++++++----------
server/red-qxl.h | 3 +--
server/reds.c | 3 +--
3 files changed, 23 insertions(+), 14 deletions(-)
Changes since v2:
- call reds_update_client_mouse_allowed from spice_qxl_gl_scanout;
- fix some typos;
- update a comment in code.
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 7dc13bbdc..336bb2e68 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -841,6 +841,8 @@ void spice_qxl_gl_scanout(QXLInstance *qxl,
/* FIXME: find a way to coallesce all pending SCANOUTs */
dispatcher_send_message(qxl_state->dispatcher,
RED_WORKER_MESSAGE_GL_SCANOUT, &payload);
+
+ reds_update_client_mouse_allowed(qxl_state->reds);
}
SPICE_GNUC_VISIBLE
@@ -964,20 +966,29 @@ void red_qxl_clear_pending(QXLState *qxl_state, int pending)
clear_bit(pending, &qxl_state->pending);
}
-gboolean red_qxl_get_primary_active(QXLInstance *qxl)
+bool red_qxl_get_allow_client_mouse(QXLInstance *qxl, int *x_res, int *y_res, int *allow_now)
{
- return qxl->st->primary_active;
-}
+ // try to get resolution when 3D enabled, since qemu did not create QXL primary surface
+ SpiceMsgDisplayGlScanoutUnix *gl;
+ if ((gl = red_qxl_get_gl_scanout(qxl))) {
+ *x_res = gl->width;
+ *y_res = gl->height;
+ *allow_now = TRUE;
+ red_qxl_put_gl_scanout(qxl, gl);
+ return true;
+ }
+
+ // check for 2D
+ if (!qxl->st->primary_active) {
+ return false;
+ }
-gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint *y_res)
-{
if (qxl->st->use_hardware_cursor) {
- if (x_res)
- *x_res = qxl->st->x_res;
- if (y_res)
- *y_res = qxl->st->y_res;
+ *x_res = qxl->st->x_res;
+ *y_res = qxl->st->y_res;
}
- return qxl->st->use_hardware_cursor;
+ *allow_now = qxl->st->use_hardware_cursor;
+ return true;
}
void red_qxl_on_ic_change(QXLInstance *qxl, SpiceImageCompression ic)
diff --git a/server/red-qxl.h b/server/red-qxl.h
index 51ec14562..6014d32a1 100644
--- a/server/red-qxl.h
+++ b/server/red-qxl.h
@@ -34,8 +34,7 @@ void red_qxl_stop(QXLInstance *qxl);
void red_qxl_start(QXLInstance *qxl);
uint32_t red_qxl_get_ram_size(QXLInstance *qxl);
gboolean red_qxl_client_monitors_config(QXLInstance *qxl, VDAgentMonitorsConfig *monitors_config);
-gboolean red_qxl_get_primary_active(QXLInstance *qxl);
-gboolean red_qxl_get_allow_client_mouse(QXLInstance *qxl, gint *x_res, gint *y_res);
+bool red_qxl_get_allow_client_mouse(QXLInstance *qxl, int *x_res, int *y_res, int *allow_now);
SpiceMsgDisplayGlScanoutUnix *red_qxl_get_gl_scanout(QXLInstance *qxl);
void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scanout);
void red_qxl_gl_draw_async_complete(QXLInstance *qxl);
diff --git a/server/reds.c b/server/reds.c
index ddc933524..12c33570a 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -4376,8 +4376,7 @@ void reds_update_client_mouse_allowed(RedsState *reds)
allow_now = TRUE;
FOREACH_QXL_INSTANCE(reds, qxl) {
- if (red_qxl_get_primary_active(qxl)) {
- allow_now = red_qxl_get_allow_client_mouse(qxl, &x_res, &y_res);
+ if (red_qxl_get_allow_client_mouse(qxl, &x_res, &y_res, &allow_now)) {
break;
}
}
--
2.13.6
More information about the Spice-devel
mailing list