From a690b84732c31e31b585d21dc813d476f3ba86c9 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Fri, 23 Jul 2021 14:05:54 -0700 Subject: [PATCH] glfw: better handle Wayland limitations Signed-off-by: Stephen Gutekanst --- glfw/src/Monitor.zig | 5 ++++- glfw/src/Window.zig | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/glfw/src/Monitor.zig b/glfw/src/Monitor.zig index 1177838d..8f591175 100644 --- a/glfw/src/Monitor.zig +++ b/glfw/src/Monitor.zig @@ -529,7 +529,10 @@ test "set_getGammaRamp" { const monitor = try getPrimary(); if (monitor) |m| { - const ramp = try m.getGammaRamp(); + const ramp = m.getGammaRamp() catch |err| { + std.debug.print("can't get window position, wayland maybe? error={}\n", .{err}); + return; + }; // Set it to the exact same value; if we do otherwise an our tests fail it wouldn't call // terminate and our made-up gamma ramp would get stuck. diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig index 9658274a..670b13bb 100644 --- a/glfw/src/Window.zig +++ b/glfw/src/Window.zig @@ -447,7 +447,8 @@ test "setIcon" { icon.pixels[(x * y * 4) + 3] = 255; // alpha } } - try window.setIcon(allocator, &[_]Image{icon}); + window.setIcon(allocator, &[_]Image{icon}) catch |err| std.debug.print("can't set window icon, wayland maybe? error={}\n", .{err}); + icon.deinit(allocator); // glfw copies it. } @@ -464,5 +465,5 @@ test "getPos" { }; defer window.destroy(); - _ = try window.getPos(); + _ = window.getPos() catch |err| std.debug.print("can't get window position, wayland maybe? error={}\n", .{err}); }