5d360b
From bb6e65d667f1bbc28cfab0ba2626880cee8e7741 Mon Sep 17 00:00:00 2001
5d360b
From: "Daniel P. Berrange" <berrange@redhat.com>
5d360b
Date: Thu, 8 Feb 2018 17:50:33 +0100
5d360b
Subject: [PATCH 19/27] ui: introduce enum to track VNC client framebuffer
5d360b
 update request state
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Daniel P. Berrange <berrange@redhat.com>
5d360b
Message-id: <20180208175041.5634-20-berrange@redhat.com>
5d360b
Patchwork-id: 78953
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v1 19/27] ui: introduce enum to track VNC client framebuffer update request state
5d360b
Bugzilla: 1527405
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: "Daniel P. Berrange" <berrange@redhat.com>
5d360b
5d360b
Currently the VNC servers tracks whether a client has requested an incremental
5d360b
or forced update with two boolean flags. There are only really 3 distinct
5d360b
states to track, so create an enum to more accurately reflect permitted states.
5d360b
5d360b
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
5d360b
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
5d360b
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: 20171218191228.31018-7-berrange@redhat.com
5d360b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
(cherry picked from commit fef1bbadfb2c3027208eb3d14b43e1bdb51166ca)
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 ui/vnc.c | 21 +++++++++++----------
5d360b
 ui/vnc.h |  9 +++++++--
5d360b
 2 files changed, 18 insertions(+), 12 deletions(-)
5d360b
5d360b
diff --git a/ui/vnc.c b/ui/vnc.c
5d360b
index eea5702..7239602 100644
5d360b
--- a/ui/vnc.c
5d360b
+++ b/ui/vnc.c
5d360b
@@ -860,16 +860,17 @@ static int vnc_update_client(VncState *vs, int has_dirty)
5d360b
     }
5d360b
 
5d360b
     vs->has_dirty += has_dirty;
5d360b
-    if (!vs->need_update) {
5d360b
+    if (vs->update == VNC_STATE_UPDATE_NONE) {
5d360b
         return 0;
5d360b
     }
5d360b
 
5d360b
-    if (vs->output.offset && !vs->audio_cap && !vs->force_update) {
5d360b
+    if (vs->output.offset && !vs->audio_cap &&
5d360b
+        vs->update != VNC_STATE_UPDATE_FORCE) {
5d360b
         /* kernel send buffers are full -> drop frames to throttle */
5d360b
         return 0;
5d360b
     }
5d360b
 
5d360b
-    if (!vs->has_dirty && !vs->force_update) {
5d360b
+    if (!vs->has_dirty && vs->update != VNC_STATE_UPDATE_FORCE) {
5d360b
         return 0;
5d360b
     }
5d360b
 
5d360b
@@ -909,7 +910,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
5d360b
     }
5d360b
 
5d360b
     vnc_job_push(job);
5d360b
-    vs->force_update = 0;
5d360b
+    vs->update = VNC_STATE_UPDATE_INCREMENTAL;
5d360b
     vs->has_dirty = 0;
5d360b
     return n;
5d360b
 }
5d360b
@@ -1832,14 +1833,14 @@ static void ext_key_event(VncState *vs, int down,
5d360b
 static void framebuffer_update_request(VncState *vs, int incremental,
5d360b
                                        int x, int y, int w, int h)
5d360b
 {
5d360b
-    vs->need_update = 1;
5d360b
-
5d360b
     if (incremental) {
5d360b
-        return;
5d360b
+        if (vs->update != VNC_STATE_UPDATE_FORCE) {
5d360b
+            vs->update = VNC_STATE_UPDATE_INCREMENTAL;
5d360b
+        }
5d360b
+    } else {
5d360b
+        vs->update = VNC_STATE_UPDATE_FORCE;
5d360b
+        vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);
5d360b
     }
5d360b
-
5d360b
-    vs->force_update = 1;
5d360b
-    vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);
5d360b
 }
5d360b
 
5d360b
 static void send_ext_key_event_ack(VncState *vs)
5d360b
diff --git a/ui/vnc.h b/ui/vnc.h
5d360b
index d8465ba..f19fd0a 100644
5d360b
--- a/ui/vnc.h
5d360b
+++ b/ui/vnc.h
5d360b
@@ -252,6 +252,12 @@ struct VncJob
5d360b
     QTAILQ_ENTRY(VncJob) next;
5d360b
 };
5d360b
 
5d360b
+typedef enum {
5d360b
+    VNC_STATE_UPDATE_NONE,
5d360b
+    VNC_STATE_UPDATE_INCREMENTAL,
5d360b
+    VNC_STATE_UPDATE_FORCE,
5d360b
+} VncStateUpdate;
5d360b
+
5d360b
 struct VncState
5d360b
 {
5d360b
     int csock;
5d360b
@@ -261,8 +267,7 @@ struct VncState
5d360b
                            * vnc-jobs-async.c */
5d360b
 
5d360b
     VncDisplay *vd;
5d360b
-    int need_update;
5d360b
-    int force_update;
5d360b
+    VncStateUpdate update; /* Most recent pending request from client */
5d360b
     int has_dirty;
5d360b
     uint32_t features;
5d360b
     int absolute;
5d360b
-- 
5d360b
1.8.3.1
5d360b