rename more stuff

This commit is contained in:
Mitchell Hashimoto
2023-02-22 14:52:38 -08:00
parent fbe35c226b
commit 913131c8f1
10 changed files with 84 additions and 84 deletions

View File

@@ -83,6 +83,7 @@ pub const App = struct {
// Create the surface -- because windows are surfaces for glfw.
try surface.init(self);
errdefer surface.deinit();
}
fn glfwErrorCallback(code: glfw.ErrorCode, desc: [:0]const u8) void {
@@ -232,12 +233,15 @@ pub const Surface = struct {
// Initialize our surface now that we have the stable pointer.
try self.core_surface.init(app.app, app.app.config, self);
errdefer self.core_surface.destroy();
errdefer self.core_surface.deinit();
}
pub fn deinit(self: *Surface) void {
var tabgroup_opt: if (builtin.target.isDarwin()) ?objc.Object else void = undefined;
if (comptime builtin.target.isDarwin()) {
// First clean up our core surface so that all the rendering and IO stop.
self.core_surface.deinit();
var tabgroup_opt: if (App.Darwin.enabled) ?objc.Object else void = undefined;
if (App.Darwin.enabled) {
const nswindow = objc.Object.fromId(glfwNative.getCocoaWindow(self.window).?);
const tabgroup = nswindow.getProperty(objc.Object, "tabGroup");
@@ -286,7 +290,7 @@ pub const Surface = struct {
/// 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,
/// or no mins.
pub fn setSizeLimits(self: *Surface, min: apprt.WindowSize, max_: ?apprt.WindowSize) !void {
pub fn setSizeLimits(self: *Surface, min: apprt.SurfaceSize, max_: ?apprt.SurfaceSize) !void {
self.window.setSizeLimits(.{
.width = min.width,
.height = min.height,
@@ -308,9 +312,9 @@ pub const Surface = struct {
/// Returns the size of the window in pixels. The pixel size may
/// not match screen coordinate size but we should be able to convert
/// back and forth using getContentScale.
pub fn getSize(self: *const Surface) !apprt.WindowSize {
pub fn getSize(self: *const Surface) !apprt.SurfaceSize {
const size = self.window.getFramebufferSize();
return apprt.WindowSize{ .width = size.width, .height = size.height };
return apprt.SurfaceSize{ .width = size.width, .height = size.height };
}
/// Returns the cursor position in scaled pixels relative to the

View File

@@ -6,8 +6,8 @@ pub const ContentScale = struct {
y: f32,
};
/// The size of the window in pixels.
pub const WindowSize = struct {
/// The size of the surface in pixels.
pub const SurfaceSize = struct {
width: u32,
height: u32,
};

View File

@@ -3,13 +3,13 @@ const Surface = @import("../Surface.zig");
const renderer = @import("../renderer.zig");
const termio = @import("../termio.zig");
/// The message types that can be sent to a single window.
/// The message types that can be sent to a single surface.
pub const Message = union(enum) {
/// Represents a write request. Magic number comes from the max size
/// we want this union to be.
pub const WriteReq = termio.MessageData(u8, 256);
/// Set the title of the window.
/// Set the title of the surface.
/// TODO: we should change this to a "WriteReq" style structure in
/// the termio message so that we can more efficiently send strings
/// of any length
@@ -25,25 +25,25 @@ pub const Message = union(enum) {
clipboard_write: WriteReq,
};
/// A window mailbox.
/// A surface mailbox.
pub const Mailbox = struct {
window: *Surface,
surface: *Surface,
app: *App.Mailbox,
/// Send a message to the window.
/// Send a message to the surface.
pub fn push(self: Mailbox, msg: Message, timeout: App.Mailbox.Timeout) App.Mailbox.Size {
// Surface message sending is actually implemented on the app
// thread, so we have to rewrap the message with our window
// thread, so we have to rewrap the message with our surface
// pointer and send it to the app thread.
const result = self.app.push(.{
.surface_message = .{
.surface = self.window,
.surface = self.surface,
.message = msg,
},
}, timeout);
// Wake up our app loop
self.window.app.wakeup();
self.surface.app.wakeup();
return result;
}