if (dpyinfo->server_time_monotonic_p)
return timestamp;
- return 0;
+ /* This means we haven't yet initialized the server time offset. */
+ if (!dpyinfo->server_time_offset)
+ return 0;
+
+ return timestamp - dpyinfo->server_time_offset;
}
/* Return the current monotonic time in the same format as a
&& time * 1000 < monotonic_time + 500 * 1000)
dpyinfo->server_time_monotonic_p = true;
else
- dpyinfo->server_time_monotonic_p = false;
+ {
+ /* Compute an offset that can be subtracted from the server
+ time to estimate the monotonic time on the X server. */
+
+ dpyinfo->server_time_monotonic_p = false;
+ dpyinfo->server_time_offset
+ = ((int64_t) time * 1000) - monotonic_time;
+ }
}
#endif
/* Whether or not the server time is probably the same as
"clock_gettime (CLOCK_MONOTONIC, ...)". */
bool server_time_monotonic_p;
+
+ /* The time difference between the X server clock and the monotonic
+ clock. */
+ int64_t server_time_offset;
#endif
};