diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-10 21:51:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 21:51:57 +0300 |
| commit | 425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch) | |
| tree | e52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/pkg/gtk4-layer-shell | |
| parent | 90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff) | |
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/pkg/gtk4-layer-shell')
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig | 169 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon | 5 | ||||
| -rw-r--r-- | vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig | 4 |
3 files changed, 117 insertions, 61 deletions
diff --git a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig index 818b48f4..38dfd2c8 100644 --- a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig @@ -17,20 +17,46 @@ pub fn build(b: *std.Build) !void { .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, .{ + translate: { + const translate_c = b.lazyImport(@This(), "translate_c") orelse break :translate; + const translate_c_dep = b.lazyDependency("translate_c", .{}) orelse break :translate; + const Translator = translate_c.Translator; + + const link_system_libs_full: [2]Translator.LinkSystemLib = .{ + .{ .name = "gtk4", .options = dynamic_link_opts }, + .{ .name = "gtk4-layer-shell-0", .options = dynamic_link_opts }, + }; + + const headers = Translator.init(translate_c_dep, .{ + .c_source_file = b.addWriteFiles().add("c.h", + \\#include <gtk4-layer-shell.h> + ), .target = target, .optimize = optimize, + .link_system_libs = if (b.systemIntegrationOption("gtk4-layer-shell", .{})) + &link_system_libs_full + else + link_system_libs_full[0..1], }); + + if (!b.systemIntegrationOption("gtk4-layer-shell", .{})) { + // local deps (non-system layer-shell/wayland) + const deps = try LocalDeps.get(b) orelse break :translate; + headers.addIncludePath(deps.upstream.path("include")); + headers.addIncludePath(deps.upstream.path("src")); + headers.addIncludePath(deps.client_header_directory); + } + + module.addImport("c", headers.mod); + } + + if (!b.systemIntegrationOption("gtk4-layer-shell", .{})) { + _ = try buildLib(b, .{ .target = target, .optimize = optimize }); } } -fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Build.Step.Compile { +fn buildLib(b: *std.Build, options: anytype) !*std.Build.Step.Compile { const lib_version = try std.SemanticVersion.parse(version); const target = options.target; const optimize = options.optimize; @@ -42,63 +68,25 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu .root_module = b.createModule(.{ .target = target, .optimize = optimize, + .link_libc = true, }), }); 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.root_module.linkSystemLibrary("gtk4", dynamic_link_opts); + + // local deps (non-system layer-shell/wayland) + const deps = try LocalDeps.get(b) orelse return lib; + lib.root_module.addIncludePath(deps.upstream.path("include")); + lib.root_module.addIncludePath(deps.upstream.path("src")); + lib.root_module.addIncludePath(deps.client_header_directory); + for (deps.private_code_files) |source| { + lib.root_module.addCSourceFile(.{ .file = source }); } lib.installHeadersDirectory( - upstream.path("include"), + deps.upstream.path("include"), "", .{ .include_extensions = &.{".h"} }, ); @@ -113,8 +101,8 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu "stubbed-surface.c", "xdg-surface-server.c", }; - lib.addCSourceFiles(.{ - .root = upstream.path("src"), + lib.root_module.addCSourceFiles(.{ + .root = deps.upstream.path("src"), .files = srcs, .flags = &.{ b.fmt("-DGTK_LAYER_SHELL_MAJOR={}", .{lib_version.major}), @@ -125,3 +113,68 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu return lib; } + +const LocalDeps = struct { + var cached: ?LocalDeps = null; + + upstream: *std.Build.Dependency, + wayland_protocols: *std.Build.Dependency, + client_header_directory: std.Build.LazyPath, + private_code_files: []std.Build.LazyPath, + + fn init(b: *std.Build) !?LocalDeps { + var result: LocalDeps = .{ + .upstream = b.lazyDependency("gtk4_layer_shell", .{}) orelse return null, + .wayland_protocols = b.lazyDependency("wayland_protocols", .{}) orelse return null, + .client_header_directory = undefined, + .private_code_files = &.{}, + }; + + // Wayland headers and source files + { + const protocols = [_]struct { []const u8, std.Build.LazyPath }{ + .{ + "wlr-layer-shell-unstable-v1", + result.upstream.path("protocol/wlr-layer-shell-unstable-v1.xml"), + }, + .{ + "xdg-shell", + result.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", + result.wayland_protocols.path("staging/ext-session-lock/ext-session-lock-v1.xml"), + }, + }; + + const wf = b.addWriteFiles(); + const private_code_files = try b.allocator.alloc(std.Build.LazyPath, protocols.len); + for (protocols, 0..) |protocol, idx| { + 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})); + private_code_files[idx] = source; + } + result.private_code_files = private_code_files; + result.client_header_directory = wf.getDirectory(); + } + + cached = result; + return result; + } + + fn get(b: *std.Build) !?LocalDeps { + if (cached) |c| return c; + return init(b); + } +}; diff --git a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon index 9329e374..fd9d0cf2 100644 --- a/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/build.zig.zon @@ -14,5 +14,10 @@ .hash = "N-V-__8AAKw-DAAaV8bOAAGqA0-oD7o-HNIlPFYKRXSPT03S", .lazy = true, }, + .translate_c = .{ + .url = "https://codeberg.org/vancluever/translate-c/archive/4e879eb8aba615de112eabd1231ea6e01920cead.tar.gz", + .hash = "translate_c-0.0.0-Q_BUWhVNBwDOEcIqub4VFPJPB6D9dgwzUMHTX5KWr8Xr", + .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 index a1531323..04e0f0f3 100644 --- a/vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig +++ b/vendor/libghostty-vt/pkg/gtk4-layer-shell/src/main.zig @@ -1,8 +1,6 @@ const std = @import("std"); -const c = @cImport({ - @cInclude("gtk4-layer-shell.h"); -}); +const c = @import("c"); const gdk = @import("gdk"); const gtk = @import("gtk"); |
