diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-04 19:22:04 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 01:23:06 +0300 |
| commit | 41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch) | |
| tree | 3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/gtk4-layer-shell | |
| parent | 55c138263e190a1e79d4b997bfb9397306c0ec1f (diff) | |
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/gtk4-layer-shell')
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig | 127 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon | 18 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig | 71 |
3 files changed, 216 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig new file mode 100644 index 00000000..818b48f4 --- /dev/null +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig @@ -0,0 +1,127 @@ +const std = @import("std"); + +const version = @import("build.zig.zon").version; + +const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{ + .preferred_link_mode = .dynamic, + .search_strategy = .mode_first, +}; + +pub fn build(b: *std.Build) !void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + // Zig API + const module = b.addModule("gtk4-layer-shell", .{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + // Needs the gtk.h header + module.linkSystemLibrary("gtk4", dynamic_link_opts); + + if (b.systemIntegrationOption("gtk4-layer-shell", .{})) { + module.linkSystemLibrary("gtk4-layer-shell-0", dynamic_link_opts); + } else { + _ = try buildLib(b, module, .{ + .target = target, + .optimize = optimize, + }); + } +} + +fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Build.Step.Compile { + const lib_version = try std.SemanticVersion.parse(version); + const target = options.target; + const optimize = options.optimize; + + // Shared library + const lib = b.addLibrary(.{ + .name = "gtk4-layer-shell", + .linkage = .dynamic, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), + }); + b.installArtifact(lib); + + // We need to call both lazy dependencies to tell Zig we need both + const upstream_ = b.lazyDependency("gtk4_layer_shell", .{}); + const wayland_protocols_ = b.lazyDependency("wayland_protocols", .{}); + const upstream = upstream_ orelse return lib; + const wayland_protocols = wayland_protocols_ orelse return lib; + + lib.linkLibC(); + lib.addIncludePath(upstream.path("include")); + lib.addIncludePath(upstream.path("src")); + module.addIncludePath(upstream.path("include")); + + // GTK + lib.linkSystemLibrary2("gtk4", dynamic_link_opts); + + // Wayland headers and source files + { + const protocols = [_]struct { []const u8, std.Build.LazyPath }{ + .{ + "wlr-layer-shell-unstable-v1", + upstream.path("protocol/wlr-layer-shell-unstable-v1.xml"), + }, + .{ + "xdg-shell", + wayland_protocols.path("stable/xdg-shell/xdg-shell.xml"), + }, + // Even though we don't use session lock, we still need its headers + .{ + "ext-session-lock-v1", + wayland_protocols.path("staging/ext-session-lock/ext-session-lock-v1.xml"), + }, + }; + + const wf = b.addWriteFiles(); + for (protocols) |protocol| { + const name, const xml = protocol; + + const header_scanner = b.addSystemCommand(&.{ "wayland-scanner", "client-header" }); + header_scanner.addFileArg(xml); + _ = wf.addCopyFile( + header_scanner.addOutputFileArg(name), + b.fmt("{s}-client.h", .{name}), + ); + + const source_scanner = b.addSystemCommand(&.{ "wayland-scanner", "private-code" }); + source_scanner.addFileArg(xml); + const source = source_scanner.addOutputFileArg(b.fmt("{s}.c", .{name})); + lib.addCSourceFile(.{ .file = source }); + } + lib.addIncludePath(wf.getDirectory()); + } + + lib.installHeadersDirectory( + upstream.path("include"), + "", + .{ .include_extensions = &.{".h"} }, + ); + + // Certain files relating to session lock were removed as we don't use them + const srcs: []const []const u8 = &.{ + "gtk4-layer-shell.c", + "layer-surface.c", + "libwayland-shim.c", + "registry.c", + "stolen-from-libwayland.c", + "stubbed-surface.c", + "xdg-surface-server.c", + }; + lib.addCSourceFiles(.{ + .root = upstream.path("src"), + .files = srcs, + .flags = &.{ + b.fmt("-DGTK_LAYER_SHELL_MAJOR={}", .{lib_version.major}), + b.fmt("-DGTK_LAYER_SHELL_MINOR={}", .{lib_version.minor}), + b.fmt("-DGTK_LAYER_SHELL_MICRO={}", .{lib_version.patch}), + }, + }); + + return lib; +} diff --git a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon new file mode 100644 index 00000000..9329e374 --- /dev/null +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon @@ -0,0 +1,18 @@ +.{ + .name = .gtk4_layer_shell, + .version = "1.1.0", + .fingerprint = 0x4b96f9483c6feeb1, + .paths = .{""}, + .dependencies = .{ + .gtk4_layer_shell = .{ + .url = "https://deps.files.ghostty.org/gtk4-layer-shell-1.1.0.tar.gz", + .hash = "N-V-__8AALiNBAA-_0gprYr92CjrMj1I5bqNu0TSJOnjFNSr", + .lazy = true, + }, + .wayland_protocols = .{ + .url = "https://deps.files.ghostty.org/wayland-protocols-258d8f88f2c8c25a830c6316f87d23ce1a0f12d9.tar.gz", + .hash = "N-V-__8AAKw-DAAaV8bOAAGqA0-oD7o-HNIlPFYKRXSPT03S", + .lazy = true, + }, + }, +} diff --git a/vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig b/vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig new file mode 100644 index 00000000..a1531323 --- /dev/null +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig @@ -0,0 +1,71 @@ +const std = @import("std"); + +const c = @cImport({ + @cInclude("gtk4-layer-shell.h"); +}); +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); +} |
