Skip to content

Commit

Permalink
gtk: also add css window-decorated class when toggling window decorat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
jcollie committed Dec 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 220d40e commit f97f7e8
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/apprt/gtk/Window.zig
Original file line number Diff line number Diff line change
@@ -514,13 +514,19 @@ pub fn toggleWindowDecorations(self: *Window) void {
const new_decorated = !old_decorated;
c.gtk_window_set_decorated(self.window, @intFromBool(new_decorated));

// Fix any artifacting that may occur in window corners.
if (new_decorated) {
c.gtk_widget_add_css_class(@ptrCast(self.window), "without-window-decoration-and-with-titlebar");
} else {
c.gtk_widget_remove_css_class(@ptrCast(self.window), "without-window-decoration-and-with-titlebar");
}

// If we have a titlebar, then we also show/hide it depending on the
// decorated state. GTK tends to consider the titlebar part of the frame
// and hides it with decorations, but libadwaita doesn't. This makes it
// explicit.
if (self.header) |v| {
const widget = v.asWidget();
c.gtk_widget_set_visible(widget, @intFromBool(new_decorated));
if (self.header) |headerbar| {
headerbar.setVisible(new_decorated);
}
}

2 changes: 1 addition & 1 deletion src/apprt/gtk/headerbar.zig
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ pub const HeaderBar = union(enum) {
}

pub fn setVisible(self: HeaderBar, visible: bool) void {
c.gtk_widget_set_visible(self.asWidget(), if (visible) 1 else 0);
c.gtk_widget_set_visible(self.asWidget(), @intFromBool(visible));
}

pub fn asWidget(self: HeaderBar) *c.GtkWidget {

0 comments on commit f97f7e8

Please sign in to comment.