From patchwork Thu May 6 08:39:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 51848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B0476B7D53 for ; Fri, 7 May 2010 01:46:38 +1000 (EST) Received: from localhost ([127.0.0.1]:52135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OA3HW-0001Hs-Jy for incoming@patchwork.ozlabs.org; Thu, 06 May 2010 11:46:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9wYg-0001FB-Vv for qemu-devel@nongnu.org; Thu, 06 May 2010 04:35:51 -0400 Received: from [140.186.70.92] (port=49474 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9wYf-0001Ao-27 for qemu-devel@nongnu.org; Thu, 06 May 2010 04:35:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9wYZ-0007LF-5K for qemu-devel@nongnu.org; Thu, 06 May 2010 04:35:48 -0400 Received: from iksaif.net ([88.191.73.63]:49400) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9wYY-0007Kk-WD for qemu-devel@nongnu.org; Thu, 06 May 2010 04:35:43 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id C9F54C90011; Thu, 6 May 2010 10:39:08 +0200 (CEST) From: Corentin Chary To: qemu-devel@nongnu.org Date: Thu, 6 May 2010 10:39:03 +0200 Message-Id: <1273135146-11093-1-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Corentin Chary , Anthony Liguori Subject: [Qemu-devel] [PATCH 1/4] vnc: set the right prefered encoding X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From RFB specs: "The order of the encoding types given in this message is a hint by the client as to its preference (the first encoding specified being most preferred)" Signed-off-by: Corentin Chary --- vnc.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/vnc.c b/vnc.c index b1a3fdb..a91c3a3 100644 --- a/vnc.c +++ b/vnc.c @@ -1587,6 +1587,13 @@ static void send_ext_audio_ack(VncState *vs) vnc_flush(vs); } +static void set_encoding(VncState *vs, int encoding) +{ + if (vs->vnc_encoding == -1) { + vs->vnc_encoding = encoding; + } +} + static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) { int i; @@ -1594,7 +1601,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vnc_zlib_init(vs); vs->features = 0; - vs->vnc_encoding = 0; + vs->vnc_encoding = -1; vs->tight_compression = 9; vs->tight_quality = 9; vs->absolute = -1; @@ -1603,18 +1610,18 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) enc = encodings[i]; switch (enc) { case VNC_ENCODING_RAW: - vs->vnc_encoding = enc; + set_encoding(vs, enc); break; case VNC_ENCODING_COPYRECT: vs->features |= VNC_FEATURE_COPYRECT_MASK; break; case VNC_ENCODING_HEXTILE: vs->features |= VNC_FEATURE_HEXTILE_MASK; - vs->vnc_encoding = enc; + set_encoding(vs, enc); break; case VNC_ENCODING_ZLIB: vs->features |= VNC_FEATURE_ZLIB_MASK; - vs->vnc_encoding = enc; + set_encoding(vs, enc); break; case VNC_ENCODING_DESKTOPRESIZE: vs->features |= VNC_FEATURE_RESIZE_MASK;