core window doesn't have reference to glfw window anymore!

This commit is contained in:
Mitchell Hashimoto
2022-12-30 15:18:32 -08:00
parent fe84686a1d
commit ba0cbecd79
3 changed files with 12 additions and 11 deletions

View File

@ -203,7 +203,7 @@ fn setQuit(self: *App) !void {
// Mark that all our windows should close
for (self.windows.items) |window| {
window.window.setShouldClose(true);
window.windowing_system.setShouldClose();
}
}

View File

@ -55,12 +55,6 @@ font_lib: font.Library,
font_group: *font.GroupCache,
font_size: font.face.DesiredSize,
/// The glfw window handle.
window: glfw.Window,
/// The glfw mouse cursor handle.
cursor: glfw.Cursor,
/// Imgui context
imgui_ctx: if (DevMode.enabled) *imgui.Context else void,
@ -356,8 +350,6 @@ pub fn create(alloc: Allocator, app: *App, config: *const Config) !*Window {
.font_lib = font_lib,
.font_group = font_group,
.font_size = font_size,
.window = winsys.window,
.cursor = winsys.cursor,
.renderer = renderer_impl,
.renderer_thread = render_thread,
.renderer_state = .{
@ -497,7 +489,7 @@ pub fn destroy(self: *Window) void {
}
pub fn shouldClose(self: Window) bool {
return self.window.shouldClose();
return self.windowing_system.shouldClose();
}
/// Add a window to the tab group of this window.
@ -521,7 +513,7 @@ pub fn handleMessage(self: *Window, msg: Message) !void {
// We know that our title should end in 0.
const slice = std.mem.sliceTo(@ptrCast([*:0]const u8, v), 0);
log.debug("changing title \"{s}\"", .{slice});
try self.window.setTitle(slice.ptr);
try self.windowing_system.setTitle(slice);
},
.cell_size => |size| try self.setCellSize(size),

View File

@ -184,6 +184,15 @@ pub const Window = struct {
self.window.setShouldClose(true);
}
/// Returns true if the window is flagged to close.
pub fn shouldClose(self: *const Window) bool {
return self.window.shouldClose();
}
pub fn setTitle(self: *Window, slice: [:0]const u8) !void {
try self.window.setTitle(slice.ptr);
}
/// The cursor position from glfw directly is in screen coordinates but
/// all our interface works in pixels.
fn cursorPosToPixels(self: *const Window, pos: glfw.Window.CursorPos) !glfw.Window.CursorPos {