diff options
author | David Robillard <d@drobilla.net> | 2014-05-05 13:44:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-05-05 13:44:44 +0000 |
commit | dc17d30d9248938e94d77780c206644ce9bb4e08 (patch) | |
tree | e01aae3378175669ab6fd380eade5c29f7192281 | |
parent | d660fee30d6110e14f2069086650e4cb715771d8 (diff) | |
download | ganv-dc17d30d9248938e94d77780c206644ce9bb4e08.tar.gz ganv-dc17d30d9248938e94d77780c206644ce9bb4e08.tar.bz2 ganv-dc17d30d9248938e94d77780c206644ce9bb4e08.zip |
Fix compilation on old glib.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5396 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/Canvas.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 4478b59..47b0013 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -788,6 +788,18 @@ apply_force(GanvNode* a, GanvNode* b, const Vector& f) b->impl->force = vec_sub(b->impl->force, f); } +inline uint64_t +get_monotonic_time() +{ +#if GLIB_CHECK_VERSION(2, 28, 0) + return g_get_monotonic_time(); +#else + GTimeVal time; + g_get_current_time(&time); + return time.tv_sec + time.tv_usec; +#endif +} + gboolean GanvCanvasImpl::layout_iteration() { @@ -802,7 +814,7 @@ GanvCanvasImpl::layout_iteration() static uint64_t prev = 0; // Previous iteration time - const uint64_t now = g_get_monotonic_time(); + const uint64_t now = get_monotonic_time(); const double time_to_run = std::min((now - prev) * T_PER_US, 10.0); prev = now; @@ -1614,14 +1626,7 @@ GanvCanvasImpl::on_animate_timeout(gpointer data) { GanvCanvasImpl* impl = (GanvCanvasImpl*)data; -#ifdef g_get_monotonic_time - // Only available in glib 2.28 - const double seconds = g_get_monotonic_time() / 1000000.0; -#else - GTimeVal time; - g_get_current_time(&time); - const double seconds = time.tv_sec + time.tv_usec / (double)G_USEC_PER_SEC; -#endif + const double seconds = get_monotonic_time() / 1000000.0; FOREACH_ITEM(impl->_selected_items, s) { ganv_node_tick(*s, seconds); |