From 4823524477f4c84d962e2a36bb3d00825cb758ef Mon Sep 17 00:00:00 2001 From: Adam Wolf Date: Wed, 12 Mar 2025 22:11:50 -0500 Subject: [PATCH] chore: remove window level toggle and utilize std.math.clamp in opengl --- src/apprt/gtk/Window.zig | 10 ---------- src/renderer/OpenGL.zig | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 16fcb70e7..6af20118b 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -661,16 +661,6 @@ pub fn toggleWindowDecorations(self: *Window) void { }; } -/// Toggle the background opacity for this window. -pub fn toggleBackgroundOpacity(self: *Window) !f64 { - if (self.app.config.@"background-opacity" >= 1) return self.app.config.@"background-opacity"; - - self.config.background_opacity = if (self.config.background_opacity == 1.0) self.app.config.@"background-opacity" else 1.0; - try self.syncAppearance(); - - return self.config.background_opacity; -} - /// Grabs focus on the currently selected tab. pub fn focusCurrentTab(self: *Window) void { const tab = self.notebook.currentTab() orelse return; diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 30e5a2efe..63103d6d4 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -661,7 +661,7 @@ pub fn setBackgroundOpacity(self: *OpenGL, opacity: f64) void { defer if (single_threaded_draw) self.draw_mutex.unlock(); // We don't want to go below 0 or above 1 - self.config.background_opacity = @max(0, @min(1, opacity)); + self.config.background_opacity = std.math.clamp(opacity, 0, 1); } /// Set the new font grid.