diff --git a/src/Surface.zig b/src/Surface.zig index 1442af869..fe751299c 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -236,7 +236,7 @@ const DerivedConfig = struct { clipboard_paste_protection: bool, clipboard_paste_bracketed_safe: bool, copy_on_select: configpkg.CopyOnSelect, - confirm_close_surface: bool, + confirm_close_surface: configpkg.ConfirmCloseSurface, cursor_click_to_move: bool, desktop_notifications: bool, font: font.SharedGridSet.DerivedConfig, @@ -784,13 +784,19 @@ pub fn deactivateInspector(self: *Surface) void { /// True if the surface requires confirmation to quit. This should be called /// by apprt to determine if the surface should confirm before quitting. pub fn needsConfirmQuit(self: *Surface) bool { - // If the child has exited then our process is certainly not alive. - // We check this first to avoid the locking overhead below. - if (self.child_exited) return false; - - // If we are configured to not hold open surfaces explicitly, just - // always say there is nothing alive. - if (!self.config.confirm_close_surface) return false; + // Contract: + // always -> confirm always (even if the child process has exited) + // true -> confirm only if we have child process running + // false -> no need to confirm, just exit + switch (self.config.confirm_close_surface) { + .false => return false, + .true => { + if (self.child_exited) { + return false; + } + }, + .always => {} + } // We have to talk to the terminal. self.renderer_state.mutex.lock(); diff --git a/src/config.zig b/src/config.zig index b7e818f8e..9918bdfc1 100644 --- a/src/config.zig +++ b/src/config.zig @@ -29,6 +29,7 @@ pub const RepeatableString = Config.RepeatableString; pub const RepeatablePath = Config.RepeatablePath; pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures; pub const WindowPaddingColor = Config.WindowPaddingColor; +pub const ConfirmCloseSurface = Config.ConfirmCloseSurface; // Alternate APIs pub const CAPI = @import("config/CAPI.zig"); diff --git a/src/config/Config.zig b/src/config/Config.zig index c6702bb74..02b4be3b3 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1306,7 +1306,7 @@ keybind: Keybinds = .{}, /// Confirms that a surface should be closed before closing it. This defaults to /// true. If set to false, surfaces will close without any confirmation. -@"confirm-close-surface": bool = true, +@"confirm-close-surface": ConfirmCloseSurface = ConfirmCloseSurface.true, /// Whether or not to quit after the last surface is closed. /// @@ -5331,6 +5331,13 @@ pub const AutoUpdate = enum { download, }; +/// See confirm-close-surface +pub const ConfirmCloseSurface = enum { + false, + true, + always, +}; + /// See theme pub const Theme = struct { light: []const u8,