libweston: Use struct timespec for compositor time
Change weston_compositor_get_time to return the current compositor time as a struct timespec. Also, use clock_gettime (with CLOCK_REALTIME) to get the time, since it's equivalent to the currently used gettimeofday call, but returns the data directly in a struct timespec. This commit is part of a larger effort to transition the Weston codebase to struct timespec. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
7d2abcf6c8
commit
409b01fd6d
@@ -106,7 +106,7 @@ struct text_backend {
|
||||
struct wl_client *client;
|
||||
|
||||
unsigned deathcount;
|
||||
uint32_t deathstamp;
|
||||
struct timespec deathstamp;
|
||||
} input_method;
|
||||
|
||||
struct wl_listener client_listener;
|
||||
@@ -938,11 +938,14 @@ static void launch_input_method(struct text_backend *text_backend);
|
||||
static void
|
||||
respawn_input_method_process(struct text_backend *text_backend)
|
||||
{
|
||||
uint32_t time;
|
||||
struct timespec time;
|
||||
int64_t tdiff;
|
||||
|
||||
/* if input_method dies more than 5 times in 10 seconds, give up */
|
||||
time = weston_compositor_get_time();
|
||||
if (time - text_backend->input_method.deathstamp > 10000) {
|
||||
weston_compositor_get_time(&time);
|
||||
tdiff = timespec_sub_to_msec(&time,
|
||||
&text_backend->input_method.deathstamp);
|
||||
if (tdiff > 10000) {
|
||||
text_backend->input_method.deathstamp = time;
|
||||
text_backend->input_method.deathcount = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user