apprt: all implement close surface

This commit is contained in:
Mitchell Hashimoto
2023-03-18 19:25:54 -07:00
parent d83bf5aeb4
commit 00c837e0d2
4 changed files with 10 additions and 5 deletions

View File

@ -482,9 +482,9 @@ pub fn deinit(self: *Surface) void {
/// Close this surface. This will trigger the runtime to start the /// Close this surface. This will trigger the runtime to start the
/// close process, which should ultimately deinitialize this surface. /// close process, which should ultimately deinitialize this surface.
pub fn close(self: *Surface) void { pub fn close(self: *Surface) void {
if (@hasDecl(apprt.Surface, "closeSurface")) { if (@hasDecl(apprt.Surface, "close")) {
try self.rt_surface.closeSurface(); self.rt_surface.close();
} else log.warn("runtime doesn't implement closeSurface", .{}); } else log.warn("runtime doesn't implement close", .{});
} }
/// Called from the app thread to handle mailbox messages to our specific /// Called from the app thread to handle mailbox messages to our specific

View File

@ -167,7 +167,7 @@ pub const Surface = struct {
func(self.opts.userdata, direction); func(self.opts.userdata, direction);
} }
pub fn closeSurface(self: *const Surface) !void { pub fn close(self: *const Surface) void {
const func = self.app.opts.close_surface orelse { const func = self.app.opts.close_surface orelse {
log.info("runtime embedder does not support closing a surface", .{}); log.info("runtime embedder does not support closing a surface", .{});
return; return;

View File

@ -378,6 +378,11 @@ pub const Surface = struct {
try self.app.newTab(&self.core_surface); try self.app.newTab(&self.core_surface);
} }
/// Close this surface.
pub fn close(self: *const Surface) void {
self.window.setShouldClose(true);
}
/// Set the size limits of the window. /// Set the size limits of the window.
/// Note: this interface is not good, we should redo it if we plan /// Note: this interface is not good, we should redo it if we plan
/// to use this more. i.e. you can't set max width but no max height, /// to use this more. i.e. you can't set max width but no max height,

View File

@ -614,7 +614,7 @@ pub const Surface = struct {
} }
/// Close this surface. /// Close this surface.
fn close(self: *Surface) void { pub fn close(self: *Surface) void {
self.window.closeSurface(self); self.window.closeSurface(self);
} }