icontheme, gdk: the pause between two looks for changed themes, between two checks for the window manager and between two flushes on Quartz is measured with the monotonic clock
This commit is contained in:
parent
abb3c12457
commit
721715ca20
3 changed files with 16 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue