glfw: add Window.show

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-10-16 14:09:06 -07:00 committed by Stephen Gutekanst
parent b3df40bdb9
commit 789a9224b7

View file

@ -671,6 +671,25 @@ pub inline fn maximize(self: Window) Error!void {
try getError();
}
/// Makes the specified window visible.
///
/// This function makes the specified window visible if it was previously hidden. If the window is
/// already visible or is in full screen mode, this function does nothing.
///
/// By default, windowed mode windows are focused when shown Set the glfw.focus_on_show window hint
/// to change this behavior for all newly created windows, or change the
/// behavior for an existing window with glfw.Window.setAttrib.
///
/// Possible errors include glfw.Error.NotInitialized and glfw.Error.PlatformError.
///
/// @thread_safety This function must only be called from the main thread.
///
/// see also: window_hide, glfw.Window.hide
pub inline fn show(self: Window) Error!void {
c.glfwShowWindow(self.handle);
try getError();
}
test "defaultHints" {
const glfw = @import("main.zig");
try glfw.init();
@ -985,3 +1004,19 @@ test "maximize" {
_ = window.maximize() catch |err| std.debug.print("can't maximize window, not supported by OS maybe? error={}\n", .{err});
}
test "show" {
const glfw = @import("main.zig");
try glfw.init();
defer glfw.terminate();
const window = glfw.Window.create(640, 480, "Hello, Zig!", null, null) catch |err| {
// return without fail, because most of our CI environments are headless / we cannot open
// windows on them.
std.debug.print("note: failed to create window: {}\n", .{err});
return;
};
defer window.destroy();
_ = window.show() catch |err| std.debug.print("can't show window, not supported by OS maybe? error={}\n", .{err});
}