Skip to content

Commit

Permalink
chore: Adjust uptime query
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 8, 2025
1 parent b76e708 commit ae1a42d
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
static UNOApplicationDelegate *ad;
static system_theme_change_fn_ptr system_theme_change;
static id<MTLDevice> 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)
{
Expand All @@ -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)
Expand Down

0 comments on commit ae1a42d

Please sign in to comment.