From nobody Sun May 5 23:36:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542100790375827.2247241998623; Tue, 13 Nov 2018 01:19:50 -0800 (PST) Received: from localhost ([::1]:52832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMUrJ-0002KL-T4 for importer@patchew.org; Tue, 13 Nov 2018 04:19:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMUm0-0005wu-9x for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:14:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMUb1-0000LT-2q for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:02:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMUb0-0000K0-Sb for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:02:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E835081F13; Tue, 13 Nov 2018 09:02:53 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-158.ams2.redhat.com [10.36.116.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DE001001938; Tue, 13 Nov 2018 09:02:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DA31C187; Tue, 13 Nov 2018 10:02:49 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 13 Nov 2018 10:02:49 +0100 Message-Id: <20181113090249.15658-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 13 Nov 2018 09:02:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] gtk: sync guest display updates to host display refresh X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , tgfbeta@me.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reduce console refresh timer to idle refresh rate. Register a frame tick callback (called by gtk on each display frame) and use that to kick display updates instead. That should sync qemu refresh rate to display refresh rate. It'll also stop updating the qemu display in case the qemu is not visible (gtk stops calling the frame tick callback then). Buglink: https://bugs.launchpad.net/bugs/1802915 Suggested-by: Chen Zhang Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui/gtk.c b/ui/gtk.c index 579990b865..8f79dfe42c 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1661,6 +1661,16 @@ static gboolean gd_configure(GtkWidget *widget, return FALSE; } =20 +static gboolean gd_frame_tick(GtkWidget *widget, + GdkFrameClock *frame_clock, + gpointer opaque) +{ + VirtualConsole *vc =3D opaque; + + vc->gfx.dcl.ops->dpy_refresh(&vc->gfx.dcl); + return G_SOURCE_CONTINUE; +} + /** Virtual Console Callbacks **/ =20 static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc, @@ -1911,6 +1921,12 @@ static void gd_connect_vc_gfx_signals(VirtualConsole= *vc) G_CALLBACK(gd_focus_out_event), vc); g_signal_connect(vc->gfx.drawing_area, "configure-event", G_CALLBACK(gd_configure), vc); + if (1 /* make that a config option ??? */) { + update_displaychangelistener(&vc->gfx.dcl, + GUI_REFRESH_INTERVAL_IDLE); + gtk_widget_add_tick_callback(vc->gfx.drawing_area, + gd_frame_tick, vc, NULL); + } } else { g_signal_connect(vc->gfx.drawing_area, "key-press-event", G_CALLBACK(gd_text_key_down), vc); --=20 2.9.3