Patchwork [1/5] vnc: factor out vnc_desktop_resize()

login
register
mail settings
Submitter Gerd Hoffmann
Date May 25, 2010, 4:25 p.m.
Message ID <1274804720-518-2-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/53556/
State New
Headers show

Comments

Gerd Hoffmann - May 25, 2010, 4:25 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vnc.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)
Anthony Liguori - June 1, 2010, 6:33 p.m.
On 05/25/2010 11:25 AM, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann<kraxel@redhat.com>
>    

Applied all.  Thanks.

Regards,

Anthony Liguori

> ---
>   vnc.c |   24 ++++++++++++++++--------
>   1 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/vnc.c b/vnc.c
> index 11ae3e5..aaebe24 100644
> --- a/vnc.c
> +++ b/vnc.c
> @@ -514,6 +514,21 @@ void buffer_append(Buffer *buffer, const void *data, size_t len)
>       buffer->offset += len;
>   }
>
> +static void vnc_desktop_resize(VncState *vs)
> +{
> +    DisplayState *ds = vs->ds;
> +
> +    if (vs->csock == -1 || !vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
> +        return;
> +    }
> +    vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
> +    vnc_write_u8(vs, 0);
> +    vnc_write_u16(vs, 1); /* number of rects */
> +    vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
> +                           VNC_ENCODING_DESKTOPRESIZE);
> +    vnc_flush(vs);
> +}
> +
>   static void vnc_dpy_resize(DisplayState *ds)
>   {
>       int size_changed;
> @@ -542,14 +557,7 @@ static void vnc_dpy_resize(DisplayState *ds)
>       QTAILQ_FOREACH(vs,&vd->clients, next) {
>           vnc_colordepth(vs);
>           if (size_changed) {
> -            if (vs->csock != -1&&  vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
> -                vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
> -                vnc_write_u8(vs, 0);
> -                vnc_write_u16(vs, 1); /* number of rects */
> -                vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
> -                        VNC_ENCODING_DESKTOPRESIZE);
> -                vnc_flush(vs);
> -            }
> +            vnc_desktop_resize(vs);
>           }
>           if (vs->vd->cursor) {
>               vnc_cursor_define(vs);
>

Patch

diff --git a/vnc.c b/vnc.c
index 11ae3e5..aaebe24 100644
--- a/vnc.c
+++ b/vnc.c
@@ -514,6 +514,21 @@  void buffer_append(Buffer *buffer, const void *data, size_t len)
     buffer->offset += len;
 }
 
+static void vnc_desktop_resize(VncState *vs)
+{
+    DisplayState *ds = vs->ds;
+
+    if (vs->csock == -1 || !vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
+        return;
+    }
+    vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
+    vnc_write_u8(vs, 0);
+    vnc_write_u16(vs, 1); /* number of rects */
+    vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
+                           VNC_ENCODING_DESKTOPRESIZE);
+    vnc_flush(vs);
+}
+
 static void vnc_dpy_resize(DisplayState *ds)
 {
     int size_changed;
@@ -542,14 +557,7 @@  static void vnc_dpy_resize(DisplayState *ds)
     QTAILQ_FOREACH(vs, &vd->clients, next) {
         vnc_colordepth(vs);
         if (size_changed) {
-            if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) {
-                vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
-                vnc_write_u8(vs, 0);
-                vnc_write_u16(vs, 1); /* number of rects */
-                vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds),
-                        VNC_ENCODING_DESKTOPRESIZE);
-                vnc_flush(vs);
-            }
+            vnc_desktop_resize(vs);
         }
         if (vs->vd->cursor) {
             vnc_cursor_define(vs);