diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 58f5659f0..28bbfe54f 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -661,8 +661,9 @@ fn gtkWindowNotifyMaximized( fn gtkWindowNotifyDecorated( object: *c.GObject, _: *c.GParamSpec, - _: ?*anyopaque, + ud: ?*anyopaque, ) callconv(.C) void { + const self = userdataSelf(ud orelse return); const is_decorated = c.gtk_window_get_decorated(@ptrCast(object)) == 1; // Fix any artifacting that may occur in window corners. The .ssd CSS @@ -671,6 +672,11 @@ fn gtkWindowNotifyDecorated( // for .ssd is provided by GTK and Adwaita. toggleCssClass(@ptrCast(object), "ssd", !is_decorated); toggleCssClass(@ptrCast(object), "no-border-radius", !is_decorated); + + // FIXME: This is to update the blur region offset on X11. + // Remove this when we move everything related to window appearance + // to `syncAppearance` for Ghostty 1.2. + self.winproto.syncAppearance() catch {}; } fn gtkWindowNotifyFullscreened( diff --git a/src/apprt/gtk/winproto/x11.zig b/src/apprt/gtk/winproto/x11.zig index 7a6b8b4c7..e7137a74d 100644 --- a/src/apprt/gtk/winproto/x11.zig +++ b/src/apprt/gtk/winproto/x11.zig @@ -157,7 +157,7 @@ pub const Window = struct { config: DerivedConfig, window: c.Window, gtk_window: *c.GtkWindow, - blur_region: Region, + blur_region: Region = .{}, const DerivedConfig = struct { blur: bool, @@ -190,34 +190,11 @@ pub const Window = struct { c.gdk_x11_surface_get_type(), ) == 0) return error.NotX11Surface; - const blur_region: Region = blur: { - if ((comptime !adwaita.versionAtLeast(0, 0, 0)) or - !adwaita.enabled(config)) break :blur .{}; - - // NOTE(pluiedev): CSDs are a f--king mistake. - // Please, GNOME, stop this nonsense of making a window ~30% bigger - // internally than how they really are just for your shadows and - // rounded corners and all that fluff. Please. I beg of you. - var x: f64 = 0; - var y: f64 = 0; - c.gtk_native_get_surface_transform( - @ptrCast(gtk_window), - &x, - &y, - ); - - break :blur .{ - .x = @intFromFloat(x), - .y = @intFromFloat(y), - }; - }; - return .{ .app = app, .config = DerivedConfig.init(config), .window = c.gdk_x11_surface_get_xid(surface), .gtk_window = gtk_window, - .blur_region = blur_region, }; } @@ -241,6 +218,24 @@ pub const Window = struct { } pub fn syncAppearance(self: *Window) !void { + self.blur_region = blur: { + // NOTE(pluiedev): CSDs are a f--king mistake. + // Please, GNOME, stop this nonsense of making a window ~30% bigger + // internally than how they really are just for your shadows and + // rounded corners and all that fluff. Please. I beg of you. + var x: f64 = 0; + var y: f64 = 0; + c.gtk_native_get_surface_transform( + @ptrCast(self.gtk_window), + &x, + &y, + ); + + break :blur .{ + .x = @intFromFloat(x), + .y = @intFromFloat(y), + }; + }; try self.syncBlur(); }