glfw: accept null cursor in Window.setCursor

This commit is contained in:
Ali Chraghi 2022-12-28 20:47:44 +03:30 committed by Stephen Gutekanst
parent 6cd186fcab
commit 5e2abcbe22

View file

@ -2059,9 +2059,9 @@ pub inline fn setCursorPos(self: Window, xpos: f64, ypos: f64) error{PlatformErr
/// @thread_safety This function must only be called from the main thread. /// @thread_safety This function must only be called from the main thread.
/// ///
/// see also: cursor_object /// see also: cursor_object
pub inline fn setCursor(self: Window, cursor: Cursor) error{PlatformError}!void { pub inline fn setCursor(self: Window, cursor: ?Cursor) error{PlatformError}!void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
c.glfwSetCursor(self.handle, cursor.ptr); c.glfwSetCursor(self.handle, if (cursor) |cs| cs.ptr else null);
getError() catch |err| return switch (err) { getError() catch |err| return switch (err) {
Error.NotInitialized => unreachable, Error.NotInitialized => unreachable,
Error.PlatformError => |e| e, Error.PlatformError => |e| e,