How to compare GDKEvent timestamp with current tim

2020-04-21 08:00发布

问题:

How to use the GDKEvent's timestamp in c++? For example, I print it as unsigned int, its value is 4194719109, but the current time is 1395764110 which is gotten from time() of time.h. The current time of g_get_real_time() is 1395764110872217 which is a gint64 type value. it seems the g_get_real_time() is more accurate than time().

My purpose is to calculate how many times it has lasted from the time of GDKEvent occurred.

回答1:

The time element of GdkEvent is in miliseconds. Comparing with g_get_monotonic_time() (which is in µs) divided by 1000 should work (make sure to check the sign and cast to guint32 before comparing)



标签: c++ gtk