From nobody Tue May 21 16:28:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1578485692; cv=none; d=zohomail.com; s=zohoarc; b=SUPav3hpdcR8r021PFxHKRDlQQmYfuljeYGbdBf2pA+AjEF6MoNn7ZQFvSo71P8dl/qP+ltBPzmwu6PZamnGCo6EAwYNpLbF8KrtdBY5yo654kimDb+NCYqJVojyM1c2/XW6GRVgv0DMizqbSrN+EP/MjZ/tna5u7NVFMaHGAoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578485692; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+1w4jYGjAvmzR5ZCAhWJySfBpIbL70IiNAQ8BNCVt0A=; b=F95SVte+VuF0qkQX0+BvHf8TyPyu1oVV1O/gFqivGUjMLGDd8Sa9PUCLVhCFSY4WJx4UQzU9PwQgPjbJm2+0bdCagP/L+bm6WzCQ5+1etQNzN/d+eUH8KuJlInjK7ZwAcyM9SULjEqh8fQdBUGkYLbdG1iJZPkM/QwifPvG76Fo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578485692131278.46499242359664; Wed, 8 Jan 2020 04:14:52 -0800 (PST) Received: from localhost ([::1]:42670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipAEc-0003cb-0p for importer@patchew.org; Wed, 08 Jan 2020 07:14:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52696) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipADs-0003BS-Fc for qemu-devel@nongnu.org; Wed, 08 Jan 2020 07:14:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipADr-0008Nr-B7 for qemu-devel@nongnu.org; Wed, 08 Jan 2020 07:14:04 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:39999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipADr-0008NR-5J for qemu-devel@nongnu.org; Wed, 08 Jan 2020 07:14:03 -0500 Received: by mail-wr1-x441.google.com with SMTP id c14so3119503wrn.7 for ; Wed, 08 Jan 2020 04:14:03 -0800 (PST) Received: from localhost.localdomain (93-139-26-156.adsl.net.t-com.hr. [93.139.26.156]) by smtp.gmail.com with ESMTPSA id n3sm3783360wrs.8.2020.01.08.04.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 04:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+1w4jYGjAvmzR5ZCAhWJySfBpIbL70IiNAQ8BNCVt0A=; b=Br+CCXPiWpZNJFqqvF0ggIkS22AGg7TH/ciw+r6urpjfKnAjTxSJaDxfYmNq1ip/hV VIyWFloY1uStA7l6ubl3PMJEXi+z/s+C/87afO+HVPLKuwuvrmhdijxn0NGx3DVMY9wk JDfyG+rkTVkOJkBT6dtxXqU9uuwnyMszActbJ3B0JrPrLcGsuLwTfo4p07f3EOMrHfWY eu49J1yn0CbjmVgxU2Dl4ZtTrYehyaux7DI2Z/+/UVEkst3OODjb1onGJWhr0WIch4dw H5qnJZZiyz2XwQjYhvr66hWE78nwO5qFmGKkASk7gBTyUkkiiZzmr/4jtyE39m+ilbzL D4Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+1w4jYGjAvmzR5ZCAhWJySfBpIbL70IiNAQ8BNCVt0A=; b=PJkDkshiERoV9hymXQhlBtm7pVCq8x4h1sLnvx7lvfv1mAFKKAAjAHfjVWae31kaMT kT6oFG2j2F+p/mfcXqieWY+SNIQONugBqKxbL7smwVRALNBTDuQsRM2PEXxolqqA8cen PviqHGpPvy8ZMkgqCIEWMVDPLNVanOUl3TKmEGwcbHgDfiPCSSGFAP3nF65RhcNKPXLW /IDiXldQZOx1p0jTF3XXIBpVgI9VBcARm3V21RSNZytl0EnpujXJt3JYhqqX/A2oj8k8 D/8hFU0+WPqTM80ECf3ERIyCw2z7yZ1jImFKXZPFx2YYwxugAJxvOpLsGbd5GQJfMzqp Iosg== X-Gm-Message-State: APjAAAWugaclxh39loXi4Mp/BBAY50JzUPgWzf5Af/5dtn1o8RGvfccf dfiBappcmY4tlsCBWNTsT8hAW/Ln/BeAwA== X-Google-Smtp-Source: APXvYqye0drTB6rXo6TpGV0L1q/8uNagbYRI3Jm182RhuhT0gn7a/Eac+ktbs7bBk2CdlOYX5CmxMA== X-Received: by 2002:adf:eb89:: with SMTP id t9mr4286128wrn.5.1578485641819; Wed, 08 Jan 2020 04:14:01 -0800 (PST) From: pavlica.nikola@gmail.com To: qemu-devel@nongnu.org Subject: [PATCH v5] display/gtk: get proper refreshrate Date: Wed, 8 Jan 2020 13:13:42 +0100 Message-Id: <20200108121342.29597-1-pavlica.nikola@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, Nikola Pavlica Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Nikola Pavlica Because some VMs in QEMU can get GPU virtualization (using technologies such as iGVT-g, as mentioned previously), they could produce a video output that had a higher display refresh rate than of what the GTK display was displaying. (fxp. Playing a video game inside of a Windows VM at 60 Hz, while the output stood locked at 33 Hz because of defaults set in include/ui/console.h) Since QEMU does indeed have internal systems for determining frame times as defined in ui/console.c. The code checks for a variable called update_interval that it later uses for time calculation. This variable, however, isn't defined anywhere in ui/gtk.c and instead ui/console.c just sets it to GUI_REFRESH_INTERVAL_DEFAULT which is 30 update_interval represents the number of milliseconds per display refresh, and by doing some math we get that 1000/30 =3D 33.33... Hz This creates the mentioned problem and what this patch does is that it checks for the display refresh rate reported by GTK itself (we can take this as a safe value) and just converts it back to a number of milliseconds per display refresh. Signed-off-by: Nikola Pavlica Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/gtk.h | 2 ++ ui/gtk.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index d9eedad976..d1b230848a 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -28,6 +28,8 @@ #include "ui/egl-context.h" #endif =20 +#define MILLISEC_PER_SEC 1000000 + typedef struct GtkDisplayState GtkDisplayState; =20 typedef struct VirtualGfxConsole { diff --git a/ui/gtk.c b/ui/gtk.c index 692ccc7bbb..eb0efc70ee 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1966,6 +1966,10 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vi= rtualConsole *vc, GSList *group, GtkWidget *view_menu) { bool zoom_to_fit =3D false; + int refresh_rate_millihz; + GdkDisplay *dpy =3D gtk_widget_get_display(s->window); + GdkWindow *win =3D gtk_widget_get_window(s->window); + GdkMonitor *monitor =3D gdk_display_get_monitor_at_window(dpy, win); =20 vc->label =3D qemu_console_get_label(con); vc->s =3D s; @@ -2026,6 +2030,12 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vi= rtualConsole *vc, =20 vc->gfx.kbd =3D qkbd_state_init(con); vc->gfx.dcl.con =3D con; + + refresh_rate_millihz =3D gdk_monitor_get_refresh_rate(monitor); + if (refresh_rate_millihz) { + vc->gfx.dcl.update_interval =3D MILLISEC_PER_SEC / refresh_rate_mi= llihz; + } + register_displaychangelistener(&vc->gfx.dcl); =20 gd_connect_vc_gfx_signals(vc); --=20 2.24.1