From 71d08ab6eca1f6956ca9932eea4711bb9b579393 Mon Sep 17 00:00:00 2001 From: Anton Bulakh Date: Tue, 23 Nov 2021 08:45:52 +0200 Subject: [PATCH] Use gmath.round --- lib/gears/timer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/gears/timer.lua b/lib/gears/timer.lua index bf06e8bb..cdc60871 100644 --- a/lib/gears/timer.lua +++ b/lib/gears/timer.lua @@ -61,6 +61,7 @@ local glib = require("lgi").GLib local object = require("gears.object") local protected_call = require("gears.protected_call") local gdebug = require("gears.debug") +local gmath = require("gears.math") --- Timer objects. This type of object is useful when triggering events repeatedly. -- The timer will emit the "timeout" signal every N seconds, N being the timeout @@ -91,7 +92,7 @@ function timer:start() gdebug.print_error(traceback("timer already started")) return end - local timeout_ms = math.floor(self.data.timeout * 1000 + 0.5) + local timeout_ms = gmath.round(self.data.timeout * 1000) self.data.source_id = glib.timeout_add(glib.PRIORITY_DEFAULT, timeout_ms, function() protected_call(self.emit_signal, self, "timeout") return true