x11: use the monotonic clock for colormap syncs
This commit is contained in:
parent
944e7d9ffe
commit
407a31fc72
1 changed files with 11 additions and 5 deletions
|
|
@ -34,6 +34,9 @@
|
|||
#include "gdkscreen-x11.h"
|
||||
#include "gdkalias.h"
|
||||
|
||||
#define MIN_SYNC_TIME 2 /* seconds between syncs of a colormap */
|
||||
#define NEVER_SYNCED G_MININT64
|
||||
|
||||
typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11;
|
||||
typedef GdkColormapPrivateX11 GdkColormapPrivate;
|
||||
|
||||
|
|
@ -82,7 +85,7 @@ gdk_colormap_init (GdkColormap *colormap)
|
|||
|
||||
private->screen = NULL;
|
||||
private->hash = NULL;
|
||||
private->last_sync_time = 0;
|
||||
private->last_sync_time = NEVER_SYNCED;
|
||||
private->info = NULL;
|
||||
|
||||
colormap->size = 0;
|
||||
|
|
@ -317,7 +320,6 @@ gdk_colormap_sync_direct_color (GdkColormap *colormap)
|
|||
g_free (xpalette);
|
||||
}
|
||||
|
||||
#define MIN_SYNC_TIME 2
|
||||
|
||||
static void
|
||||
gdk_colormap_sync (GdkColormap *colormap,
|
||||
|
|
@ -331,8 +333,12 @@ gdk_colormap_sync (GdkColormap *colormap,
|
|||
if (private->screen->closed)
|
||||
return;
|
||||
|
||||
current_time = (gint64) time (NULL);
|
||||
if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
|
||||
/* A time between two syncs: the monotonic clock, not time (), which
|
||||
* on 32-bit systems has no answer after 2038 (and then never let the
|
||||
* colormap be synced again) and jumps when the clock is set */
|
||||
current_time = g_get_monotonic_time () / G_USEC_PER_SEC;
|
||||
if (!force && private->last_sync_time != NEVER_SYNCED &&
|
||||
current_time - private->last_sync_time < MIN_SYNC_TIME)
|
||||
return;
|
||||
|
||||
private->last_sync_time = current_time;
|
||||
|
|
@ -376,7 +382,7 @@ gdk_screen_get_system_colormap (GdkScreen *screen)
|
|||
private->private_val = FALSE;
|
||||
|
||||
private->hash = NULL;
|
||||
private->last_sync_time = 0;
|
||||
private->last_sync_time = NEVER_SYNCED;
|
||||
private->info = NULL;
|
||||
|
||||
colormap->colors = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue