From b021d76edf8d8574c1b60cf75e04944c1394dcb4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 13 Dec 2023 16:35:14 -0800 Subject: [PATCH] core: quit-after-last-window-closed works properly with "exit" Fixes #1085 This moves the logic of exiting when there are no surfaces left fully to apprt and away from the core. --- src/App.zig | 4 ++-- src/apprt/glfw.zig | 2 +- src/apprt/gtk/App.zig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.zig b/src/App.zig index 7856177217..c1917f79b4 100644 --- a/src/App.zig +++ b/src/App.zig @@ -103,8 +103,8 @@ pub fn tick(self: *App, rt_app: *apprt.App) !bool { // doesn't want to quit, then we can't force it to. defer self.quit = false; - // We quit if our quit flag is on or if we have closed all surfaces. - return self.quit or self.surfaces.items.len == 0; + // We quit if our quit flag is on + return self.quit; } /// Update the configuration associated with the app. This can only be diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 809ed6c329..fce84beab0 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -111,7 +111,7 @@ pub const App = struct { // Tick the terminal app const should_quit = try self.app.tick(self); - if (should_quit) { + if (should_quit or self.app.surfaces.items.len == 0) { for (self.app.surfaces.items) |surface| { surface.close(false); } diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index ef299e31fe..caae5669eb 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -316,7 +316,7 @@ pub fn run(self: *App) !void { // Tick the terminal app const should_quit = try self.core_app.tick(self); - if (should_quit) self.quit(); + if (should_quit or self.core_app.surfaces.items.len == 0) self.quit(); } }