Jeffrey C. Ollie b6c943386c Conditional compilation against different GTK versions
Adds a comptime function to enable conditional compilation against
different GTK versions that have added new API calls in newer versions
of GTK.

Use this function to get fractional scaling information for GTK
surfaces, which is only available with GTK 4.12+.
2024-08-31 19:15:24 -07:00

25 lines
732 B
Zig

/// Imported C API directly from header files
pub const c = @cImport({
@cInclude("gtk/gtk.h");
if (@import("build_options").libadwaita) {
@cInclude("libadwaita-1/adwaita.h");
}
// Add in X11-specific GDK backend which we use for specific things
// (e.g. X11 window class).
@cInclude("gdk/x11/gdkx.h");
// Xkb for X11 state handling
@cInclude("X11/XKBlib.h");
// generated header files
@cInclude("ghostty_resources.h");
// compatibility
@cInclude("ghostty_gtk_compat.h");
});
pub fn gtkVersionMinimum(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));
}