From f3d8aac1e9b44b33a0e6bdf41107a9ccd5d45f86 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Wed, 20 Aug 2025 02:53:41 +0800 Subject: [PATCH] gtk-ng: fix toggle_window_decoration When window-decoration=none, setting the window decoration to null would just mean it would default to none again, creating a cycle of torment none can break out of... that sounds a bit too dramatic doesn't it Fixes #8274 --- src/apprt/gtk-ng/class/application.zig | 2 +- src/apprt/gtk-ng/class/window.zig | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/apprt/gtk-ng/class/application.zig b/src/apprt/gtk-ng/class/application.zig index bfecab3e1..29a124798 100644 --- a/src/apprt/gtk-ng/class/application.zig +++ b/src/apprt/gtk-ng/class/application.zig @@ -2216,7 +2216,7 @@ const Action = struct { Window, surface.as(gtk.Widget), ) orelse { - log.warn("surface is not in a window, ignoring new_tab", .{}); + log.warn("surface is not in a window, ignoring toggle_window_decorations", .{}); return false; }; diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index 18e9178ac..502b4dc78 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -780,9 +780,18 @@ pub const Window = extern struct { /// Toggle the window decorations for this window. pub fn toggleWindowDecorations(self: *Self) void { - self.setWindowDecoration(switch (self.getWindowDecoration()) { - // Null will force using the central config - .none => null, + const priv = self.private(); + + if (priv.window_decoration) |_| { + // Unset any previously set window decoration settings + self.setWindowDecoration(null); + return; + } + + const config = if (priv.config) |v| v.get() else return; + self.setWindowDecoration(switch (config.@"window-decoration") { + // Use auto when the decoration is initially none + .none => .auto, // Anything non-none to none .auto, .client, .server => .none,