Revert "Merge pull request #2060 from jcollie/gtk-compatibility"

This reverts commit 9ce789cc85d411c59eff2a01c7fe18ce14ccd2b8, reversing
changes made to f1aea10a84176ff4338f7d2f0bf1b9c700b41baa.
This commit is contained in:
Mitchell Hashimoto
2024-09-05 08:45:37 -07:00
parent 2c48e86a86
commit a3aa5463a1
2 changed files with 4 additions and 16 deletions

View File

@ -21,8 +21,7 @@ const ClipboardConfirmationWindow = @import("ClipboardConfirmationWindow.zig");
const ResizeOverlay = @import("ResizeOverlay.zig"); const ResizeOverlay = @import("ResizeOverlay.zig");
const inspector = @import("inspector.zig"); const inspector = @import("inspector.zig");
const gtk_key = @import("key.zig"); const gtk_key = @import("key.zig");
const cpkg = @import("c.zig"); const c = @import("c.zig").c;
const c = cpkg.c;
const x11 = @import("x11.zig"); const x11 = @import("x11.zig");
const log = std.log.scoped(.gtk_surface); const log = std.log.scoped(.gtk_surface);
@ -823,15 +822,9 @@ pub fn shouldClose(self: *const Surface) bool {
} }
pub fn getContentScale(self: *const Surface) !apprt.ContentScale { pub fn getContentScale(self: *const Surface) !apprt.ContentScale {
const gtk_scale: f32 = scale: { // Future: detect GTK version 4.12+ and use gdk_surface_get_scale so we
if (comptime cpkg.gtkVersionAtLeast(4, 12)) { // can support fractional scaling.
const native = c.gtk_widget_get_native(@ptrCast(self.gl_area)); const gtk_scale: f32 = @floatFromInt(c.gtk_widget_get_scale_factor(@ptrCast(self.gl_area)));
const surface = c.gtk_native_get_surface(native);
break :scale @floatCast(c.gdk_surface_get_scale(surface));
} else {
break :scale @floatFromInt(c.gtk_widget_get_scale_factor(@ptrCast(self.gl_area)));
}
};
// If we are on X11, we also have to scale using Xft.dpi // If we are on X11, we also have to scale using Xft.dpi
const xft_dpi_scale = if (!x11.is_current_display_server()) 1.0 else xft_scale: { const xft_dpi_scale = if (!x11.is_current_display_server()) 1.0 else xft_scale: {

View File

@ -17,8 +17,3 @@ pub const c = @cImport({
// compatibility // compatibility
@cInclude("ghostty_gtk_compat.h"); @cInclude("ghostty_gtk_compat.h");
}); });
pub fn gtkVersionAtLeast(comptime major: c_int, comptime minor: c_int) bool {
return (c.GTK_MAJOR_VERSION > major or
(c.GTK_MAJOR_VERSION == major and c.GTK_MINOR_VERSION >= minor));
}