diff --git a/src/App.zig b/src/App.zig index 514dc813f..b83109f20 100644 --- a/src/App.zig +++ b/src/App.zig @@ -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(); } } diff --git a/src/Window.zig b/src/Window.zig index eb5f19e58..6559acc31 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -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), diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 4ca564df0..4973ca44f 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -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 {