cae5cd0
From 3e7f2a287d21b57b167d3d49fa3d8640ffcf2d60 Mon Sep 17 00:00:00 2001
cae5cd0
From: Hans de Goede <hdegoede@redhat.com>
cae5cd0
Date: Thu, 22 Sep 2011 14:32:53 +0200
cae5cd0
Subject: [linux-vdagent PATCH 02/13] Change VDAGENTD_GUEST_XORG_RESOLUTION
cae5cd0
 message to work with multiple monitors
cae5cd0
cae5cd0
And also bump the version (a bit early in the cycle), since this breaks
cae5cd0
protocol compatibility between the system level agentd daemon and the per
cae5cd0
session agent process.
cae5cd0
cae5cd0
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
cae5cd0
---
cae5cd0
 configure.ac         |    2 +-
cae5cd0
 src/vdagent-x11.c    |    9 ++-------
cae5cd0
 src/vdagentd-proto.h |    6 +++++-
cae5cd0
 src/vdagentd.c       |   16 +++++++++++++---
cae5cd0
 4 files changed, 21 insertions(+), 12 deletions(-)
cae5cd0
cae5cd0
diff --git a/configure.ac b/configure.ac
cae5cd0
index 9ed8407..c23d7f2 100644
cae5cd0
--- a/configure.ac
cae5cd0
+++ b/configure.ac
cae5cd0
@@ -1,5 +1,5 @@
cae5cd0
 AC_PREREQ(2.65)
cae5cd0
-AC_INIT([spice-vdagent], [0.8.1])
cae5cd0
+AC_INIT([spice-vdagent], [0.8.2])
cae5cd0
 AC_CONFIG_SRCDIR([configure.ac])
cae5cd0
 
cae5cd0
 AM_CONFIG_HEADER([src/config.h])
cae5cd0
diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c
cae5cd0
index 795ed41..b01b5ab 100644
cae5cd0
--- a/src/vdagent-x11.c
cae5cd0
+++ b/src/vdagent-x11.c
cae5cd0
@@ -564,13 +564,8 @@ void vdagent_x11_do_read(struct vdagent_x11 *x11)
cae5cd0
 
cae5cd0
 static void vdagent_x11_send_daemon_guest_xorg_res(struct vdagent_x11 *x11)
cae5cd0
 {
cae5cd0
-    struct vdagentd_guest_xorg_resolution res;
cae5cd0
-
cae5cd0
-    res.width  = x11->width;
cae5cd0
-    res.height = x11->height;
cae5cd0
-
cae5cd0
-    udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, 0, 0,
cae5cd0
-                (uint8_t *)&res, sizeof(res));
cae5cd0
+    udscs_write(x11->vdagentd, VDAGENTD_GUEST_XORG_RESOLUTION, x11->width,
cae5cd0
+                x11->height, NULL, 0);
cae5cd0
 }
cae5cd0
 
cae5cd0
 static const char *vdagent_x11_get_atom_name(struct vdagent_x11 *x11, Atom a)
cae5cd0
diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
cae5cd0
index 9d96540..08279a3 100644
cae5cd0
--- a/src/vdagentd-proto.h
cae5cd0
+++ b/src/vdagentd-proto.h
cae5cd0
@@ -26,7 +26,9 @@
cae5cd0
 #define VDAGENTD_SOCKET "/var/run/spice-vdagentd/spice-vdagent-sock"
cae5cd0
 
cae5cd0
 enum {
cae5cd0
-    VDAGENTD_GUEST_XORG_RESOLUTION, /* client -> daemon */
cae5cd0
+    VDAGENTD_GUEST_XORG_RESOLUTION, /* client -> daemon, arg1: overall width,
cae5cd0
+                                       arg2: overall height, data: array of
cae5cd0
+                                       vdagentd_guest_xorg_resolution */
cae5cd0
     VDAGENTD_MONITORS_CONFIG, /* daemon -> client, VDAgentMonitorsConfig
cae5cd0
                                  followed by num_monitors VDAgentMonConfig-s */
cae5cd0
     VDAGENTD_CLIPBOARD_GRAB,    /* arg1: sel, data: array of supported types */
cae5cd0
@@ -40,6 +42,8 @@ enum {
cae5cd0
 struct vdagentd_guest_xorg_resolution {
cae5cd0
     int width;
cae5cd0
     int height;
cae5cd0
+    int x;
cae5cd0
+    int y;
cae5cd0
 };
cae5cd0
 
cae5cd0
 #endif
cae5cd0
diff --git a/src/vdagentd.c b/src/vdagentd.c
cae5cd0
index 291e4e3..18d7950 100644
cae5cd0
--- a/src/vdagentd.c
cae5cd0
+++ b/src/vdagentd.c
cae5cd0
@@ -554,8 +554,18 @@ void agent_read_complete(struct udscs_connection **connp,
cae5cd0
     case VDAGENTD_GUEST_XORG_RESOLUTION: {
cae5cd0
         struct vdagentd_guest_xorg_resolution *res =
cae5cd0
             (struct vdagentd_guest_xorg_resolution *)data;
cae5cd0
+        int n = header->size / sizeof(*res);
cae5cd0
 
cae5cd0
-        if (header->size != sizeof(*res)) {
cae5cd0
+        /* Detect older version session agent, but don't disconnect, as
cae5cd0
+           that stops it from getting the VDAGENTD_VERSION message, and then
cae5cd0
+           it will never re-exec the new version... */
cae5cd0
+        if (header->arg1 == 0 && header->arg2 == 0) {
cae5cd0
+            fprintf(logfile, "got old session agent xorg resolution message, ignoring\n");
cae5cd0
+            free(data);
cae5cd0
+            return;
cae5cd0
+        }
cae5cd0
+
cae5cd0
+        if (header->size != n * sizeof(*res)) {
cae5cd0
             fprintf(logfile,
cae5cd0
                     "guest xorg resolution message has wrong size, disconnecting agent\n");
cae5cd0
             udscs_destroy_connection(connp);
cae5cd0
@@ -563,8 +573,8 @@ void agent_read_complete(struct udscs_connection **connp,
cae5cd0
             return;
cae5cd0
         }
cae5cd0
 
cae5cd0
-        agent_data->width  = res->width;
cae5cd0
-        agent_data->height = res->height;
cae5cd0
+        agent_data->width  = header->arg1;
cae5cd0
+        agent_data->height = header->arg2;
cae5cd0
         check_xorg_resolution();
cae5cd0
         break;
cae5cd0
     }
cae5cd0
-- 
cae5cd0
1.7.7.4
cae5cd0