glfw: add Window.maximize

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-10-16 14:05:54 -07:00 committed by Stephen Gutekanst
parent 78a048d82e
commit b3df40bdb9

View file

@ -654,6 +654,23 @@ pub inline fn restore(self: Window) Error!void {
try getError(); try getError();
} }
/// Maximizes the specified window.
///
/// This function maximizes the specified window if it was previously not maximized. If the window
/// is already maximized, this function does nothing.
///
/// If the specified window is a full screen window, this function does nothing.
///
/// 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_iconify, glfw.Window.iconify, glfw.Window.restore
pub inline fn maximize(self: Window) Error!void {
c.glfwMaximizeWindow(self.handle);
try getError();
}
test "defaultHints" { test "defaultHints" {
const glfw = @import("main.zig"); const glfw = @import("main.zig");
try glfw.init(); try glfw.init();
@ -952,3 +969,19 @@ test "restore" {
_ = window.restore() catch |err| std.debug.print("can't restore window, not supported by OS maybe? error={}\n", .{err}); _ = window.restore() catch |err| std.debug.print("can't restore window, not supported by OS maybe? error={}\n", .{err});
} }
test "maximize" {
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.maximize() catch |err| std.debug.print("can't maximize window, not supported by OS maybe? error={}\n", .{err});
}