gtk: use up-to-date maximized & fullscreen state in syncAppearance

DerivedConfig's maximize and fullscreen should only ever be used during
window creation and nowhere else.
This commit is contained in:
Leah Amelia Chen
2025-03-26 19:24:36 +01:00
parent ed4260b3c2
commit ae3e92a3fb

View File

@ -473,11 +473,13 @@ pub fn syncAppearance(self: *Window) !void {
if (self.isQuickTerminal()) break :visible false; if (self.isQuickTerminal()) break :visible false;
// Unconditionally disable the header bar when fullscreened. // Unconditionally disable the header bar when fullscreened.
if (self.config.fullscreen) break :visible false; if (self.window.as(gtk.Window).isFullscreen() != 0)
break :visible false;
// *Conditionally* disable the header bar when maximized, // *Conditionally* disable the header bar when maximized,
// and gtk-titlebar-hide-when-maximized is set // and gtk-titlebar-hide-when-maximized is set
if (self.config.maximize and self.config.gtk_titlebar_hide_when_maximized) if (self.window.as(gtk.Window).isMaximized() != 0 and
self.config.gtk_titlebar_hide_when_maximized)
break :visible false; break :visible false;
break :visible self.config.gtk_titlebar; break :visible self.config.gtk_titlebar;
@ -672,7 +674,7 @@ pub fn toggleTabOverview(self: *Window) void {
/// Toggle the maximized state for this window. /// Toggle the maximized state for this window.
pub fn toggleMaximize(self: *Window) void { pub fn toggleMaximize(self: *Window) void {
if (self.config.maximize) { if (self.window.as(gtk.Window).isMaximized() != 0) {
self.window.as(gtk.Window).unmaximize(); self.window.as(gtk.Window).unmaximize();
} else { } else {
self.window.as(gtk.Window).maximize(); self.window.as(gtk.Window).maximize();
@ -683,7 +685,7 @@ pub fn toggleMaximize(self: *Window) void {
/// Toggle fullscreen for this window. /// Toggle fullscreen for this window.
pub fn toggleFullscreen(self: *Window) void { pub fn toggleFullscreen(self: *Window) void {
if (self.config.fullscreen) { if (self.window.as(gtk.Window).isFullscreen() != 0) {
self.window.as(gtk.Window).unfullscreen(); self.window.as(gtk.Window).unfullscreen();
} else { } else {
self.window.as(gtk.Window).fullscreen(); self.window.as(gtk.Window).fullscreen();
@ -754,7 +756,6 @@ fn gtkWindowNotifyMaximized(
_: *gobject.ParamSpec, _: *gobject.ParamSpec,
self: *Window, self: *Window,
) callconv(.c) void { ) callconv(.c) void {
self.config.maximize = self.window.as(gtk.Window).isMaximized() != 0;
self.syncAppearance() catch |err| { self.syncAppearance() catch |err| {
log.err("failed to sync appearance={}", .{err}); log.err("failed to sync appearance={}", .{err});
}; };
@ -765,7 +766,6 @@ fn gtkWindowNotifyFullscreened(
_: *gobject.ParamSpec, _: *gobject.ParamSpec,
self: *Window, self: *Window,
) callconv(.c) void { ) callconv(.c) void {
self.config.fullscreen = self.window.as(gtk.Window).isFullscreen() != 0;
self.syncAppearance() catch |err| { self.syncAppearance() catch |err| {
log.err("failed to sync appearance={}", .{err}); log.err("failed to sync appearance={}", .{err});
}; };