core: centralize EventQueue and EventIterator declaration

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-08-25 16:04:25 -07:00
parent 1fab277bf7
commit 2eac60caf1
4 changed files with 17 additions and 43 deletions

View file

@ -21,21 +21,12 @@ const KeyMods = Core.KeyMods;
const log = std.log.scoped(.mach);
const EventQueue = std.fifo.LinearFifo(Event, .Dynamic);
pub const EventIterator = struct {
queue: *EventQueue,
pub inline fn next(self: *EventIterator) ?Event {
return self.queue.readItem();
}
};
pub const Null = @This();
allocator: std.mem.Allocator,
core: *Core,
events: EventQueue,
events: Core.EventQueue,
input_state: Core.InputState,
modifiers: KeyMods,
@ -65,8 +56,8 @@ pub fn update(_: *Null) !void {
}
// May be called from any thread.
pub inline fn pollEvents(n: *Null) EventIterator {
return EventIterator{ .queue = &n.events };
pub inline fn pollEvents(n: *Null) Core.EventIterator {
return .{ .queue = &n.events };
}
// May be called from any thread.