From 5e4813433ec52572cf32cef0723140401526db46 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Sun, 17 Nov 2024 19:26:26 -0800 Subject: [PATCH] Do ceil(timeout/1000) when convert us timestamp to libuv timestamp. --- src/lib/fcitx-utils/event_libuv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/fcitx-utils/event_libuv.cpp b/src/lib/fcitx-utils/event_libuv.cpp index 1719584bc..8af3222bc 100644 --- a/src/lib/fcitx-utils/event_libuv.cpp +++ b/src/lib/fcitx-utils/event_libuv.cpp @@ -89,8 +89,8 @@ bool LibUVSourceTime::setup(uv_loop_t *loop, uv_timer_t *timer) { } auto curr = now(clock_); uint64_t timeout = time_ > curr ? (time_ - curr) : 0; - // libuv is milliseconds - timeout /= 1000; + // libuv is milliseconds, ceil towards 1ms. + timeout = timeout / 1000 + (timeout % 1000 != 0); if (int err = uv_timer_start(timer, &TimeEventCallback, timeout, 0); err < 0) { FCITX_LIBUV_DEBUG() << "Failed to start timer with error: " << err;