mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
Switch over to the IO thread. A messy commit!
This commit is contained in:
781
src/Window.zig
781
src/Window.zig
File diff suppressed because it is too large
Load Diff
@ -162,7 +162,8 @@ fn drainMailbox(self: *Thread) !void {
|
|||||||
log.debug("mailbox message={}", .{message});
|
log.debug("mailbox message={}", .{message});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size),
|
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size),
|
||||||
.small_write => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
||||||
|
.write_stable => |v| try self.impl.queueWrite(v),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
const renderer = @import("../renderer.zig");
|
const renderer = @import("../renderer.zig");
|
||||||
const terminal = @import("../terminal/main.zig");
|
const terminal = @import("../terminal/main.zig");
|
||||||
|
|
||||||
/// The messages that can be sent to an IO thread.
|
/// The messages that can be sent to an IO thread.
|
||||||
pub const IO = union(enum) {
|
pub const IO = union(enum) {
|
||||||
pub const SmallWriteArray = [22]u8;
|
|
||||||
|
|
||||||
/// Resize the window.
|
/// Resize the window.
|
||||||
resize: struct {
|
resize: struct {
|
||||||
grid_size: renderer.GridSize,
|
grid_size: renderer.GridSize,
|
||||||
@ -13,10 +12,35 @@ pub const IO = union(enum) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// Write where the data fits in the union.
|
/// Write where the data fits in the union.
|
||||||
small_write: struct {
|
write_small: WriteReq.Small,
|
||||||
data: [22]u8,
|
|
||||||
|
/// Write where the data pointer is stable.
|
||||||
|
write_stable: []const u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Represents a write request.
|
||||||
|
pub const WriteReq = union(enum) {
|
||||||
|
pub const Small = struct {
|
||||||
|
pub const Array = [22]u8;
|
||||||
|
data: Array,
|
||||||
len: u8,
|
len: u8,
|
||||||
},
|
};
|
||||||
|
|
||||||
|
pub const Alloc = struct {
|
||||||
|
alloc: Allocator,
|
||||||
|
data: []u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// A small write where the data fits into this union size.
|
||||||
|
small: Small,
|
||||||
|
|
||||||
|
/// A stable pointer so we can just pass the slice directly through.
|
||||||
|
/// This is useful i.e. for const data.
|
||||||
|
stable: []const u8,
|
||||||
|
|
||||||
|
/// Allocated and must be freed with the provided allocator. This
|
||||||
|
/// should be rarely used.
|
||||||
|
alloc: Alloc,
|
||||||
};
|
};
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
Reference in New Issue
Block a user