diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-23 08:06:17 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-08-23 08:06:17 +0200 |
| commit | 0a4c945e48717b24fdb6416e47bbb2fa2a7372b4 (patch) | |
| tree | ff0fccabc742908e1e1df46d0556f467f91ffcfd /src/wl | |
| parent | 5fdb94211781fe0a3e285c4b6d9d6e9cffced465 (diff) | |
add Fd type for requests
This is not tested code, since there are no requests
implemented yet using file descriptors.
Diffstat (limited to 'src/wl')
| -rw-r--r-- | src/wl/display.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wl/display.zig b/src/wl/display.zig index db5ed3c..ed4a94f 100644 --- a/src/wl/display.zig +++ b/src/wl/display.zig @@ -1,6 +1,7 @@ const std = @import("std"); const wayland = @import("../root.zig"); const wl = wayland.wl; +const ancillary_data = @import("../ancillary-data.zig"); const log = std.log.scoped(.display); @@ -85,6 +86,7 @@ pub fn request(self: *Self, object: anytype, args: @TypeOf(object.*).Request) !v const id: u32 = @truncate(object.handle); var size: u32 = 8; + comptime var fds: []std.posix.fd_t = &.{}; inline for (data) |value| { switch (@TypeOf(value)) { @@ -94,6 +96,7 @@ pub fn request(self: *Self, object: anytype, args: @TypeOf(object.*).Request) !v const padding_size: usize = padding_len(u8, value.len + 1); size += @as(u32, @intCast(@sizeOf(u32) + (value.len + 1) + padding_size)); }, + wayland.types.Fd => |fd| fds = fds ++ .{ fd }, else => |t| switch (@typeInfo(t)) { .pointer => |ptr| if (ptr.size == .slice) { const padding_size: usize = padding_len(ptr.child, value.len); @@ -119,6 +122,7 @@ pub fn request(self: *Self, object: anytype, args: @TypeOf(object.*).Request) !v _ = try self.stream.writeAll(std.mem.asBytes(&@as(u8, 0))); } }, + wayland.types.Fd => {}, else => |t| switch (@typeInfo(t)) { .pointer => |ptr| if (ptr.size == .slice) { const padding_size: usize = @mod(@as(usize, @bitCast(-@as(isize, @intCast(value.len * @sizeOf(ptr.child))))), 4); @@ -132,6 +136,11 @@ pub fn request(self: *Self, object: anytype, args: @TypeOf(object.*).Request) !v }, } } + + if (fds.len > 0) { + try ancillary_data.send_fds(self.stream.handle, fds); + } + return; } } |