Blame SOURCES/kvm-ui-introduce-enum-to-track-VNC-client-framebuffer-up.patch

9bac43
From 408b757578e8d9b96756c3753fb6661cd812d62f Mon Sep 17 00:00:00 2001
9bac43
From: "Daniel P. Berrange" <berrange@redhat.com>
9bac43
Date: Mon, 5 Feb 2018 11:10:03 +0100
9bac43
Subject: [PATCH 09/20] ui: introduce enum to track VNC client framebuffer
9bac43
 update request state
9bac43
MIME-Version: 1.0
9bac43
Content-Type: text/plain; charset=UTF-8
9bac43
Content-Transfer-Encoding: 8bit
9bac43
9bac43
RH-Author: Daniel P. Berrange <berrange@redhat.com>
9bac43
Message-id: <20180205111012.6210-9-berrange@redhat.com>
9bac43
Patchwork-id: 78879
9bac43
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 08/17] ui: introduce enum to track VNC client framebuffer update request state
9bac43
Bugzilla: 1527404
9bac43
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9bac43
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
9bac43
From: "Daniel P. Berrange" <berrange@redhat.com>
9bac43
9bac43
Currently the VNC servers tracks whether a client has requested an incremental
9bac43
or forced update with two boolean flags. There are only really 3 distinct
9bac43
states to track, so create an enum to more accurately reflect permitted states.
9bac43
9bac43
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9bac43
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
9bac43
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Message-id: 20171218191228.31018-7-berrange@redhat.com
9bac43
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9bac43
(cherry picked from commit fef1bbadfb2c3027208eb3d14b43e1bdb51166ca)
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 ui/vnc.c | 21 +++++++++++----------
9bac43
 ui/vnc.h |  9 +++++++--
9bac43
 2 files changed, 18 insertions(+), 12 deletions(-)
9bac43
9bac43
diff --git a/ui/vnc.c b/ui/vnc.c
9bac43
index e159fe6..2320421 100644
9bac43
--- a/ui/vnc.c
9bac43
+++ b/ui/vnc.c
9bac43
@@ -975,16 +975,17 @@ static int vnc_update_client(VncState *vs, int has_dirty)
9bac43
     }
9bac43
 
9bac43
     vs->has_dirty += has_dirty;
9bac43
-    if (!vs->need_update) {
9bac43
+    if (vs->update == VNC_STATE_UPDATE_NONE) {
9bac43
         return 0;
9bac43
     }
9bac43
 
9bac43
-    if (vs->output.offset && !vs->audio_cap && !vs->force_update) {
9bac43
+    if (vs->output.offset && !vs->audio_cap &&
9bac43
+        vs->update != VNC_STATE_UPDATE_FORCE) {
9bac43
         /* kernel send buffers are full -> drop frames to throttle */
9bac43
         return 0;
9bac43
     }
9bac43
 
9bac43
-    if (!vs->has_dirty && !vs->force_update) {
9bac43
+    if (!vs->has_dirty && vs->update != VNC_STATE_UPDATE_FORCE) {
9bac43
         return 0;
9bac43
     }
9bac43
 
9bac43
@@ -1030,7 +1031,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
9bac43
     }
9bac43
 
9bac43
     vnc_job_push(job);
9bac43
-    vs->force_update = 0;
9bac43
+    vs->update = VNC_STATE_UPDATE_INCREMENTAL;
9bac43
     vs->has_dirty = 0;
9bac43
     return n;
9bac43
 }
9bac43
@@ -1869,14 +1870,14 @@ static void ext_key_event(VncState *vs, int down,
9bac43
 static void framebuffer_update_request(VncState *vs, int incremental,
9bac43
                                        int x, int y, int w, int h)
9bac43
 {
9bac43
-    vs->need_update = 1;
9bac43
-
9bac43
     if (incremental) {
9bac43
-        return;
9bac43
+        if (vs->update != VNC_STATE_UPDATE_FORCE) {
9bac43
+            vs->update = VNC_STATE_UPDATE_INCREMENTAL;
9bac43
+        }
9bac43
+    } else {
9bac43
+        vs->update = VNC_STATE_UPDATE_FORCE;
9bac43
+        vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);
9bac43
     }
9bac43
-
9bac43
-    vs->force_update = 1;
9bac43
-    vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h);
9bac43
 }
9bac43
 
9bac43
 static void send_ext_key_event_ack(VncState *vs)
9bac43
diff --git a/ui/vnc.h b/ui/vnc.h
9bac43
index 694cf32..b9d310e 100644
9bac43
--- a/ui/vnc.h
9bac43
+++ b/ui/vnc.h
9bac43
@@ -252,6 +252,12 @@ struct VncJob
9bac43
     QTAILQ_ENTRY(VncJob) next;
9bac43
 };
9bac43
 
9bac43
+typedef enum {
9bac43
+    VNC_STATE_UPDATE_NONE,
9bac43
+    VNC_STATE_UPDATE_INCREMENTAL,
9bac43
+    VNC_STATE_UPDATE_FORCE,
9bac43
+} VncStateUpdate;
9bac43
+
9bac43
 struct VncState
9bac43
 {
9bac43
     QIOChannelSocket *sioc; /* The underlying socket */
9bac43
@@ -264,8 +270,7 @@ struct VncState
9bac43
                            * vnc-jobs-async.c */
9bac43
 
9bac43
     VncDisplay *vd;
9bac43
-    int need_update;
9bac43
-    int force_update;
9bac43
+    VncStateUpdate update; /* Most recent pending request from client */
9bac43
     int has_dirty;
9bac43
     uint32_t features;
9bac43
     int absolute;
9bac43
-- 
9bac43
1.8.3.1
9bac43