apprt/gtk-ng: implement the quit_timer action to just quit

This commit is contained in:
Mitchell Hashimoto
2025-07-18 11:19:21 -07:00
parent 7c9e913ca9
commit 2ab5d3cd81
3 changed files with 29 additions and 4 deletions

View File

@ -203,9 +203,16 @@ pub const Action = union(Key) {
open_config, open_config,
/// Called when there are no more surfaces and the app should quit /// Called when there are no more surfaces and the app should quit
/// after the configured delay. This can be cancelled by sending /// after the configured delay.
/// another quit_timer action with "stop". Multiple "starts" shouldn't ///
/// happen and can be ignored or cause a restart it isn't that important. /// Despite the name, this is the notification that libghostty sends
/// when there are no more surfaces regardless of if the configuration
/// wants to quit after close, has any delay set, etc. It's up to the
/// apprt to implement the proper logic based on the config.
///
/// This can be cancelled by sending another quit_timer action with "stop".
/// Multiple "starts" shouldn't happen and can be ignored or cause a
/// restart it isn't that important.
quit_timer: QuitTimer, quit_timer: QuitTimer,
/// Set the window floating state. A floating window is one that is /// Set the window floating state. A floating window is one that is

View File

@ -378,6 +378,8 @@ pub const Application = extern struct {
}, },
), ),
.quit_timer => try Action.quitTimer(self, value),
// Unimplemented // Unimplemented
.quit, .quit,
.close_window, .close_window,
@ -407,7 +409,6 @@ pub const Application = extern struct {
.toggle_tab_overview, .toggle_tab_overview,
.toggle_split_zoom, .toggle_split_zoom,
.toggle_window_decorations, .toggle_window_decorations,
.quit_timer,
.prompt_title, .prompt_title,
.toggle_quick_terminal, .toggle_quick_terminal,
.secure_input, .secure_input,
@ -867,6 +868,21 @@ const Action = struct {
const win = Window.new(self); const win = Window.new(self);
gtk.Window.present(win.as(gtk.Window)); gtk.Window.present(win.as(gtk.Window));
} }
pub fn quitTimer(
self: *Application,
mode: apprt.action.QuitTimer,
) !void {
// TODO: An actual quit timer implementation. For now, we immediately
// quit on no windows regardless of the config.
switch (mode) {
.start => {
self.private().running = false;
},
.stop => {},
}
}
}; };
/// This sets various GTK-related environment variables as necessary /// This sets various GTK-related environment variables as necessary

View File

@ -220,6 +220,8 @@ pub const Surface = extern struct {
// Deinit the surface // Deinit the surface
v.deinit(); v.deinit();
const alloc = Application.default().allocator();
alloc.destroy(v);
} }
gobject.Object.virtual_methods.finalize.call( gobject.Object.virtual_methods.finalize.call(