From ae1a42d568a4c2889cb60742ea8c93e5b7b4cec3 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 8 Jan 2025 17:06:26 +0100 Subject: [PATCH] chore: Adjust uptime query --- .../UnoNativeMac/UnoNativeMac/UNOApplication.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOApplication.m b/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOApplication.m index 5eac3ebf1a47..e8562e0ab118 100644 --- a/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOApplication.m +++ b/src/Uno.UI.Runtime.Skia.MacOS/UnoNativeMac/UnoNativeMac/UNOApplication.m @@ -7,7 +7,8 @@ static UNOApplicationDelegate *ad; static system_theme_change_fn_ptr system_theme_change; static id device; -static NSTimeInterval uptime = 0; +static NSTimeInterval initialUptime = 0; +static NSDate *initialUptimeDate = nil; inline system_theme_change_fn_ptr uno_get_system_theme_change_callback(void) { @@ -30,10 +31,15 @@ void uno_set_system_theme_change_callback(system_theme_change_fn_ptr p) NSTimeInterval uno_get_system_uptime(void) { - if (uptime == 0) { - uptime = NSProcessInfo.processInfo.systemUptime; + if (initialUptime == 0) { + initialUptime = NSProcessInfo.processInfo.systemUptime; + initialUptimeDate = [NSDate date]; + return initialUptime; + } + else { + NSTimeInterval elapsedTime = [[NSDate date] timeIntervalSinceDate:initialUptimeDate]; + return initialUptime + elapsedTime; } - return uptime; } bool uno_app_initialize(bool *metal)