Merge pull request #2041 from jcollie/quit-delay-fix

Fix quit-after-last-window-closed=true, quit-after-last-window-closed-delay=null
This commit is contained in:
Mitchell Hashimoto
2024-08-04 19:12:03 -07:00
committed by GitHub

View File

@ -529,8 +529,8 @@ pub fn startQuitTimer(self: *App) void {
// This is a no-op unless we are configured to quit after last window is closed. // This is a no-op unless we are configured to quit after last window is closed.
if (!self.config.@"quit-after-last-window-closed") return; if (!self.config.@"quit-after-last-window-closed") return;
// If a delay is configured, set a timeout function to quit after the delay.
if (self.config.@"quit-after-last-window-closed-delay") |v| { if (self.config.@"quit-after-last-window-closed-delay") |v| {
// If a delay is configured, set a timeout function to quit after the delay.
const ms: u64 = std.math.divTrunc( const ms: u64 = std.math.divTrunc(
u64, u64,
v.duration, v.duration,
@ -538,6 +538,9 @@ pub fn startQuitTimer(self: *App) void {
) catch std.math.maxInt(c.guint); ) catch std.math.maxInt(c.guint);
const t = std.math.cast(c.guint, ms) orelse std.math.maxInt(c.guint); const t = std.math.cast(c.guint, ms) orelse std.math.maxInt(c.guint);
self.quit_timer = .{ .active = c.g_timeout_add(t, gtkQuitTimerExpired, self) }; self.quit_timer = .{ .active = c.g_timeout_add(t, gtkQuitTimerExpired, self) };
} else {
// If no delay is configured, treat it as expired.
self.quit_timer = .{ .expired = {} };
} }
} }