diff options
author | rbuj <[email protected]> | 2020-02-03 23:09:51 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-02-16 13:55:25 +0100 |
commit | e8fbac2ce193f5c2c93fdecb7ca0e14c1152ace6 (patch) | |
tree | f352830733cbf6ccf755a5cbe98d68ce9d4b3889 | |
parent | 2edc2a7dfbf95cf710002d633ca11530ef094ce8 (diff) | |
download | mate-desktop-e8fbac2ce193f5c2c93fdecb7ca0e14c1152ace6.tar.bz2 mate-desktop-e8fbac2ce193f5c2c93fdecb7ca0e14c1152ace6.tar.xz |
Remove GTimeVal deprecation warning for GLib 2.61.2+
-rw-r--r-- | libmate-desktop/mate-bg-crossfade.c | 13 | ||||
-rw-r--r-- | libmate-desktop/mate-bg.c | 16 | ||||
-rw-r--r-- | libmate-desktop/mate-desktop-item.c | 19 |
3 files changed, 45 insertions, 3 deletions
diff --git a/libmate-desktop/mate-bg-crossfade.c b/libmate-desktop/mate-bg-crossfade.c index fa083bb..ba1fbef 100644 --- a/libmate-desktop/mate-bg-crossfade.c +++ b/libmate-desktop/mate-bg-crossfade.c @@ -326,6 +326,18 @@ mate_bg_crossfade_set_start_surface (MateBGCrossfade* fade, cairo_surface_t *sur return fade->priv->start_surface != NULL; } +#if GLIB_CHECK_VERSION(2,61,2) +static gdouble +get_current_time (void) +{ + const double microseconds_per_second = (double) G_USEC_PER_SEC; + gint64 tv; + + tv = g_get_real_time (); + + return (double) (tv / microseconds_per_second); +} +#else static gdouble get_current_time (void) { @@ -340,6 +352,7 @@ get_current_time (void) return timestamp; } +#endif /** * mate_bg_crossfade_set_end_surface: diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c index 3ced320..d8a20c8 100644 --- a/libmate-desktop/mate-bg.c +++ b/libmate-desktop/mate-bg.c @@ -1709,15 +1709,29 @@ struct _SlideShow }; +#if GLIB_CHECK_VERSION(2,61,2) static double now (void) { + const double microseconds_per_second = (double) G_USEC_PER_SEC; + gint64 tv; + + tv = g_get_real_time (); + + return (double) (tv / microseconds_per_second); +} +#else +static double +now (void) +{ + const double microseconds_per_second = (double) G_USEC_PER_SEC; GTimeVal tv; g_get_current_time (&tv); - return (double)tv.tv_sec + (tv.tv_usec / 1000000.0); + return (double)tv.tv_sec + (tv.tv_usec / microseconds_per_second); } +#endif static Slide * get_current_slide (SlideShow *show, diff --git a/libmate-desktop/mate-desktop-item.c b/libmate-desktop/mate-desktop-item.c index f7b1154..616020b 100644 --- a/libmate-desktop/mate-desktop-item.c +++ b/libmate-desktop/mate-desktop-item.c @@ -1578,26 +1578,41 @@ startup_timeout (void *data) { StartupTimeoutData *std = data; GSList *tmp; - GTimeVal now; int min_timeout; min_timeout = STARTUP_TIMEOUT_LENGTH; +#if GLIB_CHECK_VERSION(2,61,2) + gint64 now = g_get_real_time (); +#else + GTimeVal now; g_get_current_time (&now); +#endif tmp = std->contexts; while (tmp != NULL) { SnLauncherContext *sn_context = tmp->data; GSList *next = tmp->next; - long tv_sec, tv_usec; double elapsed; +#if GLIB_CHECK_VERSION(2,61,2) + time_t tv_sec; + suseconds_t tv_usec; + gint64 tv; + + sn_launcher_context_get_last_active_time (sn_context, &tv_sec, &tv_usec); + tv = (tv_sec * G_USEC_PER_SEC) + tv_usec; + elapsed = (double) (now - tv) / 1000.0; +#else + long tv_sec, tv_usec; + sn_launcher_context_get_last_active_time (sn_context, &tv_sec, &tv_usec); elapsed = ((((double)now.tv_sec - tv_sec) * G_USEC_PER_SEC + (now.tv_usec - tv_usec))) / 1000.0; +#endif if (elapsed >= STARTUP_TIMEOUT_LENGTH) { std->contexts = g_slist_remove (std->contexts, |