From patchwork Fri Oct 30 11:10:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 538251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2902E140D5F for ; Fri, 30 Oct 2015 22:13:08 +1100 (AEDT) Received: from localhost ([::1]:49712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs7cI-0001lj-9L for incoming@patchwork.ozlabs.org; Fri, 30 Oct 2015 07:13:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs7Zh-0005eO-VM for qemu-devel@nongnu.org; Fri, 30 Oct 2015 07:10:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zs7Ze-0002Zh-W0 for qemu-devel@nongnu.org; Fri, 30 Oct 2015 07:10:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zs7Ze-0002ZL-RL for qemu-devel@nongnu.org; Fri, 30 Oct 2015 07:10:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6E3BEBDD6C; Fri, 30 Oct 2015 11:10:22 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9UBAK1R015615; Fri, 30 Oct 2015 07:10:21 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id F3FC1818E9; Fri, 30 Oct 2015 12:10:17 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 30 Oct 2015 12:10:09 +0100 Message-Id: <1446203414-4013-15-git-send-email-kraxel@redhat.com> In-Reply-To: <1446203414-4013-1-git-send-email-kraxel@redhat.com> References: <1446203414-4013-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pl@kamp.de, Gerd Hoffmann Subject: [Qemu-devel] [PATCH 14/19] vnc: only alloc server surface with clients connected X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrange --- ui/vnc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ui/vnc.c b/ui/vnc.c index 8ee1266..c5bef47 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -721,6 +721,10 @@ static void vnc_update_server_surface(VncDisplay *vd) qemu_pixman_image_unref(vd->server); vd->server = NULL; + if (QTAILQ_EMPTY(&vd->clients)) { + return; + } + vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT, vnc_width(vd), vnc_height(vd), @@ -1231,6 +1235,10 @@ void vnc_disconnect_finish(VncState *vs) if (vs->initialized) { QTAILQ_REMOVE(&vs->vd->clients, vs, next); qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier); + if (QTAILQ_EMPTY(&vs->vd->clients)) { + /* last client gone */ + vnc_update_server_surface(vs->vd); + } } if (vs->vd->lock_key_sync) @@ -3069,6 +3077,7 @@ void vnc_init_state(VncState *vs) { vs->initialized = true; VncDisplay *vd = vs->vd; + bool first_client = QTAILQ_EMPTY(&vd->clients); vs->last_x = -1; vs->last_y = -1; @@ -3082,6 +3091,9 @@ void vnc_init_state(VncState *vs) vs->bh = qemu_bh_new(vnc_jobs_bh, vs); QTAILQ_INSERT_TAIL(&vd->clients, vs, next); + if (first_client) { + vnc_update_server_surface(vd); + } graphic_hw_update(vd->dcl.con);