mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
gtk(x11): update blur region upon syncAppearance
Fixes a bug where the blur region offset used to accomodate CSDs are applied even when CSDs are disabled.
This commit is contained in:
@ -661,8 +661,9 @@ fn gtkWindowNotifyMaximized(
|
|||||||
fn gtkWindowNotifyDecorated(
|
fn gtkWindowNotifyDecorated(
|
||||||
object: *c.GObject,
|
object: *c.GObject,
|
||||||
_: *c.GParamSpec,
|
_: *c.GParamSpec,
|
||||||
_: ?*anyopaque,
|
ud: ?*anyopaque,
|
||||||
) callconv(.C) void {
|
) callconv(.C) void {
|
||||||
|
const self = userdataSelf(ud orelse return);
|
||||||
const is_decorated = c.gtk_window_get_decorated(@ptrCast(object)) == 1;
|
const is_decorated = c.gtk_window_get_decorated(@ptrCast(object)) == 1;
|
||||||
|
|
||||||
// Fix any artifacting that may occur in window corners. The .ssd CSS
|
// 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.
|
// for .ssd is provided by GTK and Adwaita.
|
||||||
toggleCssClass(@ptrCast(object), "ssd", !is_decorated);
|
toggleCssClass(@ptrCast(object), "ssd", !is_decorated);
|
||||||
toggleCssClass(@ptrCast(object), "no-border-radius", !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(
|
fn gtkWindowNotifyFullscreened(
|
||||||
|
@ -157,7 +157,7 @@ pub const Window = struct {
|
|||||||
config: DerivedConfig,
|
config: DerivedConfig,
|
||||||
window: c.Window,
|
window: c.Window,
|
||||||
gtk_window: *c.GtkWindow,
|
gtk_window: *c.GtkWindow,
|
||||||
blur_region: Region,
|
blur_region: Region = .{},
|
||||||
|
|
||||||
const DerivedConfig = struct {
|
const DerivedConfig = struct {
|
||||||
blur: bool,
|
blur: bool,
|
||||||
@ -190,34 +190,11 @@ pub const Window = struct {
|
|||||||
c.gdk_x11_surface_get_type(),
|
c.gdk_x11_surface_get_type(),
|
||||||
) == 0) return error.NotX11Surface;
|
) == 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 .{
|
return .{
|
||||||
.app = app,
|
.app = app,
|
||||||
.config = DerivedConfig.init(config),
|
.config = DerivedConfig.init(config),
|
||||||
.window = c.gdk_x11_surface_get_xid(surface),
|
.window = c.gdk_x11_surface_get_xid(surface),
|
||||||
.gtk_window = gtk_window,
|
.gtk_window = gtk_window,
|
||||||
.blur_region = blur_region,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +218,24 @@ pub const Window = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn syncAppearance(self: *Window) !void {
|
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();
|
try self.syncBlur();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user