ui/gtk: don't try to redefine SI prefixes
authorVolker Rümelin <vr_qemu@t-online.de>
Sun, 13 Dec 2020 16:57:22 +0000 (17:57 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 15 Jan 2021 10:22:42 +0000 (11:22 +0100)
Redefining SI prefixes is always wrong. 1s has per definition
1000ms. Remove the misnamed named constant and replace it with
a comment explaining the frequency to period conversion in two
simple steps. Now you can cancel out the unit mHz in the comment
with the implicit unit mHz in refresh_rate_millihz and see why
the implicit unit ms for update_interval remains.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20201213165724.13418-1-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
include/ui/gtk.h
ui/gtk.c

index eaeb450f913e02b50c0a7c1e4e190da66ed1338e..80851fb4c7e12d9421b395c67975f5c271584f4c 100644 (file)
@@ -24,8 +24,6 @@
 #include "ui/egl-context.h"
 #endif
 
-#define MILLISEC_PER_SEC 1000000
-
 typedef struct GtkDisplayState GtkDisplayState;
 
 typedef struct VirtualGfxConsole {
index e8474456df88e7f63c95b0fc357171c8f126660f..a83c8c3785e1fac2fefc4d6a2559953f6dcb2326 100644 (file)
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -798,7 +798,8 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
     refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ?
                                                    vc->window : s->window);
     if (refresh_rate_millihz) {
-        vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / refresh_rate_millihz;
+        /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */
+        vc->gfx.dcl.update_interval = 1000 * 1000 / refresh_rate_millihz;
     }
 
     fbw = surface_width(vc->gfx.ds);