[Spice-devel] server/red_dispatcher: fix wrong resolution set for tablet

Submitted by Alon Levy on July 31, 2011, 8:38 p.m.

Details

Message ID 1312119508-11207-1-git-send-email-alevy@redhat.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy July 31, 2011, 8:38 p.m.
when changing resolutions due to the new async code paths the surface
creation command was kept by reference, and later, when the red_worker
signaled completion by calling async_complete the mouse mode was updated
using the reference. This caused the wrong values to be read resulting in wrong
resolutions set and a non working mouse pointer. Fix this by keeping a copy of
the surface creation command instead of a reference.

No bz. Found in testing.
---
 server/red_dispatcher.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 7792d90..aa4bdf8 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -56,7 +56,7 @@  struct RedDispatcher {
     RedDispatcher *next;
     RedWorkerMessage async_message;
     pthread_mutex_t  async_lock;
-    QXLDevSurfaceCreate *surface_create;
+    QXLDevSurfaceCreate surface_create;
 };
 
 typedef struct RedWorkeState {
@@ -207,6 +207,7 @@  static void update_client_mouse_allowed(void)
 
     if (allow_now || allow_now != allowed) {
         allowed = allow_now;
+        printf("setting mouse allowed to %d, %d\n", x_res, y_res);
         reds_set_client_mouse_allowed(allowed, x_res, y_res);
     }
 }
@@ -382,7 +383,7 @@  static void qxl_worker_destroy_primary_surface(QXLWorker *qxl_worker, uint32_t s
 
 static void red_dispatcher_create_primary_surface_complete(RedDispatcher *dispatcher)
 {
-    QXLDevSurfaceCreate *surface = dispatcher->surface_create;
+    QXLDevSurfaceCreate *surface = &dispatcher->surface_create;
 
     dispatcher->x_res = surface->width;
     dispatcher->y_res = surface->height;
@@ -390,7 +391,9 @@  static void red_dispatcher_create_primary_surface_complete(RedDispatcher *dispat
     dispatcher->primary_active = TRUE;
 
     update_client_mouse_allowed();
-    dispatcher->surface_create = NULL;
+    dispatcher->surface_create.width = 0;
+    dispatcher->surface_create.height = 0;
+    dispatcher->surface_create.mouse_mode = 0;
 }
 
 static void
@@ -408,7 +411,7 @@  red_dispatcher_create_primary_surface(RedDispatcher *dispatcher, uint32_t surfac
     } else {
         message = RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE;
     }
-    dispatcher->surface_create = surface;
+    dispatcher->surface_create = *surface;
 
     write_message(dispatcher->channel, &message);
     if (async) {