mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-15 10:21:58 +00:00
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. Key parts: * In addition to its previous responsibilities, the global state now houses state for global I/O implementations and the process environment. It is now also utilized in the main application along with the C library. Where necessary, global state is isolated from key parts of the implementation (e.g., in libghostty subsystems), and it's expected that this list will grow. * We currently manage our own C translation layer where necessary. In these cases, cImport has been removed in favor of the new external translate-c package. Due to fixes that have needed be made to properly translate the dependencies that were swapped out, as mentioned, we have had to backport fixes from the current translate-c package (and the upstream Arocc dependency). We will host this ourselves until Zig 0.17.0 is released with these fixes. * Where necessary (only a small number of cases), some stdlib code from 0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in lib/compat. Co-authored-by: Leah Amelia Chen <hi@pluie.me>
70 lines
2.1 KiB
Zig
70 lines
2.1 KiB
Zig
const std = @import("std");
|
|
|
|
const c = @import("c");
|
|
const gdk = @import("gdk");
|
|
const gtk = @import("gtk");
|
|
|
|
pub const ShellLayer = enum(c_uint) {
|
|
background = c.GTK_LAYER_SHELL_LAYER_BACKGROUND,
|
|
bottom = c.GTK_LAYER_SHELL_LAYER_BOTTOM,
|
|
top = c.GTK_LAYER_SHELL_LAYER_TOP,
|
|
overlay = c.GTK_LAYER_SHELL_LAYER_OVERLAY,
|
|
};
|
|
|
|
pub const ShellEdge = enum(c_uint) {
|
|
left = c.GTK_LAYER_SHELL_EDGE_LEFT,
|
|
right = c.GTK_LAYER_SHELL_EDGE_RIGHT,
|
|
top = c.GTK_LAYER_SHELL_EDGE_TOP,
|
|
bottom = c.GTK_LAYER_SHELL_EDGE_BOTTOM,
|
|
};
|
|
|
|
pub const KeyboardMode = enum(c_uint) {
|
|
none = c.GTK_LAYER_SHELL_KEYBOARD_MODE_NONE,
|
|
exclusive = c.GTK_LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE,
|
|
on_demand = c.GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND,
|
|
};
|
|
|
|
pub fn isSupported() bool {
|
|
return c.gtk_layer_is_supported() != 0;
|
|
}
|
|
|
|
pub fn getProtocolVersion() c_uint {
|
|
return c.gtk_layer_get_protocol_version();
|
|
}
|
|
|
|
pub fn getLibraryVersion() std.SemanticVersion {
|
|
return .{
|
|
.major = c.gtk_layer_get_major_version(),
|
|
.minor = c.gtk_layer_get_minor_version(),
|
|
.patch = c.gtk_layer_get_micro_version(),
|
|
};
|
|
}
|
|
|
|
pub fn initForWindow(window: *gtk.Window) void {
|
|
c.gtk_layer_init_for_window(@ptrCast(window));
|
|
}
|
|
|
|
pub fn setLayer(window: *gtk.Window, layer: ShellLayer) void {
|
|
c.gtk_layer_set_layer(@ptrCast(window), @intFromEnum(layer));
|
|
}
|
|
|
|
pub fn setAnchor(window: *gtk.Window, edge: ShellEdge, anchor_to_edge: bool) void {
|
|
c.gtk_layer_set_anchor(@ptrCast(window), @intFromEnum(edge), @intFromBool(anchor_to_edge));
|
|
}
|
|
|
|
pub fn setMargin(window: *gtk.Window, edge: ShellEdge, margin_size: c_int) void {
|
|
c.gtk_layer_set_margin(@ptrCast(window), @intFromEnum(edge), margin_size);
|
|
}
|
|
|
|
pub fn setKeyboardMode(window: *gtk.Window, mode: KeyboardMode) void {
|
|
c.gtk_layer_set_keyboard_mode(@ptrCast(window), @intFromEnum(mode));
|
|
}
|
|
|
|
pub fn setMonitor(window: *gtk.Window, monitor: ?*gdk.Monitor) void {
|
|
c.gtk_layer_set_monitor(@ptrCast(window), @ptrCast(monitor));
|
|
}
|
|
|
|
pub fn setNamespace(window: *gtk.Window, name: [:0]const u8) void {
|
|
c.gtk_layer_set_namespace(@ptrCast(window), name.ptr);
|
|
}
|