Handle deprecation of GTimeVal (#575)

`GTimeVal` has been deprecated in glib 2.62 . While switching to `g_get_monotonic_time()`, I realized that we could simply reuse `fluid_utime()` for that purpose.
This commit is contained in:
Tom M 2019-10-22 17:39:08 +02:00 committed by GitHub
parent dfcf5c019f
commit 64cee5537d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,22 +313,21 @@ void fluid_msleep(unsigned int msecs)
/** /**
* Get time in milliseconds to be used in relative timing operations. * Get time in milliseconds to be used in relative timing operations.
* @return Unix time in milliseconds. * @return Monotonic time in milliseconds.
*/ */
unsigned int fluid_curtime(void) unsigned int fluid_curtime(void)
{ {
static glong initial_seconds = 0; float now;
GTimeVal timeval; static float initial_time = 0;
if(initial_seconds == 0) if(initial_time == 0)
{ {
g_get_current_time(&timeval); initial_time = (float)fluid_utime();
initial_seconds = timeval.tv_sec;
} }
g_get_current_time(&timeval); now = (float)fluid_utime();
return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0); return (unsigned int)((now - initial_time) / 1000.0f);
} }
/** /**