summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-02-03 23:09:51 +0100
committerraveit65 <[email protected]>2020-02-25 13:26:36 +0100
commitdb26b07080c9f3504e706f7fde9f7fcc3215617d (patch)
treea9a7ee4c7d208b89c2bd2a8d76a3cc49df9af313 /libmate-desktop
parent11942ceab81309f4d65431b185acac84c957fdfe (diff)
downloadmate-desktop-db26b07080c9f3504e706f7fde9f7fcc3215617d.tar.bz2
mate-desktop-db26b07080c9f3504e706f7fde9f7fcc3215617d.tar.xz
Remove GTimeVal deprecation warning for GLib 2.61.2+
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/mate-bg-crossfade.c13
-rw-r--r--libmate-desktop/mate-bg.c16
-rw-r--r--libmate-desktop/mate-desktop-item.c19
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,