From 1e37864cb8abbafa1adacd26cb6a473e4cace89f Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 18 Jul 2021 20:33:04 -0700 Subject: [PATCH] glfw: add Window.hintString Signed-off-by: Stephen Gutekanst --- glfw/src/Window.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig index 9dbb2de1..65df6f72 100644 --- a/glfw/src/Window.zig +++ b/glfw/src/Window.zig @@ -47,6 +47,34 @@ pub fn hint(hint_const: usize, value: isize) Error!void { try getError(); } +/// Sets the specified window hint to the desired value. +/// +/// This function sets hints for the next call to glfw.Window.create. The hints, once set, retain +/// their values until changed by a call to this function or glfw.Window.defaultHints, or until the +/// library is terminated. +/// +/// Only string type hints can be set with this function. Integer value hints are set with +/// glfw.Window.hint. +/// +/// This function does not check whether the specified hint values are valid. If you set hints to +/// invalid values this will instead be reported by the next call to glfw.window.create. +/// +/// Some hints are platform specific. These may be set on any platform but they will only affect +/// their specific platform. Other platforms will ignore them. Setting these hints requires no +/// platform specific headers or functions. +/// +/// Possible errors include glfw.Error.NotInitialized and glfw.Error.InvalidEnum. +/// +/// @pointer_lifetime The specified string is copied before this function returns. +/// +/// @thread_safety This function must only be called from the main thread. +/// +/// see also: window_hints, glfw.Window.hint, glfw.Window.defaultHints +pub fn hintString(hint_const: usize, value: [:0]const u8) Error!void { + c.glfwWindowHintString(@intCast(c_int, hint_const), &value[0]); + try getError(); +} + test "defaultHints" { const glfw = @import("main.zig"); try glfw.init(); @@ -63,3 +91,11 @@ test "hint" { try hint(glfw.focused, 1); try defaultHints(); } + +test "hintString" { + const glfw = @import("main.zig"); + try glfw.init(); + defer glfw.terminate(); + + try hintString(glfw.x11_class_name, "myclass"); +}