From 8432b086b17467c58a7601f8d0e88adae7d5f275 Mon Sep 17 00:00:00 2001 From: Atlas Yu Date: Tue, 14 Jan 2025 17:27:47 +0800 Subject: [PATCH] fix(gtk/toggle_fullscreen): header bar visibility While unfullscreen the window, header.setVisible(true) will be called. For .gtk it's okay, because it will follows the window-decoration, while .adw doesn't. After #4850, the header is always created and added to the window, so setting visibility to the correct value is vital for .adw. Fixes: #4850 --- src/apprt/gtk/Window.zig | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 3c8c2c2e7..bc53a5af4 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -538,8 +538,8 @@ pub fn toggleMaximize(self: *Window) void { /// Toggle fullscreen for this window. pub fn toggleFullscreen(self: *Window) void { - const is_fullscreen = c.gtk_window_is_fullscreen(self.window); - if (is_fullscreen == 0) { + const is_fullscreen = c.gtk_window_is_fullscreen(self.window) == 1; + if (!is_fullscreen) { c.gtk_window_fullscreen(self.window); } else { c.gtk_window_unfullscreen(self.window); @@ -642,7 +642,18 @@ fn gtkWindowNotifyFullscreened( ud: ?*anyopaque, ) callconv(.C) void { const self = userdataSelf(ud orelse return); - self.headerbar.setVisible(c.gtk_window_is_fullscreen(@ptrCast(object)) == 0); + const is_fullscreen = c.gtk_window_is_fullscreen(@ptrCast(object)) == 1; + + const visible = if (is_fullscreen) + false + else switch (self.headerbar) { + // gtk will follow the window decorations + .gtk => true, + // adw need the explicit setting + .adw => c.gtk_window_get_decorated(self.window) == 1, + }; + + self.headerbar.setVisible(visible); } // Note: we MUST NOT use the GtkButton parameter because gtkActionNewTab