diff --git a/gdk/quartz/gdkdrawable-quartz.c b/gdk/quartz/gdkdrawable-quartz.c index eb520f08d..3193e2984 100644 --- a/gdk/quartz/gdkdrawable-quartz.c +++ b/gdk/quartz/gdkdrawable-quartz.c @@ -844,14 +844,16 @@ gdk_quartz_drawable_get_context (GdkDrawable *drawable, void _gdk_quartz_drawable_flush (GdkDrawable *drawable) { - static struct timeval prev_tv; + /* intervals on the monotonic clock: setting the clock, or a 32-bit + * time_t after 2038, does not stop the flushing */ + static gint64 prev_time; static gint intervals[4]; static gint index; - struct timeval tv; + gint64 now; gint ms; - gettimeofday (&tv, NULL); - ms = (tv.tv_sec - prev_tv.tv_sec) * 1000 + (tv.tv_usec - prev_tv.tv_usec) / 1000; + now = g_get_monotonic_time (); + ms = (gint) MIN ((now - prev_time) / 1000, G_MAXINT / 8); intervals[index++ % 4] = ms; if (drawable) @@ -868,11 +870,11 @@ _gdk_quartz_drawable_flush (GdkDrawable *drawable) [window_impl->toplevel flushWindow]; } - prev_tv = tv; + prev_time = now; } } else - prev_tv = tv; + prev_time = now; } void diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 1d427a15b..227b477c7 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -2715,9 +2715,11 @@ fetch_net_wm_check_window (GdkScreen *screen) g_return_if_fail (GDK_DISPLAY_X11 (display)->trusted_client); - now_sec = g_get_real_time () / G_USEC_PER_SEC; + now_sec = g_get_monotonic_time () / G_USEC_PER_SEC; - if (ABS (now_sec - screen_x11->last_wmspec_check_time) < 15) + /* 0: not checked yet, or to be checked again */ + if (screen_x11->last_wmspec_check_time != 0 && + ABS (now_sec - screen_x11->last_wmspec_check_time) < 15) return; /* we've checked recently */ screen_x11->last_wmspec_check_time = now_sec; diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index b5533878c..3c1c4ed95 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -99,7 +99,7 @@ struct _GtkIconThemePrivate */ GdkScreen *screen; - /* time when we last stat:ed for theme changes */ + /* time when we last stat:ed for theme changes (monotonic seconds) */ gint64 last_stat_time; GList *dir_mtimes; @@ -1187,7 +1187,7 @@ load_themes (GtkIconTheme *icon_theme) priv->themes_valid = TRUE; - priv->last_stat_time = g_get_real_time () / G_USEC_PER_SEC; + priv->last_stat_time = g_get_monotonic_time () / G_USEC_PER_SEC; } void @@ -1237,7 +1237,7 @@ ensure_valid_themes (GtkIconTheme *icon_theme) if (priv->themes_valid) { - now = g_get_real_time () / G_USEC_PER_SEC; + now = g_get_monotonic_time () / G_USEC_PER_SEC; if (ABS (now - priv->last_stat_time) > 5 && rescan_themes (icon_theme)) @@ -1997,7 +1997,7 @@ rescan_themes (GtkIconTheme *icon_theme) return TRUE; } - priv->last_stat_time = g_get_real_time () / G_USEC_PER_SEC; + priv->last_stat_time = g_get_monotonic_time () / G_USEC_PER_SEC; return FALSE; }