apprt/gtk: use tagged union for quit timer

This commit is contained in:
Mitchell Hashimoto
2024-08-03 10:05:31 -07:00
parent c5e2889369
commit 224f2d0491
2 changed files with 35 additions and 22 deletions

View File

@@ -135,6 +135,9 @@ pub fn updateConfig(self: *App, config: *const Config) !void {
pub fn addSurface(self: *App, rt_surface: *apprt.Surface) !void {
try self.surfaces.append(self.alloc, rt_surface);
// Since we have non-zero surfaces, we can cancel the quit timer.
// It is up to the apprt if there is a quit timer at all and if it
// should be canceled.
if (@hasDecl(apprt.App, "cancelQuitTimer")) rt_surface.app.cancelQuitTimer();
}
@@ -161,7 +164,10 @@ pub fn deleteSurface(self: *App, rt_surface: *apprt.Surface) void {
i += 1;
}
if (@hasDecl(apprt.App, "startQuitTimer") and self.surfaces.items.len == 0) rt_surface.app.startQuitTimer();
// If we have no surfaces, we can start the quit timer. It is up to the
// apprt to determine if this is necessary.
if (@hasDecl(apprt.App, "startQuitTimer") and
self.surfaces.items.len == 0) rt_surface.app.startQuitTimer();
}
/// The last focused surface. This is only valid while on the main thread