From db26b07080c9f3504e706f7fde9f7fcc3215617d Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 3 Feb 2020 23:09:51 +0100 Subject: Remove GTimeVal deprecation warning for GLib 2.61.2+ --- libmate-desktop/mate-bg-crossfade.c | 13 +++++++++++++ libmate-desktop/mate-bg.c | 16 +++++++++++++++- 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, -- cgit v1.2.1