diff options
Diffstat (limited to 'src/xdg')
| -rw-r--r-- | src/xdg/root.zig | 2 | ||||
| -rw-r--r-- | src/xdg/surface.zig | 25 | ||||
| -rw-r--r-- | src/xdg/wm-base.zig | 45 |
3 files changed, 72 insertions, 0 deletions
diff --git a/src/xdg/root.zig b/src/xdg/root.zig new file mode 100644 index 0000000..0d4f0eb --- /dev/null +++ b/src/xdg/root.zig @@ -0,0 +1,2 @@ +pub const WmBase = @import("wm-base.zig"); +pub const Surface = @import("surface.zig"); diff --git a/src/xdg/surface.zig b/src/xdg/surface.zig new file mode 100644 index 0000000..fc9d838 --- /dev/null +++ b/src/xdg/surface.zig @@ -0,0 +1,25 @@ +const wayland = @import("../root.zig"); +const wl = wayland.wl; + +const Self = @This(); + +pub const Request = union(enum) { + destroy: void, + get_toplevel: struct { wayland.Object.Ref }, + get_popup: struct { wayland.Object.Ref, ?wayland.Object.Ref, wayland.Object.Ref }, + set_window_geometry: struct { i32, i32, i32, i32 }, + ack_configure: struct { u32 }, +}; + +pub const Events = wayland.EventSet(Self, .{ configure }); + +handle: wayland.Object.Ref, +init: wayland.Object.interface.Init(Self) = .{}, + +fn configure( + self: *Self, + ctx: wayland.Context, + payload: u32 +) !void { + try ctx.display.request(self, .{ .ack_configure = .{ payload } }); +} diff --git a/src/xdg/wm-base.zig b/src/xdg/wm-base.zig new file mode 100644 index 0000000..6a9df47 --- /dev/null +++ b/src/xdg/wm-base.zig @@ -0,0 +1,45 @@ +const std = @import("std"); +const wayland = @import("../root.zig"); +const wl = wayland.wl; + +const Self = @This(); + +pub const Request = union(enum) { + destroy: void, + create_positioner: struct { wayland.Object.Ref }, + create_xdg_surface: struct { wayland.Object.Ref, wayland.Object.Ref }, + pong: struct { u32 }, +}; + +pub const Events = wayland.EventSet(Self, .{ ping }); + +handle: wayland.Object.Ref, +init: wayland.Object.interface.Init(Self) = .{}, + + +pub var globals: wayland.Object.interface.Global(Self) = .init; +pub const handler: wl.Registry.GlobalHandler = .{ + .interface = "xdg_wm_base", + .version = 6, + .handler = globals.register, +}; + +fn ping( + self: *Self, + ctx: wayland.Context, + payload: u32, +) !void { + try ctx.display.request(self, .{ .pong = .{ payload } }); +} + +pub fn format( + self: *const Self, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, +) !void { + _ = self; + _ = fmt; + _ = options; + try writer.print("xdg.wm-base", .{}); +} |