[sysprof/wip/visualizers] visualizer-ticks: fix msec value
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] visualizer-ticks: fix msec value
- Date: Fri, 7 Oct 2016 05:27:24 +0000 (UTC)
commit 8f613b5352c49a82e2944600593bbc0ad3d0e5a4
Author: Christian Hergert <chergert redhat com>
Date: Thu Oct 6 22:26:52 2016 -0700
visualizer-ticks: fix msec value
lib/sp-visualizer-ticks.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/lib/sp-visualizer-ticks.c b/lib/sp-visualizer-ticks.c
index d469928..9da9722 100644
--- a/lib/sp-visualizer-ticks.c
+++ b/lib/sp-visualizer-ticks.c
@@ -23,7 +23,7 @@
#define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000)
#define NSEC_PER_HOUR (NSEC_PER_SEC * 60 * 60)
#define NSEC_PER_MIN (NSEC_PER_SEC * 60)
-#define NSEC_PER_MSEC (NSEC_PER_SEC/1000L)
+#define NSEC_PER_MSEC (NSEC_PER_SEC/G_GINT64_CONSTANT(1000))
#define MIN_TICK_DISTANCE 20
#define LABEL_HEIGHT_PX 8
@@ -73,24 +73,17 @@ update_label_text (PangoLayout *layout,
gboolean want_msec)
{
g_autofree gchar *str = NULL;
+ gint64 tmp;
+ gint msec = 0;
gint hours = 0;
gint min = 0;
gint sec = 0;
- gint msec = 0;
- gint64 tmp;
g_assert (PANGO_IS_LAYOUT (layout));
- tmp = time % NSEC_PER_MSEC;
+ tmp = time % NSEC_PER_SEC;
time -= tmp;
- msec = tmp / 1000000L;
-
- /* In case our pixel math got us not quite there */
- if (msec == 999)
- {
- msec = 0;
- time += NSEC_PER_SEC;
- }
+ msec = tmp / 100000L;
if (time >= NSEC_PER_HOUR)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]