diff --git a/src/core.zig b/src/core.zig index 0fed8cf..d67bad4 100644 --- a/src/core.zig +++ b/src/core.zig @@ -1,42 +1,24 @@ pub const Display = struct { - pub const Request = union(Request.Tag) { - sync: Sync, - get_registry: GetRegistry, - - pub const Tag = enum(u16) { - sync, - get_registry, - }; - - pub const Sync = struct { + pub const Request = union(enum) { + sync: struct { /// new_id callback: u32, - }; - - pub const GetRegistry = struct { + }, + get_registry: struct { /// new_id registry: u32, - }; + }, }; - pub const Event = union(Event.Tag) { - @"error": Event.Error, - delete_id: DeleteId, - - pub const Tag = enum(u16) { - @"error", - delete_id, - }; - - pub const Error = struct { + pub const Event = union(enum) { + @"error": struct { object_id: u32, code: u32, message: []const u8, - }; - - pub const DeleteId = struct { + }, + delete_id: struct { name: u32, - }; + }, }; pub const Error = enum(u32) { @@ -48,66 +30,42 @@ pub const Display = struct { }; pub const Registry = struct { - pub const Event = union(Event.Tag) { - global: Global, - global_remove: GlobalRemove, - - pub const Tag = enum(u16) { - global, - global_remove, - }; - - pub const Global = struct { + pub const Event = union(enum) { + global: struct { name: u32, interface: [:0]const u8, version: u32, - }; - - pub const GlobalRemove = struct { + }, + global_remove: struct { name: u32, - }; + }, }; - pub const Request = union(Request.Tag) { - bind: Bind, - - pub const Tag = enum(u16) { - bind, - }; - - pub const Bind = struct { + pub const Request = union(enum) { + bind: struct { name: u32, interface: [:0]const u8, version: u32, new_id: u32, - }; + }, }; }; pub const Compositor = struct { pub const INTERFACE = "wl_compositor"; - pub const Request = union(Request.Tag) { - create_surface: CreateSurface, - create_region: CreateRegion, - - pub const Tag = enum(u16) { - create_surface, - create_region, - }; - - pub const CreateSurface = struct { + pub const Request = union(enum) { + create_surface: struct { new_id: u32, - }; - - pub const CreateRegion = struct { + }, + create_region: struct { new_id: u32, - }; + }, }; }; pub const ShmPool = struct { - pub const Request = union(Request.Tag) { + pub const Request = union(enum) { create_buffer: struct { new_id: u32, offset: i32, @@ -120,29 +78,17 @@ pub const ShmPool = struct { resize: struct { size: i32, }, - - pub const Tag = enum(u16) { - create_buffer, - destroy, - resize, - }; }; }; pub const Shm = struct { - pub const Request = union(Request.Tag) { - create_pool: CreatePool, - - pub const Tag = enum(u16) { - create_pool, - }; - - pub const CreatePool = struct { + pub const Request = union(enum) { + create_pool: struct { new_id: u32, // file descriptors are sent through a control message // fd: u32, size: u32, - }; + }, }; pub const Event = union(enum) { @@ -151,6 +97,12 @@ pub const Shm = struct { }, }; + pub const Error = enum(u32) { + invalid_format, + invalid_stride, + invalid_fd, + }; + pub const Format = enum(u32) { argb8888, xrgb8888, @@ -159,7 +111,7 @@ pub const Shm = struct { }; pub const Surface = struct { - pub const Request = union(Request.Tag) { + pub const Request = union(enum) { destroy: void, attach: struct { buffer: u32, @@ -183,31 +135,29 @@ pub const Surface = struct { region: u32, }, commit: void, - - pub const Tag = enum(u16) { - destroy, - attach, - damage, - frame, - set_opaque_region, - set_input_region, - commit, - }; }; - pub const Event = union(Event.Tag) { - format: Format, + pub const Event = union(enum) { + enter: struct { + output: u32, + }, + leave: struct { + output: u32, + }, + preferred_buffer_scale: struct { + factor: i32, + }, + preferred_buffer_transform: struct { + transform: u32, + }, + }; - pub const Tag = enum(u16) { - @"error", - delete_id, - }; - - pub const Format = enum(u32) { - argb8888, - xrgb8888, - _, - }; + pub const Error = enum(u32) { + invalid_scale, + invalid_transform, + invalid_size, + invalid_offset, + defunct_role_object, }; };