Skip to content

Commit facda0c

Browse files
authored
gtk(x11): update blur region upon syncAppearance (#5443)
Fixes a bug where the blur region offset used to accomodate CSDs are applied even when CSDs are disabled.
2 parents 75dec59 + 48a1a10 commit facda0c

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

‎src/apprt/gtk/Window.zig‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,9 @@ fn gtkWindowNotifyMaximized(
658658
fn gtkWindowNotifyDecorated(
659659
object: *c.GObject,
660660
_: *c.GParamSpec,
661-
_: ?*anyopaque,
661+
ud: ?*anyopaque,
662662
) callconv(.C) void {
663+
const self = userdataSelf(ud orelse return);
663664
const is_decorated = c.gtk_window_get_decorated(@ptrCast(object)) == 1;
664665

665666
// Fix any artifacting that may occur in window corners. The .ssd CSS
@@ -668,6 +669,11 @@ fn gtkWindowNotifyDecorated(
668669
// for .ssd is provided by GTK and Adwaita.
669670
toggleCssClass(@ptrCast(object), "ssd", !is_decorated);
670671
toggleCssClass(@ptrCast(object), "no-border-radius", !is_decorated);
672+
673+
// FIXME: This is to update the blur region offset on X11.
674+
// Remove this when we move everything related to window appearance
675+
// to `syncAppearance` for Ghostty 1.2.
676+
self.winproto.syncAppearance() catch {};
671677
}
672678

673679
fn gtkWindowNotifyFullscreened(

‎src/apprt/gtk/winproto/x11.zig‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub const Window = struct {
157157
config: DerivedConfig,
158158
window: c.Window,
159159
gtk_window: *c.GtkWindow,
160-
blur_region: Region,
160+
blur_region: Region = .{},
161161

162162
const DerivedConfig = struct {
163163
blur: bool,
@@ -190,34 +190,11 @@ pub const Window = struct {
190190
c.gdk_x11_surface_get_type(),
191191
) == 0) return error.NotX11Surface;
192192

193-
const blur_region: Region = blur: {
194-
if ((comptime !adwaita.versionAtLeast(0, 0, 0)) or
195-
!adwaita.enabled(config)) break :blur .{};
196-
197-
// NOTE(pluiedev): CSDs are a f--king mistake.
198-
// Please, GNOME, stop this nonsense of making a window ~30% bigger
199-
// internally than how they really are just for your shadows and
200-
// rounded corners and all that fluff. Please. I beg of you.
201-
var x: f64 = 0;
202-
var y: f64 = 0;
203-
c.gtk_native_get_surface_transform(
204-
@ptrCast(gtk_window),
205-
&x,
206-
&y,
207-
);
208-
209-
break :blur .{
210-
.x = @intFromFloat(x),
211-
.y = @intFromFloat(y),
212-
};
213-
};
214-
215193
return .{
216194
.app = app,
217195
.config = DerivedConfig.init(config),
218196
.window = c.gdk_x11_surface_get_xid(surface),
219197
.gtk_window = gtk_window,
220-
.blur_region = blur_region,
221198
};
222199
}
223200

@@ -241,6 +218,24 @@ pub const Window = struct {
241218
}
242219

243220
pub fn syncAppearance(self: *Window) !void {
221+
self.blur_region = blur: {
222+
// NOTE(pluiedev): CSDs are a f--king mistake.
223+
// Please, GNOME, stop this nonsense of making a window ~30% bigger
224+
// internally than how they really are just for your shadows and
225+
// rounded corners and all that fluff. Please. I beg of you.
226+
var x: f64 = 0;
227+
var y: f64 = 0;
228+
c.gtk_native_get_surface_transform(
229+
@ptrCast(self.gtk_window),
230+
&x,
231+
&y,
232+
);
233+
234+
break :blur .{
235+
.x = @intFromFloat(x),
236+
.y = @intFromFloat(y),
237+
};
238+
};
244239
try self.syncBlur();
245240
}
246241

0 commit comments

Comments
 (0)