From 409b01fd6dad591b42e4f43c37b4e8c833422968 Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Thu, 16 Nov 2017 18:21:01 +0200 Subject: 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 Reviewed-by: Pekka Paalanen --- compositor/text-backend.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'compositor') diff --git a/compositor/text-backend.c b/compositor/text-backend.c index 5f6b5d80..e10f9576 100644 --- a/compositor/text-backend.c +++ b/compositor/text-backend.c @@ -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; } -- cgit v1.2.3