From f92afebcb3dd7bb881005f78716fde11b3062ab6 Mon Sep 17 00:00:00 2001 From: PiergiorgioZagaria Date: Tue, 28 Jun 2022 20:20:40 +0200 Subject: [PATCH] glfw: update system_sdk for wayland and catch wayland test errors --- glfw/src/Monitor.zig | 5 +++-- glfw/src/Window.zig | 22 ++++++++++++++-------- glfw/system_sdk.zig | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/glfw/src/Monitor.zig b/glfw/src/Monitor.zig index 82631b27..dd3c08be 100644 --- a/glfw/src/Monitor.zig +++ b/glfw/src/Monitor.zig @@ -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 /// 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 /// 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. /// /// 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(); if (c.glfwGetGammaRamp(self.handle)) |ramp| return GammaRamp.fromC(ramp.*); getError() catch |err| return switch (err) { Error.NotInitialized => unreachable, - Error.PlatformError => |e| e, + Error.PlatformError, Error.FeatureUnavailable => |e| e, else => unreachable, }; // `glfwGetGammaRamp` returns `null` only for errors diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig index a5f9ad2d..88349bf2 100644 --- a/glfw/src/Window.zig +++ b/glfw/src/Window.zig @@ -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. /// /// 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(); 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) { Error.NotInitialized => unreachable, Error.InvalidValue => unreachable, - Error.PlatformError => |e| e, + Error.PlatformError, Error.FeatureUnimplemented => |e| e, 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. /// /// 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(); c.glfwShowWindow(self.handle); getError() catch |err| return switch (err) { Error.NotInitialized => unreachable, - Error.PlatformError => |e| e, + Error.PlatformError, Error.FeatureUnavailable => |e| e, 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. /// /// 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(); c.glfwRequestWindowAttention(self.handle); getError() catch |err| return switch (err) { Error.NotInitialized => unreachable, - Error.PlatformError => |e| e, + Error.PlatformError, Error.FeatureUnimplemented => |e| e, else => unreachable, }; } @@ -2699,7 +2705,7 @@ test "setAspectRatio" { }; 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" { @@ -2879,7 +2885,7 @@ test "swapBuffers" { }; defer window.destroy(); - _ = try window.swapBuffers(); + _ = window.swapBuffers() catch |err| std.debug.print("can't swap buffers, wayland maybe? error={}\n", .{err}); } test "getMonitor" { diff --git a/glfw/system_sdk.zig b/glfw/system_sdk.zig index 04358815..3b261630 100644 --- a/glfw/system_sdk.zig +++ b/glfw/system_sdk.zig @@ -46,11 +46,11 @@ pub const Options = struct { /// The Linux x86-64 SDK repository name. 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. 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. windows_x86_64: []const u8 = "sdk-windows-x86_64",