mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
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.
This commit is contained in:
@ -658,8 +658,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
|
||||
@ -668,6 +669,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(
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user