diff --git a/src/Surface.zig b/src/Surface.zig index 9d2ee7f62..d83926b43 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -482,9 +482,9 @@ pub fn deinit(self: *Surface) void { /// Close this surface. This will trigger the runtime to start the /// close process, which should ultimately deinitialize this surface. pub fn close(self: *Surface) void { - if (@hasDecl(apprt.Surface, "closeSurface")) { - try self.rt_surface.closeSurface(); - } else log.warn("runtime doesn't implement closeSurface", .{}); + if (@hasDecl(apprt.Surface, "close")) { + self.rt_surface.close(); + } else log.warn("runtime doesn't implement close", .{}); } /// Called from the app thread to handle mailbox messages to our specific diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index 063743b44..8d12085a8 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -167,7 +167,7 @@ pub const Surface = struct { 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 { log.info("runtime embedder does not support closing a surface", .{}); return; diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 533887349..1995f03cd 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -378,6 +378,11 @@ pub const Surface = struct { 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. /// 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, diff --git a/src/apprt/gtk.zig b/src/apprt/gtk.zig index da69ed3e4..928947612 100644 --- a/src/apprt/gtk.zig +++ b/src/apprt/gtk.zig @@ -614,7 +614,7 @@ pub const Surface = struct { } /// Close this surface. - fn close(self: *Surface) void { + pub fn close(self: *Surface) void { self.window.closeSurface(self); }