f8dc431
From: Gerd Hoffmann <kraxel@redhat.com>
f8dc431
Date: Wed, 3 Feb 2016 13:55:00 +0100
f8dc431
Subject: [PATCH] spice/gl: add & use qemu_spice_gl_monitor_config
f8dc431
MIME-Version: 1.0
f8dc431
Content-Type: text/plain; charset=UTF-8
f8dc431
Content-Transfer-Encoding: 8bit
f8dc431
f8dc431
Cc: qemu-stable@nongnu.org
f8dc431
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
f8dc431
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
f8dc431
(cherry picked from commit 39414ef4e93db9041e463a097084a407d0d374f0)
f8dc431
---
f8dc431
 include/ui/spice-display.h |  1 +
f8dc431
 ui/spice-display.c         | 30 ++++++++++++++++++++++++++++++
f8dc431
 2 files changed, 31 insertions(+)
f8dc431
f8dc431
diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h
f8dc431
index 00e4a0b..3c679e8 100644
f8dc431
--- a/include/ui/spice-display.h
f8dc431
+++ b/include/ui/spice-display.h
f8dc431
@@ -71,6 +71,7 @@ typedef struct QXLCookie {
f8dc431
             QXLRect area;
f8dc431
             int redraw;
f8dc431
         } render;
f8dc431
+        void *data;
f8dc431
     } u;
f8dc431
 } QXLCookie;
f8dc431
 
f8dc431
diff --git a/ui/spice-display.c b/ui/spice-display.c
f8dc431
index 242ab5f..2a77a54 100644
f8dc431
--- a/ui/spice-display.c
f8dc431
+++ b/ui/spice-display.c
f8dc431
@@ -660,6 +660,11 @@ static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
f8dc431
         qemu_bh_schedule(ssd->gl_unblock_bh);
f8dc431
         break;
f8dc431
     }
f8dc431
+    case QXL_COOKIE_TYPE_IO:
f8dc431
+        if (cookie->io == QXL_IO_MONITORS_CONFIG_ASYNC) {
f8dc431
+            g_free(cookie->u.data);
f8dc431
+        }
f8dc431
+        break;
f8dc431
 #endif
f8dc431
     default:
f8dc431
         /* should never be called, used in qxl native mode only */
f8dc431
@@ -795,6 +800,29 @@ static const DisplayChangeListenerOps display_listener_ops = {
f8dc431
 
f8dc431
 #ifdef HAVE_SPICE_GL
f8dc431
 
f8dc431
+static void qemu_spice_gl_monitor_config(SimpleSpiceDisplay *ssd,
f8dc431
+                                         int x, int y, int w, int h)
f8dc431
+{
f8dc431
+    QXLMonitorsConfig *config;
f8dc431
+    QXLCookie *cookie;
f8dc431
+
f8dc431
+    config = g_malloc0(sizeof(QXLMonitorsConfig) + sizeof(QXLHead));
f8dc431
+    config->count = 1;
f8dc431
+    config->max_allowed = 1;
f8dc431
+    config->heads[0].x = x;
f8dc431
+    config->heads[0].y = y;
f8dc431
+    config->heads[0].width = w;
f8dc431
+    config->heads[0].height = h;
f8dc431
+    cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
f8dc431
+                            QXL_IO_MONITORS_CONFIG_ASYNC);
f8dc431
+    cookie->u.data = config;
f8dc431
+
f8dc431
+    spice_qxl_monitors_config_async(&ssd->qxl,
f8dc431
+                                    (uintptr_t)config,
f8dc431
+                                    MEMSLOT_GROUP_HOST,
f8dc431
+                                    (uintptr_t)cookie);
f8dc431
+}
f8dc431
+
f8dc431
 static void qemu_spice_gl_block(SimpleSpiceDisplay *ssd, bool block)
f8dc431
 {
f8dc431
     uint64_t timeout;
f8dc431
@@ -858,6 +886,8 @@ static void qemu_spice_gl_scanout(DisplayChangeListener *dcl,
f8dc431
                          surface_width(ssd->ds),
f8dc431
                          surface_height(ssd->ds),
f8dc431
                          stride, fourcc, y_0_top);
f8dc431
+
f8dc431
+    qemu_spice_gl_monitor_config(ssd, x, y, w, h);
f8dc431
 }
f8dc431
 
f8dc431
 static void qemu_spice_gl_update(DisplayChangeListener *dcl,