glfw: update system_sdk for wayland and catch wayland test errors

This commit is contained in:
PiergiorgioZagaria 2022-06-28 20:20:40 +02:00 committed by Stephen Gutekanst
parent b4ea44c647
commit d7c4c730ad
3 changed files with 19 additions and 12 deletions

View file

@ -318,6 +318,7 @@ pub inline fn setGamma(self: Monitor, gamma: f32) error{PlatformError}!void {
/// ///
/// wayland: Gamma handling is a privileged protocol, this function will thus never be implemented /// wayland: Gamma handling is a privileged protocol, this function will thus never be implemented
/// and returns glfw.Error.PlatformError. /// and returns glfw.Error.PlatformError.
/// TODO: Is the documentation obsolete? On wayland the error returned is FeatureUnavailable
/// ///
/// The returned gamma ramp is `.owned = true` by GLFW, and is valid until the monitor is /// The returned gamma ramp is `.owned = true` by GLFW, and is valid until the monitor is
/// disconnected, this function is called again, or `glfw.terminate()` is called. /// disconnected, this function is called again, or `glfw.terminate()` is called.
@ -325,12 +326,12 @@ pub inline fn setGamma(self: Monitor, gamma: f32) error{PlatformError}!void {
/// @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: monitor_gamma /// see also: monitor_gamma
pub inline fn getGammaRamp(self: Monitor) error{PlatformError}!GammaRamp { pub inline fn getGammaRamp(self: Monitor) error{ PlatformError, FeatureUnavailable }!GammaRamp {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
if (c.glfwGetGammaRamp(self.handle)) |ramp| return GammaRamp.fromC(ramp.*); if (c.glfwGetGammaRamp(self.handle)) |ramp| return GammaRamp.fromC(ramp.*);
getError() catch |err| return switch (err) { getError() catch |err| return switch (err) {
Error.NotInitialized => unreachable, Error.NotInitialized => unreachable,
Error.PlatformError => |e| e, Error.PlatformError, Error.FeatureUnavailable => |e| e,
else => unreachable, else => unreachable,
}; };
// `glfwGetGammaRamp` returns `null` only for errors // `glfwGetGammaRamp` returns `null` only for errors

View file

@ -751,7 +751,9 @@ pub inline fn setSizeLimits(self: Window, min: SizeOptional, max: SizeOptional)
/// @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: window_sizelimits, glfw.Window.setSizeLimits /// see also: window_sizelimits, glfw.Window.setSizeLimits
pub inline fn setAspectRatio(self: Window, numerator: ?u32, denominator: ?u32) error{PlatformError}!void { ///
/// WARNING: on wayland it will return Error.FeatureUnimplemented
pub inline fn setAspectRatio(self: Window, numerator: ?u32, denominator: ?u32) error{ PlatformError, FeatureUnimplemented }!void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
if (numerator != null and denominator != null) { if (numerator != null and denominator != null) {
@ -767,7 +769,7 @@ pub inline fn setAspectRatio(self: Window, numerator: ?u32, denominator: ?u32) e
getError() catch |err| return switch (err) { getError() catch |err| return switch (err) {
Error.NotInitialized => unreachable, Error.NotInitialized => unreachable,
Error.InvalidValue => unreachable, Error.InvalidValue => unreachable,
Error.PlatformError => |e| e, Error.PlatformError, Error.FeatureUnimplemented => |e| e,
else => unreachable, else => unreachable,
}; };
} }
@ -1010,12 +1012,14 @@ pub inline fn maximize(self: Window) error{PlatformError}!void {
/// @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: window_hide, glfw.Window.hide /// see also: window_hide, glfw.Window.hide
pub inline fn show(self: Window) error{PlatformError}!void { ///
/// WARNING: on wayland it will return Error.FeatureUnavailable
pub inline fn show(self: Window) error{ PlatformError, FeatureUnavailable }!void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
c.glfwShowWindow(self.handle); c.glfwShowWindow(self.handle);
getError() catch |err| return switch (err) { getError() catch |err| return switch (err) {
Error.NotInitialized => unreachable, Error.NotInitialized => unreachable,
Error.PlatformError => |e| e, Error.PlatformError, Error.FeatureUnavailable => |e| e,
else => unreachable, else => unreachable,
}; };
} }
@ -1087,12 +1091,14 @@ pub inline fn focus(self: Window) error{ PlatformError, FeatureUnavailable }!voi
/// @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: window_attention /// see also: window_attention
pub inline fn requestAttention(self: Window) error{PlatformError}!void { ///
/// WARNING: on wayland it will return Error.FeatureUnimplemented
pub inline fn requestAttention(self: Window) error{ PlatformError, FeatureUnimplemented }!void {
internal_debug.assertInitialized(); internal_debug.assertInitialized();
c.glfwRequestWindowAttention(self.handle); c.glfwRequestWindowAttention(self.handle);
getError() catch |err| return switch (err) { getError() catch |err| return switch (err) {
Error.NotInitialized => unreachable, Error.NotInitialized => unreachable,
Error.PlatformError => |e| e, Error.PlatformError, Error.FeatureUnimplemented => |e| e,
else => unreachable, else => unreachable,
}; };
} }
@ -2699,7 +2705,7 @@ test "setAspectRatio" {
}; };
defer window.destroy(); defer window.destroy();
try window.setAspectRatio(4, 3); window.setAspectRatio(4, 3) catch |err| std.debug.print("can't modify aspect ratio, wayland maybe? error={}\n", .{err});
} }
test "getFramebufferSize" { test "getFramebufferSize" {
@ -2879,7 +2885,7 @@ test "swapBuffers" {
}; };
defer window.destroy(); defer window.destroy();
_ = try window.swapBuffers(); _ = window.swapBuffers() catch |err| std.debug.print("can't swap buffers, wayland maybe? error={}\n", .{err});
} }
test "getMonitor" { test "getMonitor" {

View file

@ -46,11 +46,11 @@ pub const Options = struct {
/// The Linux x86-64 SDK repository name. /// The Linux x86-64 SDK repository name.
linux_x86_64: []const u8 = "sdk-linux-x86_64", linux_x86_64: []const u8 = "sdk-linux-x86_64",
linux_x86_64_revision: []const u8 = "080c403e2f0874fea02361e3c4501b79b3c0fade", linux_x86_64_revision: []const u8 = "baace69c969b7577fbcd2dda2d4e139fb3a7bdf7",
/// The Linux aarch64 SDK repository name. /// The Linux aarch64 SDK repository name.
linux_aarch64: []const u8 = "sdk-linux-aarch64", linux_aarch64: []const u8 = "sdk-linux-aarch64",
linux_aarch64_revision: []const u8 = "20414fe0f2cee80da348701dfc584025887592b2", linux_aarch64_revision: []const u8 = "8f6ddaf6cc25df02925ef78448d512c3184abc63",
/// The Windows x86-64 SDK repository name. /// The Windows x86-64 SDK repository name.
windows_x86_64: []const u8 = "sdk-windows-x86_64", windows_x86_64: []const u8 = "sdk-windows-x86_64",