desktop-shell:change expiration of minute and sec

Fixes: #400

the clock on upper right corner of screen for
desktop shell is behind one minute when compared
to output of date command, so change initial expiration
it_value for minute and sec to remove the delay.

Signed-off-by: Veeresh Kadasani <veeresh.kadasani@huawei.com>
dev
Veeresh Kadasani 4 years ago
parent 9cb96f8353
commit ed4a0e9275
  1. 13
      clients/desktop-shell.c

@ -48,6 +48,7 @@
#include "shared/xalloc.h"
#include <libweston/zalloc.h>
#include "shared/file-util.h"
#include "shared/timespec-util.h"
#include "weston-desktop-shell-client-protocol.h"
@ -421,13 +422,19 @@ static int
clock_timer_reset(struct panel_clock *clock)
{
struct itimerspec its;
struct timespec ts;
struct tm *tm;
clock_gettime(CLOCK_REALTIME, &ts);
tm = localtime(&ts.tv_sec);
its.it_interval.tv_sec = clock->refresh_timer;
its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = clock->refresh_timer;
its.it_value.tv_nsec = 0;
toytimer_arm(&clock->timer, &its);
its.it_value.tv_sec = clock->refresh_timer - tm->tm_sec % clock->refresh_timer;
its.it_value.tv_nsec = 10000000; /* 10 ms late to ensure the clock digit has actually changed */
timespec_add_nsec(&its.it_value, &its.it_value, -ts.tv_nsec);
toytimer_arm(&clock->timer, &its);
return 0;
}

Loading…
Cancel
Save