From 6bb0a4fc4616140523ea8c0cc40d9e1aaf9a5723 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Thu, 24 Apr 2025 13:44:44 +0200 Subject: [PATCH 01/54] build: update to wlroots 0.19.0 rc3 --- README.md | 2 +- build.zig | 2 +- build.zig.zon | 2 +- src/backend.zig | 7 ++ src/backend/session.zig | 6 +- src/render/drm_format_set.zig | 3 + src/render/renderer.zig | 11 +- src/types/alpha_modifier_v1.zig | 4 + src/types/buffer.zig | 14 ++- src/types/compositor.zig | 86 ++++++------- src/types/content_type_v1.zig | 4 + src/types/cursor.zig | 2 +- src/types/cursor_shape_v1.zig | 6 +- src/types/damage_ring.zig | 25 +--- src/types/data_control_v1.zig | 12 +- src/types/data_device.zig | 29 +++-- src/types/drm.zig | 11 +- src/types/drm_lease_v1.zig | 24 +++- src/types/export_dmabuf_v1.zig | 12 +- src/types/foreign_toplevel_management_v1.zig | 18 +-- src/types/fractional_scale_v1.zig | 4 +- src/types/gamma_control_v1.zig | 14 ++- src/types/idle_inhibit_v1.zig | 15 ++- src/types/idle_notify_v1.zig | 10 +- src/types/input_device.zig | 2 +- src/types/input_method_v2.zig | 24 ++-- src/types/keyboard.zig | 2 +- src/types/keyboard_group.zig | 2 +- src/types/keyboard_shortcuts_inhibit_v1.zig | 18 +-- src/types/layer_shell_v1.zig | 20 +-- src/types/linux_dmabuf_v1.zig | 32 ++--- src/types/matrix.zig | 28 ----- src/types/output.zig | 30 ++++- src/types/output_layout.zig | 16 +-- src/types/output_management_v1.zig | 14 ++- src/types/output_power_management_v1.zig | 16 ++- src/types/output_swapchain_manager.zig | 6 +- src/types/pointer.zig | 3 + src/types/pointer_constraints_v1.zig | 20 +-- src/types/pointer_gestures_v1.zig | 8 +- src/types/presentation_time.zig | 18 +-- src/types/primary_selection.zig | 2 +- src/types/primary_selection_v1.zig | 18 +-- src/types/relative_pointer_v1.zig | 14 ++- src/types/scene.zig | 121 +++++++++++-------- src/types/screencopy_v1.zig | 19 ++- src/types/seat.zig | 58 +++++---- src/types/security_context_v1.zig | 7 +- src/types/session_lock_v1.zig | 27 ++--- src/types/shm.zig | 10 +- src/types/single_pixel_buffer_v1.zig | 6 +- src/types/subcompositor.zig | 27 ++--- src/types/switch.zig | 2 +- src/types/tablet_tool.zig | 4 +- src/types/tablet_v2.zig | 26 ++-- src/types/tearing_control_v1.zig | 14 ++- src/types/text_input_v3.zig | 14 ++- src/types/touch.zig | 2 +- src/types/transient_seat_v1.zig | 10 +- src/types/viewporter.zig | 4 +- src/types/virtual_keyboard_v1.zig | 6 +- src/types/virtual_pointer_v1.zig | 6 +- src/types/xdg_activation_v1.zig | 28 ++--- src/types/xdg_decoration_v1.zig | 14 +-- src/types/xdg_output_v1.zig | 16 ++- src/types/xdg_shell.zig | 56 ++++++--- src/util/addon.zig | 13 +- src/util/box.zig | 3 + src/wlroots.zig | 8 +- src/xwayland/server.zig | 8 +- src/xwayland/shell.zig | 25 ++-- src/xwayland/xwayland.zig | 59 ++++++--- tinywl/build.zig | 2 +- tinywl/tinywl.zig | 43 +++++-- 74 files changed, 737 insertions(+), 517 deletions(-) delete mode 100644 src/types/matrix.zig diff --git a/README.md b/README.md index 6e5bd54..3164916 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ request on [codeberg](https://codeberg.org/ifreund/zig-wlroots). ## Dependencies - [zig](https://ziglang.org/) 0.14 -- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.18 +- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.19 - [zig-wayland](https://codeberg.org/ifreund/zig-wayland) - [zig-xkbcommon](https://codeberg.org/ifreund/zig-xkbcommon) - [zig-pixman](https://codeberg.org/ifreund/zig-pixman) diff --git a/build.zig b/build.zig index e323ed3..2402b01 100644 --- a/build.zig +++ b/build.zig @@ -77,7 +77,7 @@ pub fn build(b: *std.Build) void { wlr_test.root_module.addImport("pixman", pixman); wlr_test.linkSystemLibrary("pixman-1"); - wlr_test.linkSystemLibrary("wlroots-0.18"); + wlr_test.linkSystemLibrary("wlroots-0.19"); const test_step = b.step("test", "Run the tests"); test_step.dependOn(&wlr_test.step); diff --git a/build.zig.zon b/build.zig.zon index 18f1f6e..6189868 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.18.3-dev", + .version = "0.19.0-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", diff --git a/src/backend.zig b/src/backend.zig index 89f8e83..9c5f385 100644 --- a/src/backend.zig +++ b/src/backend.zig @@ -12,6 +12,13 @@ pub const Backend = extern struct { }; impl: *const Impl, + + buffer_caps: u32, + + features: extern struct { + timeline: bool, + }, + events: extern struct { destroy: wl.Signal(*Backend), new_input: wl.Signal(*wlr.InputDevice), diff --git a/src/backend/session.zig b/src/backend/session.zig index dac94d5..1138129 100644 --- a/src/backend/session.zig +++ b/src/backend/session.zig @@ -44,7 +44,6 @@ pub const Session = extern struct { active: bool, - vtnr: c_uint, seat: [256]u8, // TODO: do we need libudev bindings? @@ -58,7 +57,6 @@ pub const Session = extern struct { devices: wl.list.Head(Device, .link), event_loop: *wl.EventLoop, - event_loop_destroy: wl.Listener(*wl.EventLoop), events: extern struct { active: wl.Signal(void), @@ -66,6 +64,10 @@ pub const Session = extern struct { destroy: wl.Signal(*Session), }, + private: extern struct { + event_loop_destroy: wl.Listener(void), + }, + extern fn wlr_session_create(loop: *wl.EventLoop) ?*Session; pub fn create(loop: *wl.EventLoop) !*Session { return wlr_session_create(loop) orelse error.SessionCreateFailed; diff --git a/src/render/drm_format_set.zig b/src/render/drm_format_set.zig index 54cfcc4..07e837d 100644 --- a/src/render/drm_format_set.zig +++ b/src/render/drm_format_set.zig @@ -19,6 +19,9 @@ pub const DrmFormatSet = extern struct { extern fn wlr_drm_format_set_get(set: *const DrmFormatSet, format: u32) *const DrmFormat; pub const get = wlr_drm_format_set_get; + extern fn wlr_drm_format_set_remove(set: *const DrmFormatSet, format: u32, modifier: u64) bool; + pub const remove = wlr_drm_format_set_remove; + extern fn wlr_drm_format_set_has(set: *const DrmFormatSet, format: u32, modifier: u64) bool; pub const has = wlr_drm_format_set_has; diff --git a/src/render/renderer.zig b/src/render/renderer.zig index 73cf89a..fa8bffd 100644 --- a/src/render/renderer.zig +++ b/src/render/renderer.zig @@ -18,11 +18,12 @@ pub const Renderer = extern struct { features: extern struct { output_color_transform: bool, + timeline: bool, }, - // private state - - impl: *const Impl, + private: extern struct { + impl: *const Impl, + }, extern fn wlr_renderer_autocreate(backend: *wlr.Backend) ?*Renderer; pub fn autocreate(backend: *wlr.Backend) !*Renderer { @@ -55,6 +56,8 @@ pub const Renderer = extern struct { pub const BufferPassOptions = extern struct { timer: ?*RenderTimer = null, color_transform: ?*wlr.ColorTransform = null, + signal_timeline: ?*wlr.DrmSyncobjTimeline = null, + signal_point: u64 = 0, }; extern fn wlr_renderer_begin_buffer_pass(renderer: *Renderer, buffer: *wlr.Buffer, options: ?*const BufferPassOptions) ?*RenderPass; pub fn beginBufferPass(renderer: *Renderer, buffer: *wlr.Buffer, options: ?*const BufferPassOptions) !*RenderPass { @@ -117,6 +120,8 @@ pub const RenderPass = opaque { transform: wl.Output.Transform, filter_mode: ScaleFilterMode, blend_mode: BlendMode, + wait_timeline: ?*wlr.DrmSyncobjTimeline = null, + wait_point: u64, }; pub const RectOptions = extern struct { diff --git a/src/types/alpha_modifier_v1.zig b/src/types/alpha_modifier_v1.zig index eaf8c76..e1991da 100644 --- a/src/types/alpha_modifier_v1.zig +++ b/src/types/alpha_modifier_v1.zig @@ -10,6 +10,10 @@ pub const AlphaModifierV1 = extern struct { global: *wl.Global, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_alpha_modifier_v1_create(server: *wl.Server) ?*AlphaModifierV1; pub fn create(server: *wl.Server) !*AlphaModifierV1 { return wlr_alpha_modifier_v1_create(server) orelse error.OutOfMemory; diff --git a/src/types/buffer.zig b/src/types/buffer.zig index 73d4750..dcf3d4d 100644 --- a/src/types/buffer.zig +++ b/src/types/buffer.zig @@ -80,6 +80,9 @@ pub const Buffer = extern struct { extern fn wlr_buffer_try_from_resource(resource: *wl.Buffer) ?*Buffer; pub const tryFromWlBuffer = wlr_buffer_try_from_resource; + extern fn wlr_buffer_is_opaque(buffer: *Buffer) bool; + pub const isOpaque = wlr_buffer_is_opaque; + extern fn wlr_buffer_begin_data_ptr_access(buffer: *Buffer, flags: u32, data: **anyopaque, format: *u32, stride: *usize) bool; pub const beginDataPtrAccess = wlr_buffer_begin_data_ptr_access; @@ -93,12 +96,11 @@ pub const ClientBuffer = extern struct { texture: ?*wlr.Texture, source: ?*wlr.Buffer, - // private state - - source_destroy: wl.Listener(void), - renderer_destroy: wl.Listener(void), - - n_ignore_locks: usize, + private: extern struct { + source_destroy: wl.Listener(void), + renderer_destroy: wl.Listener(void), + n_ignore_locks: usize, + }, extern fn wlr_client_buffer_get(buffer: *wlr.Buffer) ?*ClientBuffer; pub const get = wlr_client_buffer_get; diff --git a/src/types/compositor.zig b/src/types/compositor.zig index 7fd24a6..95afc4c 100644 --- a/src/types/compositor.zig +++ b/src/types/compositor.zig @@ -11,14 +11,16 @@ pub const Compositor = extern struct { global: *wl.Global, renderer: ?*wlr.Renderer, - server_destroy: wl.Listener(*wl.Server), - renderer_destroy: wl.Listener(void), - events: extern struct { new_surface: wl.Signal(*wlr.Surface), destroy: wl.Signal(*wlr.Compositor), }, + private: extern struct { + server_destroy: wl.Listener(void), + renderer_destroy: wl.Listener(void), + }, + extern fn wlr_compositor_create(server: *wl.Server, version: u32, renderer: ?*wlr.Renderer) ?*Compositor; pub fn create(server: *wl.Server, version: u32, renderer: ?*wlr.Renderer) !*Compositor { return wlr_compositor_create(server, version, renderer) orelse error.OutOfMemory; @@ -88,6 +90,7 @@ pub const Surface = extern struct { no_object: bool = false, client_commit: ?*const fn (surface: *Surface) callconv(.C) void = null, commit: ?*const fn (surface: *Surface) callconv(.C) void = null, + map: ?*const fn (surface: *Surface) callconv(.C) void = null, unmap: ?*const fn (surface: *Surface) callconv(.C) void = null, destroy: ?*const fn (surface: *Surface) callconv(.C) void = null, }; @@ -98,8 +101,11 @@ pub const Surface = extern struct { // Surface.current_outputs link: wl.list.Link, - bind: wl.Listener(*wlr.Output.event.Bind), - destroy: wl.Listener(*wlr.Output), + + private: extern struct { + bind: wl.Listener(void), + destroy: wl.Listener(void), + }, }; pub const Synced = extern struct { @@ -108,6 +114,7 @@ pub const Surface = extern struct { init_state: ?*const fn (state: *anyopaque) callconv(.C) void, finish_state: ?*const fn (state: *anyopaque) callconv(.C) void, move_state: ?*const fn (dst: *anyopaque, src: *anyopaque) callconv(.C) void, + commit: ?*const fn (synced: *Synced) callconv(.C) void = null, }; surface: *Surface, @@ -173,37 +180,38 @@ pub const Surface = extern struct { current_outputs: wl.list.Head(Surface.Output, .link), addons: wlr.AddonSet, - data: usize, + data: ?*anyopaque, - // private state + private: extern struct { + role_resource_destroy: wl.Listener(void), - role_resource_destroy: wl.Listener(*wl.Resource), + previous: extern struct { + scale: i32, + transform: wl.Output.Transform, + width: c_int, + height: c_int, + buffer_width: c_int, + buffer_height: c_int, + }, - previous: extern struct { - scale: i32, - transform: wl.Output.Transform, - width: c_int, - height: c_int, - buffer_width: c_int, - buffer_height: c_int, + unmap_commit: bool, + + @"opaque": bool, + + handling_commit: bool, + pending_rejected: bool, + + preferred_buffer_scale: i32, + preferred_buffer_transform_sent: bool, + preferred_buffer_transform: wl.Output.Transform, + + synced: wl.list.Link, + synced_len: usize, + + pending_buffer_resource: *wl.Resource, + pending_buffer_resource_destroy: wl.Listener(void), }, - unmap_commit: bool, - @"opaque": bool, - - handling_commit: bool, - pending_rejected: bool, - - preferred_buffer_scale: i32, - preferred_buffer_transform_sent: bool, - preferred_buffer_transform: wl.Output.Transform, - - synced: wl.list.Head(Synced, .link), - synced_len: usize, - - pending_buffer_resource: *wl.Resource, - pending_buffer_resource_destroy: wl.Listener(void), - extern fn wlr_surface_set_role( surface: *Surface, role: *const Role, @@ -245,8 +253,8 @@ pub const Surface = extern struct { extern fn wlr_surface_send_frame_done(surface: *Surface, when: *const posix.timespec) void; pub const sendFrameDone = wlr_surface_send_frame_done; - extern fn wlr_surface_get_extends(surface: *Surface, box: *wlr.Box) void; - pub const getExtends = wlr_surface_get_extends; + extern fn wlr_surface_get_extents(surface: *Surface, box: *wlr.Box) void; + pub const getExtents = wlr_surface_get_extents; extern fn wlr_surface_from_resource(resource: *wl.Surface) *Surface; pub const fromWlSurface = wlr_surface_from_resource; @@ -279,15 +287,11 @@ pub const Surface = extern struct { extern fn wlr_surface_get_buffer_source_box(surface: *Surface, box: *wlr.FBox) void; pub const getBufferSourceBox = wlr_surface_get_buffer_source_box; - extern fn wlr_surface_accepts_touch(seat: *wlr.Seat, surface: *Surface) bool; - pub fn acceptsTouch(surface: *Surface, seat: *wlr.Seat) bool { - return wlr_surface_accepts_touch(seat, surface); - } + extern fn wlr_surface_accepts_touch(surface: *Surface, seat: *wlr.Seat) bool; + pub const acceptsTouch = wlr_surface_accepts_touch; - extern fn wlr_surface_accepts_tablet_v2(tablet: *wlr.TabletV2Tablet, surface: *Surface) bool; - pub fn acceptsTabletV2(surface: *Surface, tablet: *wlr.TabletV2Tablet) bool { - return wlr_surface_accepts_tablet_v2(tablet, surface); - } + extern fn wlr_surface_accepts_tablet_v2(surface: *Surface, tablet: *wlr.TabletV2Tablet) bool; + pub const acceptsTabletV2 = wlr_surface_accepts_tablet_v2; extern fn wlr_surface_lock_pending(surface: *Surface) u32; pub const lockPending = wlr_surface_lock_pending; diff --git a/src/types/content_type_v1.zig b/src/types/content_type_v1.zig index 2b637e9..de11438 100644 --- a/src/types/content_type_v1.zig +++ b/src/types/content_type_v1.zig @@ -13,6 +13,10 @@ pub const ContentTypeManagerV1 = extern struct { data: ?*anyopaque, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_content_type_manager_v1_create(server: *wl.Server, version: u32) ?*ContentTypeManagerV1; pub fn create(server: *wl.Server, version: u32) !*ContentTypeManagerV1 { return wlr_content_type_manager_v1_create(server, version) orelse error.OutOfMemory; diff --git a/src/types/cursor.zig b/src/types/cursor.zig index 57877ee..981c274 100644 --- a/src/types/cursor.zig +++ b/src/types/cursor.zig @@ -37,7 +37,7 @@ pub const Cursor = extern struct { tablet_tool_button: wl.Signal(*wlr.Tablet.event.Button), }, - data: usize, + data: ?*anyopaque, extern fn wlr_cursor_create() ?*Cursor; pub fn create() !*Cursor { diff --git a/src/types/cursor_shape_v1.zig b/src/types/cursor_shape_v1.zig index d75f7ba..5e51073 100644 --- a/src/types/cursor_shape_v1.zig +++ b/src/types/cursor_shape_v1.zig @@ -12,9 +12,11 @@ pub const CursorShapeManagerV1 = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, pub const DeviceType = enum(c_int) { pointer, diff --git a/src/types/damage_ring.zig b/src/types/damage_ring.zig index 6eb7b54..2940c30 100644 --- a/src/types/damage_ring.zig +++ b/src/types/damage_ring.zig @@ -6,17 +6,11 @@ const wl = wayland.server.wl; const pixman = @import("pixman"); pub const DamageRing = extern struct { - width: i32, - height: i32, - current: pixman.Region32, - // private state - - previous: [2]pixman.Region32, - previous_idx: usize, - - buffers: wl.list.Link, + private: extern struct { + buffers: wl.list.Link, + }, extern fn wlr_damage_ring_init(ring: *DamageRing) void; pub const init = wlr_damage_ring_init; @@ -24,24 +18,15 @@ pub const DamageRing = extern struct { extern fn wlr_damage_ring_finish(ring: *DamageRing) void; pub const finish = wlr_damage_ring_finish; - extern fn wlr_damage_ring_set_bounds(ring: *DamageRing, width: i32, height: i32) void; - pub const setBounds = wlr_damage_ring_set_bounds; - - extern fn wlr_damage_ring_add(ring: *DamageRing, damage: *const pixman.Region32) bool; + extern fn wlr_damage_ring_add(ring: *DamageRing, damage: *const pixman.Region32) void; pub const add = wlr_damage_ring_add; - extern fn wlr_damage_ring_add_box(ring: *DamageRing, box: ?*const wlr.Box) bool; + extern fn wlr_damage_ring_add_box(ring: *DamageRing, box: ?*const wlr.Box) void; pub const addBox = wlr_damage_ring_add_box; extern fn wlr_damage_ring_add_whole(ring: *DamageRing) void; pub const addWhole = wlr_damage_ring_add_whole; - extern fn wlr_damage_ring_rotate(ring: *DamageRing) void; - pub const rotate = wlr_damage_ring_rotate; - - extern fn wlr_damage_ring_get_buffer_damage(ring: *DamageRing, buffer_age: c_int, damage: *pixman.Region32) void; - pub const getBufferDamage = wlr_damage_ring_get_buffer_damage; - extern fn wlr_damage_ring_rotate_buffer(ring: *DamageRing, buffer: *wlr.Buffer, damage: *pixman.Region32) void; pub const rotateBuffer = wlr_damage_ring_rotate_buffer; }; diff --git a/src/types/data_control_v1.zig b/src/types/data_control_v1.zig index 3e6e651..ff8d9b6 100644 --- a/src/types/data_control_v1.zig +++ b/src/types/data_control_v1.zig @@ -12,7 +12,9 @@ pub const DataControlManagerV1 = extern struct { new_device: wl.Signal(*DataControlDeviceV1), }, - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_data_control_manager_v1_create(server: *wl.Server) ?*DataControlManagerV1; pub fn create(server: *wl.Server) !*DataControlManagerV1 { @@ -30,9 +32,11 @@ pub const DataControlDeviceV1 = extern struct { selection_offer_resource: ?*wl.Resource, primary_selection_offer_resource: ?*wl.Resource, - seat_destroy: wl.Listener(*wlr.Seat), - seat_set_selection: wl.Listener(*wlr.Seat), - seat_set_primary_selection: wl.Listener(*wlr.Seat), + private: extern struct { + seat_destroy: wl.Listener(void), + seat_set_selection: wl.Listener(void), + seat_set_primary_selection: wl.Listener(void), + }, extern fn wlr_data_control_device_v1_destroy(device: *DataControlDeviceV1) void; pub const destroy = wlr_data_control_device_v1_destroy; diff --git a/src/types/data_device.zig b/src/types/data_device.zig index cc1e81d..9a2e567 100644 --- a/src/types/data_device.zig +++ b/src/types/data_device.zig @@ -7,13 +7,15 @@ pub const DataDeviceManager = extern struct { global: *wl.Global, data_sources: wl.list.Head(wl.DataSource, null), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*DataDeviceManager), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_data_device_manager_create(server: *wl.Server) ?*DataDeviceManager; pub fn create(server: *wl.Server) !*DataDeviceManager { @@ -37,7 +39,9 @@ pub const DataOffer = extern struct { preferred_action: wl.DataDeviceManager.DndAction.Enum, in_ask: bool, - source_destroy: wl.Listener(*DataSource), + private: extern struct { + source_destroy: wl.Listener(void), + }, }; pub const DataSource = extern struct { @@ -95,9 +99,11 @@ pub const Drag = extern struct { destroy: wl.Signal(*Drag.Icon), }, - surface_destroy: wl.Listener(*wlr.Surface), + data: ?*anyopaque, - data: usize, + private: extern struct { + surface_destroy: wl.Listener(void), + }, }; pub const GrabType = enum(c_int) { @@ -146,11 +152,14 @@ pub const Drag = extern struct { destroy: wl.Signal(*Drag), }, - source_destroy: wl.Listener(*DataSource), - seat_client_destroy: wl.Listener(*wlr.Seat.Client), - icon_destroy: wl.Listener(*Drag.Icon), + data: ?*anyopaque, - data: usize, + private: extern struct { + source_destroy: wl.Listener(void), + seat_client_destroy: wl.Listener(void), + focus_destroy: wl.Listener(void), + icon_destroy: wl.Listener(void), + }, extern fn wlr_drag_create( seat_client: *wlr.Seat.Client, diff --git a/src/types/drm.zig b/src/types/drm.zig index e899de5..857e02d 100644 --- a/src/types/drm.zig +++ b/src/types/drm.zig @@ -10,12 +10,11 @@ pub const Drm = extern struct { destroy: wl.Signal(void), }, - // private state - - node_name: [*:0]u8, - formats: wlr.DrmFormatSet, - - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + node_name: ?[*:0]u8, + formats: wlr.DrmFormatSet, + server_destroy: wl.Listener(void), + }, extern fn wlr_drm_create(server: *wl.Server, renderer: *wlr.Renderer) ?*Drm; pub fn create(server: *wl.Server, renderer: *wlr.Renderer) !*Drm { diff --git a/src/types/drm_lease_v1.zig b/src/types/drm_lease_v1.zig index 0829627..7f0c8c2 100644 --- a/src/types/drm_lease_v1.zig +++ b/src/types/drm_lease_v1.zig @@ -6,11 +6,16 @@ const wl = wayland.server.wl; pub const DrmLeaseManagerV1 = extern struct { devices: wl.list.Head(DrmLeaseDeviceV1, .link), server: *wl.Server, - server_destroy: wl.Listener(*wl.Server), + events: extern struct { + destroy: wl.Signal(void), request: wl.Signal(*DrmLeaseRequestV1), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_drm_lease_v1_manager_create(server: *wl.Server, backend: *wlr.Backend) ?*DrmLeaseManagerV1; pub const create = wlr_drm_lease_v1_manager_create; @@ -34,9 +39,11 @@ pub const DrmLeaseDeviceV1 = extern struct { /// DrmLeaseManagerV1.devices link: wl.list.Link, - backend_destroy: wl.Listener(*wlr.Backend), - data: ?*anyopaque, + + private: extern struct { + backend_destroy: wl.Listener(void), + }, }; pub const DrmLeaseConnectorV1 = extern struct { @@ -47,9 +54,12 @@ pub const DrmLeaseConnectorV1 = extern struct { active_lease: ?*DrmLeaseV1, - destroy: wl.Listener(void), /// DrmLeaseDeviceV1.connectors link: wl.list.Link, + + private: extern struct { + destroy: wl.Listener(void), + }, }; pub const DrmLeaseRequestV1 = extern struct { @@ -84,10 +94,12 @@ pub const DrmLeaseV1 = extern struct { /// DrmLeaseDeviceV1.leases link: wl.list.Link, - destroy: wl.Listener(void), - data: ?*anyopaque, + private: extern struct { + destroy: wl.Listener(void), + }, + extern fn wlr_drm_lease_v1_revoke(lease: *DrmLeaseV1) void; pub const revoke = wlr_drm_lease_v1_revoke; }; diff --git a/src/types/export_dmabuf_v1.zig b/src/types/export_dmabuf_v1.zig index 3dbc062..c4c7eba 100644 --- a/src/types/export_dmabuf_v1.zig +++ b/src/types/export_dmabuf_v1.zig @@ -7,12 +7,14 @@ pub const ExportDmabufManagerV1 = extern struct { global: *wl.Global, frames: wl.list.Head(ExportDmabufFrameV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*ExportDmabufManagerV1), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_export_dmabuf_manager_v1_create(server: *wl.Server) ?*ExportDmabufManagerV1; pub fn create(server: *wl.Server) !*ExportDmabufManagerV1 { return wlr_export_dmabuf_manager_v1_create(server) orelse error.OutOfMemory; @@ -29,6 +31,8 @@ pub const ExportDmabufFrameV1 = extern struct { cursor_locked: bool, - output_commit: wl.Listener(*wlr.Output.event.Commit), - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + output_commit: wl.Listener(void), + output_destroy: wl.Listener(void), + }, }; diff --git a/src/types/foreign_toplevel_management_v1.zig b/src/types/foreign_toplevel_management_v1.zig index 76f8e05..acbd4d7 100644 --- a/src/types/foreign_toplevel_management_v1.zig +++ b/src/types/foreign_toplevel_management_v1.zig @@ -9,13 +9,15 @@ pub const ForeignToplevelManagerV1 = extern struct { resources: wl.list.Head(wl.Resource, null), toplevels: wl.list.Head(ForeignToplevelHandleV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*ForeignToplevelManagerV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_foreign_toplevel_manager_v1_create(wl_server: *wl.Server) ?*ForeignToplevelManagerV1; pub fn create(wl_server: *wl.Server) !*ForeignToplevelManagerV1 { @@ -37,10 +39,10 @@ pub const ForeignToplevelHandleV1 = extern struct { output: *wlr.Output, toplevel: *ForeignToplevelHandleV1, - // private state - - output_bind: wl.Listener(*wlr.Output.event.Bind), - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + output_bind: wl.Listener(void), + output_destroy: wl.Listener(void), + }, }; pub const event = struct { @@ -96,7 +98,7 @@ pub const ForeignToplevelHandleV1 = extern struct { destroy: wl.Signal(*ForeignToplevelHandleV1), }, - data: usize, + data: ?*anyopaque, extern fn wlr_foreign_toplevel_handle_v1_create(manager: *ForeignToplevelManagerV1) ?*ForeignToplevelHandleV1; pub fn create(manager: *ForeignToplevelManagerV1) !*ForeignToplevelHandleV1 { diff --git a/src/types/fractional_scale_v1.zig b/src/types/fractional_scale_v1.zig index baa6742..90ba7a3 100644 --- a/src/types/fractional_scale_v1.zig +++ b/src/types/fractional_scale_v1.zig @@ -10,7 +10,9 @@ pub const FractionalScaleManagerV1 = extern struct { destroy: wl.Signal(void), }, - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_fractional_scale_manager_v1_create(server: *wl.Server, version: u32) ?*FractionalScaleManagerV1; pub fn create(server: *wl.Server, version: u32) !*FractionalScaleManagerV1 { diff --git a/src/types/gamma_control_v1.zig b/src/types/gamma_control_v1.zig index f245935..11a163d 100644 --- a/src/types/gamma_control_v1.zig +++ b/src/types/gamma_control_v1.zig @@ -14,14 +14,16 @@ pub const GammaControlManagerV1 = extern struct { global: *wl.Global, controls: wl.list.Head(GammaControlV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*GammaControlManagerV1), set_gamma: wl.Signal(*event.SetGamma), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_gamma_control_manager_v1_create(server: *wl.Server) ?*GammaControlManagerV1; pub fn create(server: *wl.Server) !*GammaControlManagerV1 { @@ -42,9 +44,11 @@ pub const GammaControlV1 = extern struct { table: *u16, ramp_size: usize, - output_destroy_listener: wl.Listener(*wlr.Output), + data: ?*anyopaque, - data: usize, + private: extern struct { + output_destroy_listener: wl.Listener(void), + }, extern fn wlr_gamma_control_v1_apply(gamma_control: ?*GammaControlV1, output_state: *wlr.Output.State) bool; pub const apply = wlr_gamma_control_v1_apply; diff --git a/src/types/idle_inhibit_v1.zig b/src/types/idle_inhibit_v1.zig index 4818cf9..fcde54e 100644 --- a/src/types/idle_inhibit_v1.zig +++ b/src/types/idle_inhibit_v1.zig @@ -7,14 +7,16 @@ pub const IdleInhibitManagerV1 = extern struct { inhibitors: wl.list.Head(IdleInhibitorV1, .link), global: *wl.Global, - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_inhibitor: wl.Signal(*IdleInhibitorV1), destroy: wl.Signal(*IdleInhibitManagerV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_idle_inhibit_v1_create(server: *wl.Server) ?*IdleInhibitManagerV1; pub fn create(server: *wl.Server) !*IdleInhibitManagerV1 { @@ -25,7 +27,6 @@ pub const IdleInhibitManagerV1 = extern struct { pub const IdleInhibitorV1 = extern struct { surface: *wlr.Surface, resource: *wl.Resource, - surface_destroy: wl.Listener(*wlr.Surface), link: wl.list.Link, @@ -33,5 +34,9 @@ pub const IdleInhibitorV1 = extern struct { destroy: wl.Signal(*wlr.Surface), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + surface_destroy: wl.Listener(void), + }, }; diff --git a/src/types/idle_notify_v1.zig b/src/types/idle_notify_v1.zig index d691534..b07af4d 100644 --- a/src/types/idle_notify_v1.zig +++ b/src/types/idle_notify_v1.zig @@ -6,12 +6,12 @@ const wl = wayland.server.wl; pub const IdleNotifierV1 = extern struct { global: *wl.Global, - // private state + private: extern struct { + inhibited: bool, + notifications: wl.list.Link, - inhibited: bool, - notifications: wl.list.Link, - - server_destroy: wl.Listener(*wl.Server), + server_destroy: wl.Listener(void), + }, extern fn wlr_idle_notifier_v1_create(server: *wl.Server) ?*IdleNotifierV1; pub fn create(server: *wl.Server) !*IdleNotifierV1 { diff --git a/src/types/input_device.zig b/src/types/input_device.zig index 8ec8400..7dff2a6 100644 --- a/src/types/input_device.zig +++ b/src/types/input_device.zig @@ -20,7 +20,7 @@ pub const InputDevice = extern struct { destroy: wl.Signal(*InputDevice), }, - data: usize, + data: ?*anyopaque, extern fn wlr_keyboard_from_input_device(wlr_dev: *InputDevice) *wlr.Keyboard; pub const toKeyboard = wlr_keyboard_from_input_device; diff --git a/src/types/input_method_v2.zig b/src/types/input_method_v2.zig index 0d52382..2521a26 100644 --- a/src/types/input_method_v2.zig +++ b/src/types/input_method_v2.zig @@ -7,13 +7,15 @@ pub const InputMethodManagerV2 = extern struct { global: *wl.Global, input_methods: wl.list.Head(InputMethodV2, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { input_method: wl.Signal(*wlr.InputMethodV2), destroy: wl.Signal(*wlr.InputMethodManagerV2), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_input_method_manager_v2_create(server: *wl.Server) ?*wlr.InputMethodManagerV2; pub fn create(server: *wl.Server) !*wlr.InputMethodManagerV2 { return wlr_input_method_manager_v2_create(server) orelse error.OutOfMemory; @@ -43,14 +45,16 @@ pub const InputMethodV2 = extern struct { input_method: *wlr.InputMethodV2, keyboard: ?*wlr.Keyboard, - keyboard_keymap: wl.Listener(*wlr.Keyboard), - keyboard_repeat_info: wl.Listener(*wlr.Keyboard), - keyboard_destroy: wl.Listener(*wlr.Keyboard), - events: extern struct { destroy: wl.Signal(*wlr.InputMethodV2.KeyboardGrab), }, + private: extern struct { + keyboard_keymap: wl.Listener(void), + keyboard_repeat_info: wl.Listener(void), + keyboard_destroy: wl.Listener(void), + }, + extern fn wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, time: u32, key: u32, state: u32) void; pub fn sendKey(keyboard_grab: *wlr.InputMethodV2.KeyboardGrab, time: u32, key: u32, state: wl.Keyboard.KeyState) void { wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, time, key, @as(u32, @intCast(@intFromEnum(state)))); @@ -81,8 +85,6 @@ pub const InputMethodV2 = extern struct { link: wl.list.Link, - seat_client_destroy: wl.Listener(*wlr.Seat.Client), - events: extern struct { commit: wl.Signal(*wlr.InputMethodV2), new_popup_surface: wl.Signal(*wlr.InputPopupSurfaceV2), @@ -90,6 +92,10 @@ pub const InputMethodV2 = extern struct { destroy: wl.Signal(*wlr.InputMethodV2), }, + private: extern struct { + seat_client_destroy: wl.Listener(void), + }, + extern fn wlr_input_method_v2_send_activate(input_method: *wlr.InputMethodV2) void; pub const sendActivate = wlr_input_method_v2_send_activate; @@ -123,7 +129,7 @@ pub const InputPopupSurfaceV2 = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, extern fn wlr_input_popup_surface_v2_try_from_wlr_surface(surface: *wlr.Surface) ?*wlr.InputPopupSurfaceV2; pub const tryFromWlrSurface = wlr_input_popup_surface_v2_try_from_wlr_surface; diff --git a/src/types/keyboard.zig b/src/types/keyboard.zig index 8e03e1d..214d6fd 100644 --- a/src/types/keyboard.zig +++ b/src/types/keyboard.zig @@ -74,7 +74,7 @@ pub const Keyboard = extern struct { repeat_info: wl.Signal(*Keyboard), }, - data: usize, + data: ?*anyopaque, extern fn wlr_keyboard_set_keymap(kb: *Keyboard, keymap: ?*xkb.Keymap) bool; pub const setKeymap = wlr_keyboard_set_keymap; diff --git a/src/types/keyboard_group.zig b/src/types/keyboard_group.zig index b77bdd4..03f82fa 100644 --- a/src/types/keyboard_group.zig +++ b/src/types/keyboard_group.zig @@ -16,7 +16,7 @@ pub const KeyboardGroup = extern struct { leave: wl.Signal(*wl.Array), }, - data: usize, + data: ?*anyopaque, extern fn wlr_keyboard_group_create() ?*KeyboardGroup; pub fn create() !*KeyboardGroup { diff --git a/src/types/keyboard_shortcuts_inhibit_v1.zig b/src/types/keyboard_shortcuts_inhibit_v1.zig index cc076de..7a82d20 100644 --- a/src/types/keyboard_shortcuts_inhibit_v1.zig +++ b/src/types/keyboard_shortcuts_inhibit_v1.zig @@ -7,14 +7,16 @@ pub const KeyboardShortcutsInhibitManagerV1 = extern struct { inhibitors: wl.list.Head(wlr.KeyboardShortcutsInhibitorV1, .link), global: *wl.Global, - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_inhibitor: wl.Signal(*wlr.KeyboardShortcutsInhibitorV1), destroy: wl.Signal(*wlr.KeyboardShortcutsInhibitManagerV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_keyboard_shortcuts_inhibit_v1_create(server: *wl.Server) ?*wlr.KeyboardShortcutsInhibitManagerV1; pub fn create(server: *wl.Server) !*wlr.KeyboardShortcutsInhibitManagerV1 { @@ -28,16 +30,18 @@ pub const KeyboardShortcutsInhibitorV1 = extern struct { active: bool, resource: *wl.Resource, - surface_destroy: wl.Listener(*wlr.Surface), - seat_destroy: wl.Listener(*wlr.Seat), - link: wl.list.Link, events: extern struct { destroy: wl.Signal(*wlr.KeyboardShortcutsInhibitorV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + surface_destroy: wl.Listener(void), + seat_destroy: wl.Listener(void), + }, extern fn wlr_keyboard_shortcuts_inhibitor_v1_activate(inhibitor: *wlr.KeyboardShortcutsInhibitorV1) void; pub const activate = wlr_keyboard_shortcuts_inhibitor_v1_activate; diff --git a/src/types/layer_shell_v1.zig b/src/types/layer_shell_v1.zig index 6dc9f6c..3c32c25 100644 --- a/src/types/layer_shell_v1.zig +++ b/src/types/layer_shell_v1.zig @@ -7,14 +7,16 @@ const zwlr = wayland.server.zwlr; pub const LayerShellV1 = extern struct { global: *wl.Global, - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_surface: wl.Signal(*LayerSurfaceV1), destroy: wl.Signal(*LayerShellV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_layer_shell_v1_create(server: *wl.Server, version: u32) ?*LayerShellV1; pub fn create(server: *wl.Server, version: u32) !*LayerShellV1 { @@ -31,7 +33,8 @@ pub const LayerSurfaceV1 = extern struct { margin: bool = false, keyboard_interactivity: bool = false, layer: bool = false, - _: u26 = 0, + exclusive_edge: bool = false, + _: u25 = 0, }; committed: Fields, @@ -47,6 +50,7 @@ pub const LayerSurfaceV1 = extern struct { desired_width: u32, desired_height: u32, layer: zwlr.LayerShellV1.Layer, + exclusive_edge: u32, configure_serial: u32, actual_width: u32, @@ -86,11 +90,11 @@ pub const LayerSurfaceV1 = extern struct { new_popup: wl.Signal(*wlr.XdgPopup), }, - data: usize, + data: ?*anyopaque, - // private state - - synced: wlr.Surface.Synced, + private: extern struct { + synced: wlr.Surface.Synced, + }, extern fn wlr_layer_surface_v1_configure(surface: *LayerSurfaceV1, width: u32, height: u32) u32; pub const configure = wlr_layer_surface_v1_configure; diff --git a/src/types/linux_dmabuf_v1.zig b/src/types/linux_dmabuf_v1.zig index 645bc81..58bf6d9 100644 --- a/src/types/linux_dmabuf_v1.zig +++ b/src/types/linux_dmabuf_v1.zig @@ -13,9 +13,9 @@ pub const DmabufBufferV1 = extern struct { resource: ?*wl.Resource, attributes: wlr.DmabufAttributes, - // private state - - release: wl.Listener(void), + private: extern struct { + release: wl.Listener(void), + }, extern fn wlr_dmabuf_v1_buffer_try_from_buffer_resource(buffer_resource: *wl.Resource) ?*DmabufBufferV1; pub const tryFromBufferResource = wlr_dmabuf_v1_buffer_try_from_buffer_resource; @@ -31,6 +31,19 @@ pub const LinuxDmabufFeedbackV1 = extern struct { main_device: posix.dev_t, tranches: wl.Array, + private: extern struct { + default_feedback: *LinuxDmabufFeedbackV1Compiled, + default_formats: wlr.DrmFormatSet, + surfaces: wl.list.Link, + + main_device_fd: c_int, + + server_destroy: wl.Listener(void), + + check_dmabuf_callback: ?*anyopaque, + check_dmabuf_callback_data: ?*anyopaque, + }, + extern fn wlr_linux_dmabuf_feedback_add_tranche(feedback: *LinuxDmabufFeedbackV1) ?*Tranche; pub fn addTranche(feedback: *LinuxDmabufFeedbackV1) !*Tranche { return wlr_linux_dmabuf_feedback_add_tranche(feedback) orelse error.OutOfMemory; @@ -58,19 +71,6 @@ pub const LinuxDmabufV1 = extern struct { destroy: wl.Signal(*LinuxDmabufV1), }, - // private state - - default_feedback: *LinuxDmabufFeedbackV1Compiled, - default_formats: wlr.DrmFormatSet, - surfaces: wl.list.Link, - - main_device_fd: c_int, - - server_destroy: wl.Listener(*wl.Server), - - check_dmabuf_callback: *const fn (attribs: *wlr.DmabufAttributes, data: ?*anyopaque) callconv(.C) bool, - check_dmabuf_callback_data: ?*anyopaque, - extern fn wlr_linux_dmabuf_v1_create(server: *wl.Server, version: u32, default_feedback: *const LinuxDmabufFeedbackV1) ?*LinuxDmabufV1; pub fn create(server: *wl.Server, version: u32, default_feedback: *const LinuxDmabufFeedbackV1) !*LinuxDmabufV1 { return wlr_linux_dmabuf_v1_create(server, version, default_feedback) orelse error.OutOfMemory; diff --git a/src/types/matrix.zig b/src/types/matrix.zig deleted file mode 100644 index 5f487a2..0000000 --- a/src/types/matrix.zig +++ /dev/null @@ -1,28 +0,0 @@ -const wlr = @import("../wlroots.zig"); - -const wayland = @import("wayland"); -const wl = wayland.server.wl; - -extern fn wlr_matrix_identity(mat: *[9]f32) void; -pub const identity = wlr_matrix_identity; - -extern fn wlr_matrix_multiply(mat: *[9]f32, a: *const [9]f32, b: *const [9]f32) void; -pub const multiply = wlr_matrix_multiply; - -extern fn wlr_matrix_transpose(mat: *[9]f32, a: *const [9]f32) void; -pub const transpose = wlr_matrix_transpose; - -extern fn wlr_matrix_translate(mat: *[9]f32, x: f32, y: f32) void; -pub const translate = wlr_matrix_translate; - -extern fn wlr_matrix_scale(mat: *[9]f32, x: f32, y: f32) void; -pub const scale = wlr_matrix_scale; - -extern fn wlr_matrix_rotate(mat: *[9]f32, rad: f32) void; -pub const rotate = wlr_matrix_rotate; - -extern fn wlr_matrix_transform(mat: *[9]f32, transform: wl.Output.Transform) void; -pub const transform = wlr_matrix_transform; - -extern fn wlr_matrix_project_box(mat: *[9]f32, box: *const wlr.Box, transform: wl.Output.Transform, rotation: f32, projection: *const [9]f32) void; -pub const projectBox = wlr_matrix_project_box; diff --git a/src/types/output.zig b/src/types/output.zig index b91ed16..661413e 100644 --- a/src/types/output.zig +++ b/src/types/output.zig @@ -46,7 +46,9 @@ pub const Output = extern struct { render_format: bool = false, subpixel: bool = false, layers: bool = false, - _: u21 = 0, + wait_timeline: bool = false, + signal_timeline: bool = false, + _: u19 = 0, }; pub const ModeType = enum(c_int) { @@ -65,6 +67,9 @@ pub const Output = extern struct { subpixel: wl.Output.Subpixel, buffer: ?*wlr.Buffer, + buffer_src_box: wlr.FBox, + buffer_dst_box: wlr.FBox, + tearing_page_flip: bool, mode_type: ModeType, @@ -82,6 +87,12 @@ pub const Output = extern struct { layers: ?*anyopaque, layers_len: usize, + wait_timeline: *wlr.DrmSyncobjTimeline, + wait_point: u64, + + signal_timeline: *wlr.DrmSyncobjTimeline, + signal_point: u64, + extern fn wlr_output_state_init(state: *State) void; pub fn init() State { var state: State = undefined; @@ -170,7 +181,7 @@ pub const Output = extern struct { output: *wlr.Output, commit_seq: u32, presented: bool, - when: *posix.timespec, + when: posix.timespec, seq: c_uint, refresh: c_int, flags: Flags, @@ -258,11 +269,13 @@ pub const Output = extern struct { renderer: ?*wlr.Renderer, swapchain: ?*wlr.Swapchain, - server_destroy: wl.Listener(*wl.Server), - addons: wlr.AddonSet, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_output_create_global(output: *Output, server: *wl.Server) void; pub const createGlobal = wlr_output_create_global; @@ -378,10 +391,15 @@ pub const OutputCursor = extern struct { hotspot_y: i32, texture: ?*wlr.Texture, own_texture: bool, - renderer_destroy: wl.Listener(void), + wait_timeline: ?*wlr.DrmSyncobjTimeline, + wait_point: u64, /// Output.cursors link: wl.list.Link, + private: extern struct { + renderer_destroy: wl.Listener(void), + }, + extern fn wlr_output_cursor_create(output: *Output) ?*OutputCursor; pub fn create(output: *Output) !*OutputCursor { return wlr_output_cursor_create(output) orelse error.OutOfMemory; diff --git a/src/types/output_layout.zig b/src/types/output_layout.zig index d29e219..9105bc9 100644 --- a/src/types/output_layout.zig +++ b/src/types/output_layout.zig @@ -19,11 +19,10 @@ pub const OutputLayout = extern struct { destroy: wl.Signal(*OutputLayout.Output), }, - // private state - - addon: *wlr.Addon, - - commit: wl.Listener(*wlr.Output.event.Commit), + private: extern struct { + addon: wlr.Addon, + commit: wl.Listener(void), + }, }; pub const Direction = enum(c_int) { @@ -42,10 +41,11 @@ pub const OutputLayout = extern struct { destroy: wl.Signal(*OutputLayout), }, - data: usize, + data: ?*anyopaque, - // private state - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_output_layout_create(server: *wl.Server) ?*OutputLayout; pub fn create(server: *wl.Server) !*OutputLayout { diff --git a/src/types/output_management_v1.zig b/src/types/output_management_v1.zig index 682ae7a..412a6e3 100644 --- a/src/types/output_management_v1.zig +++ b/src/types/output_management_v1.zig @@ -16,9 +16,11 @@ pub const OutputManagerV1 = extern struct { destroy: wl.Signal(*OutputManagerV1), }, - server_destroy: wl.Listener(*wl.Server), + data: ?*anyopaque, - data: usize, + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_output_manager_v1_create(server: *wl.Server) ?*OutputManagerV1; pub fn create(server: *wl.Server) !*OutputManagerV1 { @@ -57,7 +59,9 @@ pub const OutputHeadV1 = extern struct { resources: wl.list.Head(wl.Resource, null), mode_resources: wl.list.Head(wl.Resource, null), - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + output_destroy: wl.Listener(void), + }, }; pub const OutputConfigurationV1 = extern struct { @@ -68,7 +72,9 @@ pub const OutputConfigurationV1 = extern struct { resource: ?*wl.Resource, - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + output_destroy: wl.Listener(void), + }, extern fn wlr_output_configuration_head_v1_create(config: *OutputConfigurationV1, output: *wlr.Output) ?*Head; pub fn create(config: *OutputConfigurationV1, output: *wlr.Output) !*Head { diff --git a/src/types/output_power_management_v1.zig b/src/types/output_power_management_v1.zig index 5787d7a..713fb5e 100644 --- a/src/types/output_power_management_v1.zig +++ b/src/types/output_power_management_v1.zig @@ -15,14 +15,16 @@ pub const OutputPowerManagerV1 = extern struct { global: *wl.Global, output_powers: wl.list.Head(OutputPowerV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { set_mode: wl.Signal(*event.SetMode), destroy: wl.Signal(*OutputPowerManagerV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_output_power_manager_v1_create(server: *wl.Server) ?*OutputPowerManagerV1; pub fn create(server: *wl.Server) !*OutputPowerManagerV1 { @@ -37,8 +39,10 @@ pub const OutputPowerV1 = extern struct { /// OutputPowerManagerV1.output_powers link: wl.list.Link, - output_destroy_listener: wl.Listener(*wlr.Output), - output_commit_listener: wl.Listener(*wlr.Output.event.Commit), + data: ?*anyopaque, - data: usize, + private: extern struct { + output_destroy: wl.Listener(void), + output_commit: wl.Listener(void), + }, }; diff --git a/src/types/output_swapchain_manager.zig b/src/types/output_swapchain_manager.zig index 8fc48f6..eb938c9 100644 --- a/src/types/output_swapchain_manager.zig +++ b/src/types/output_swapchain_manager.zig @@ -6,9 +6,9 @@ const wl = wayland.server.wl; pub const OutputSwapchainManager = extern struct { backend: *wlr.Backend, - // private state - - outputs: wl.Array, + private: extern struct { + outputs: wl.Array, + }, extern fn wlr_output_swapchain_manager_init(manager: *OutputSwapchainManager, backend: *wlr.Backend) void; pub const init = wlr_output_swapchain_manager_init; diff --git a/src/types/pointer.zig b/src/types/pointer.zig index 28f08cb..30eb72c 100644 --- a/src/types/pointer.zig +++ b/src/types/pointer.zig @@ -101,6 +101,9 @@ pub const Pointer = extern struct { output_name: [*:0]u8, + buttons: [16]u32, + button_count: usize, + events: extern struct { motion: wl.Signal(*event.Motion), motion_absolute: wl.Signal(*event.MotionAbsolute), diff --git a/src/types/pointer_constraints_v1.zig b/src/types/pointer_constraints_v1.zig index 6ec3618..70b0da8 100644 --- a/src/types/pointer_constraints_v1.zig +++ b/src/types/pointer_constraints_v1.zig @@ -48,15 +48,16 @@ pub const PointerConstraintV1 = extern struct { destroy: wl.Signal(*PointerConstraintV1), }, - data: usize, + data: ?*anyopaque, - // private state + private: extern struct { + surface_destroy: wl.Listener(void), + seat_destroy: wl.Listener(void), - surface_commit: wl.Listener(*wlr.Surface), - surface_destroy: wl.Listener(*wlr.Surface), - seat_destroy: wl.Listener(*wl.Seat), + synced: wlr.Surface.Synced, - synced: wlr.Surface.Synced, + destroying: bool, + }, extern fn wlr_pointer_constraint_v1_send_activated(constraint: *PointerConstraintV1) void; pub const sendActivated = wlr_pointer_constraint_v1_send_activated; @@ -70,12 +71,15 @@ pub const PointerConstraintsV1 = extern struct { constraints: wl.list.Head(PointerConstraintV1, .link), events: extern struct { + destroy: wl.Signal(void), new_constraint: wl.Signal(*PointerConstraintV1), }, - server_destroy: wl.Listener(*wl.Server), + data: ?*anyopaque, - data: usize, + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_pointer_constraints_v1_create(server: *wl.Server) ?*PointerConstraintsV1; pub fn create(server: *wl.Server) !*PointerConstraintsV1 { diff --git a/src/types/pointer_gestures_v1.zig b/src/types/pointer_gestures_v1.zig index ba48a70..5ecca19 100644 --- a/src/types/pointer_gestures_v1.zig +++ b/src/types/pointer_gestures_v1.zig @@ -11,13 +11,15 @@ pub const PointerGesturesV1 = extern struct { pinches: wl.list.Head(zwp.PointerGesturePinchV1, null), holds: wl.list.Head(zwp.PointerGestureHoldV1, null), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*PointerGesturesV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_pointer_gestures_v1_create(server: *wl.Server) ?*PointerGesturesV1; pub fn create(server: *wl.Server) !*PointerGesturesV1 { diff --git a/src/types/presentation_time.zig b/src/types/presentation_time.zig index 00d50b6..626c223 100644 --- a/src/types/presentation_time.zig +++ b/src/types/presentation_time.zig @@ -12,11 +12,13 @@ pub const Presentation = extern struct { destroy: wl.Signal(*wlr.Presentation), }, - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, - extern fn wlr_presentation_create(server: *wl.Server, backend: *wlr.Backend) ?*wlr.Presentation; - pub fn create(server: *wl.Server, backend: *wlr.Backend) !*wlr.Presentation { - return wlr_presentation_create(server, backend) orelse error.OutOfMemory; + extern fn wlr_presentation_create(server: *wl.Server, backend: *wlr.Backend, version: u32) ?*wlr.Presentation; + pub fn create(server: *wl.Server, backend: *wlr.Backend, version: c_int) !*wlr.Presentation { + return wlr_presentation_create(server, backend, version) orelse error.OutOfMemory; } extern fn wlr_presentation_surface_sampled(surface: *wlr.Surface) ?*wlr.PresentationFeedback; @@ -37,9 +39,11 @@ pub const PresentationFeedback = extern struct { output_commit_seq: u32, zero_copy: bool, - output_commit: wl.Listener(*wlr.Output.event.Commit), - output_present: wl.Listener(*wlr.Output.event.Present), - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + output_commit: wl.Listener(void), + output_present: wl.Listener(void), + output_destroy: wl.Listener(void), + }, extern fn wlr_presentation_feedback_send_presented(feedback: *wlr.PresentationFeedback, event: *const wlr.PresentationEvent) void; pub const sendPresented = wlr_presentation_feedback_send_presented; diff --git a/src/types/primary_selection.zig b/src/types/primary_selection.zig index 7ad79fd..42fea66 100644 --- a/src/types/primary_selection.zig +++ b/src/types/primary_selection.zig @@ -16,7 +16,7 @@ pub const PrimarySelectionSource = extern struct { destroy: wl.Signal(*PrimarySelectionSource), }, - data: usize, + data: ?*anyopaque, extern fn wlr_primary_selection_source_init(source: *PrimarySelectionSource, impl: *const PrimarySelectionSource.Impl) void; pub const init = wlr_primary_selection_source_init; diff --git a/src/types/primary_selection_v1.zig b/src/types/primary_selection_v1.zig index 5773e5e..05156db 100644 --- a/src/types/primary_selection_v1.zig +++ b/src/types/primary_selection_v1.zig @@ -8,13 +8,15 @@ pub const PrimarySelectionDeviceManagerV1 = extern struct { /// PrimarySelectionV1Device.link devices: wl.list.Head(PrimarySelectionDeviceV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*PrimarySelectionDeviceManagerV1), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_primary_selection_v1_device_manager_create(server: *wl.Server) ?*PrimarySelectionDeviceManagerV1; pub fn create(server: *wl.Server) !*PrimarySelectionDeviceManagerV1 { @@ -31,9 +33,11 @@ pub const PrimarySelectionDeviceV1 = extern struct { offers: wl.list.Head(wl.Resource, null), - seat_destroy: wl.Listener(*wlr.Seat), - seat_focus_change: wl.Listener(*wlr.Seat.event.KeyboardFocusChange), - seat_set_primary_selection: wl.Listener(*wlr.Seat.event.RequestSetPrimarySelection), + data: ?*anyopaque, - data: usize, + private: extern struct { + seat_destroy: wl.Listener(void), + seat_focus_change: wl.Listener(void), + seat_set_primary_selection: wl.Listener(void), + }, }; diff --git a/src/types/relative_pointer_v1.zig b/src/types/relative_pointer_v1.zig index c039351..39e0a64 100644 --- a/src/types/relative_pointer_v1.zig +++ b/src/types/relative_pointer_v1.zig @@ -12,9 +12,11 @@ pub const RelativePointerManagerV1 = extern struct { new_relative_pointer: wl.Signal(*RelativePointerV1), }, - server_destroy: wl.Listener(*wl.Server), + data: ?*anyopaque, - data: usize, + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_relative_pointer_manager_v1_create(server: *wl.Server) ?*RelativePointerManagerV1; pub fn create(server: *wl.Server) !*RelativePointerManagerV1 { @@ -43,10 +45,12 @@ pub const RelativePointerV1 = extern struct { destroy: wl.Signal(*RelativePointerV1), }, - seat_destroy: wl.Listener(*wlr.Seat), - pointer_destroy: wl.Listener(*wlr.Pointer), + data: ?*anyopaque, - data: usize, + private: extern struct { + seat_destroy: wl.Listener(void), + pointer_destroy: wl.Listener(void), + }, extern fn wlr_relative_pointer_v1_from_resource(resource: *wl.Resource) ?*RelativePointerV1; pub const fromResource = wlr_relative_pointer_v1_from_resource; diff --git a/src/types/scene.zig b/src/types/scene.zig index 1636e8d..3b33395 100644 --- a/src/types/scene.zig +++ b/src/types/scene.zig @@ -28,13 +28,13 @@ pub const SceneNode = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, addons: wlr.AddonSet, - // private state - - visible: pixman.Region32, + private: extern struct { + visible: pixman.Region32, + }, extern fn wlr_scene_node_at(node: *SceneNode, lx: f64, ly: f64, nx: *f64, ny: *f64) ?*SceneNode; pub const at = wlr_scene_node_at; @@ -147,21 +147,19 @@ pub const Scene = extern struct { outputs: wl.list.Head(SceneOutput, .link), linux_dmabuf_v1: ?*wlr.LinuxDmabufV1, + gamma_control_manager_v1: ?*wlr.GammaControlManagerV1, - // private state + private: extern struct { + linux_dmabuf_v1_destroy: wl.Listener(void), + gamma_control_manager_v1_destroy: wl.Listener(void), + gamma_control_manager_v1_set_gamma: wl.Listener(void), - linux_dmabuf_v1_destroy: wl.Listener(*wlr.LinuxDmabufV1), - - debug_damage_option: enum(c_int) { - none, - rerender, - highlight, + debug_damage_option: c_int, + direct_scanout: bool, + calculate_visibility: bool, + highlight_transparent_region: bool, }, - direct_scanout: bool, - calculate_visibility: bool, - highlight_transparent_region: bool, - extern fn wlr_scene_create() ?*Scene; pub fn create() !*Scene { return wlr_scene_create() orelse error.OutOfMemory; @@ -178,6 +176,9 @@ pub const Scene = extern struct { extern fn wlr_scene_set_linux_dmabuf_v1(scene: *Scene, linux_dmabuf_v1: *wlr.LinuxDmabufV1) void; pub const setLinuxDmabufV1 = wlr_scene_set_linux_dmabuf_v1; + extern fn wlr_scene_set_gamma_control_manager_v1(scene: *Scene, gamma_control: *wlr.GammaControlManagerV1) void; + pub const setGammaControlManagerV1 = wlr_scene_set_gamma_control_manager_v1; + extern fn wlr_scene_output_create(scene: *Scene, output: *wlr.Output) ?*SceneOutput; pub fn createSceneOutput(scene: *Scene, output: *wlr.Output) !*SceneOutput { return wlr_scene_output_create(scene, output) orelse error.OutOfMemory; @@ -193,19 +194,18 @@ pub const SceneSurface = extern struct { buffer: *SceneBuffer, surface: *wlr.Surface, - // private state + private: extern struct { + clip: wlr.Box, + addon: wlr.Addon, - clip: wlr.Box, - - addon: wlr.Addon, - - outputs_update: wl.Listener(*SceneBuffer.event.OutputsUpdate), - output_enter: wl.Listener(*SceneOutput), - output_leave: wl.Listener(*SceneOutput), - output_sample: wl.Listener(*SceneBuffer.event.OutputSample), - frame_done: wl.Listener(*posix.timespec), - surface_destroy: wl.Listener(void), - surface_commit: wl.Listener(void), + outputs_update: wl.Listener(void), + output_enter: wl.Listener(void), + output_leave: wl.Listener(void), + output_sample: wl.Listener(void), + frame_done: wl.Listener(void), + surface_destroy: wl.Listener(void), + surface_commit: wl.Listener(void), + }, extern fn wlr_scene_surface_try_from_buffer(buffer: *SceneBuffer) ?*SceneSurface; pub const tryFromBuffer = wlr_scene_surface_try_from_buffer; @@ -262,19 +262,25 @@ pub const SceneBuffer = extern struct { transform: wl.Output.Transform, opaque_region: pixman.Region32, - // private state + private: extern struct { + active_outputs: u64, + texture: ?*wlr.Texture, + prev_feedback_options: wlr.LinuxDmabufFeedbackV1.InitOptions, - active_outputs: u64, - texture: ?*wlr.Texture, - prev_feedback_options: wlr.LinuxDmabufFeedbackV1.InitOptions, + own_buffer: bool, + buffer_width: c_int, + buffer_height: c_int, + buffer_is_opaque: bool, - own_buffer: bool, - buffer_width: c_int, - buffer_height: c_int, - buffer_is_opaque: bool, + wait_timeline: ?*wlr.DrmSyncobjTimeline, + wait_point: u64, - buffer_release: wl.Listener(void), - renderer_destroy: wl.Listener(void), + buffer_release: wl.Listener(void), + renderer_destroy: wl.Listener(void), + + is_single_pixel_buffer: bool, + single_pixel_buffer_color: [4]u32, + }, extern fn wlr_scene_buffer_from_node(node: *SceneNode) *SceneBuffer; pub const fromNode = wlr_scene_buffer_from_node; @@ -323,20 +329,28 @@ pub const SceneOutput = extern struct { destroy: wl.Signal(void), }, - // private state + private: extern struct { + pending_commit_damage: pixman.Region32, - pending_commit_damage: pixman.Region32, + index: u8, - index: u8, - prev_scanout: bool, + dmabuf_feedback_debounce: u8, + prev_scanout: bool, - output_commit: wl.Listener(*wlr.Output.event.Commit), - output_damage: wl.Listener(void), - output_needs_frame: wl.Listener(void), + gamma_lut_changed: bool, + gamma_lut: ?*wlr.GammaControlV1, - damage_highlight_regions: wl.list.Link, + output_commit: wl.Listener(void), + output_damage: wl.Listener(void), + output_needs_frame: wl.Listener(void), - render_list: wl.Array, + damage_highlight_regions: wl.list.Link, + + render_list: wl.Array, + + in_timeline: ?*wlr.DrmSyncobjTimeline, + in_point: u64, + }, pub const StateOptions = extern struct { timer: ?*wlr.SceneTimer = null, @@ -344,6 +358,9 @@ pub const SceneOutput = extern struct { swapchain: ?*wlr.Swapchain = null, }; + extern fn wlr_scene_output_needs_frame(scene_output: *SceneOutput) bool; + pub const needsFrame = wlr_scene_output_needs_frame; + extern fn wlr_scene_output_commit(scene_output: *SceneOutput, options: ?*const StateOptions) bool; pub const commit = wlr_scene_output_commit; @@ -397,12 +414,12 @@ pub const SceneLayerSurfaceV1 = extern struct { tree: *SceneTree, layer_surface: *wlr.LayerSurfaceV1, - // private state - - tree_destroy: wl.Listener(void), - layer_surface_destroy: wl.Listener(*wlr.LayerSurfaceV1), - layer_surface_map: wl.Listener(*wlr.LayerSurfaceV1), - layer_surface_unmap: wl.Listener(*wlr.LayerSurfaceV1), + private: extern struct { + tree_destroy: wl.Listener(void), + layer_surface_destroy: wl.Listener(void), + layer_surface_map: wl.Listener(void), + layer_surface_unmap: wl.Listener(void), + }, extern fn wlr_scene_layer_surface_v1_configure( scene_layer_surface: *SceneLayerSurfaceV1, diff --git a/src/types/screencopy_v1.zig b/src/types/screencopy_v1.zig index 85c537f..53193f4 100644 --- a/src/types/screencopy_v1.zig +++ b/src/types/screencopy_v1.zig @@ -6,11 +6,16 @@ const wl = wayland.server.wl; pub const ScreencopyManagerV1 = extern struct { global: *wl.Global, frames: wl.list.Head(ScreencopyFrameV1, .link), - server_destroy: wl.Listener(*wl.Server), + events: extern struct { destroy: wl.Signal(*ScreencopyManagerV1), }, - data: usize, + + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_screencopy_manager_v1_create(server: *wl.Server) ?*ScreencopyManagerV1; pub fn create(server: *wl.Server) !*ScreencopyManagerV1 { @@ -45,9 +50,11 @@ pub const ScreencopyFrameV1 = extern struct { buffer: *wlr.Buffer, output: *wlr.Output, - output_commit: wl.Listener(*wlr.Output.event.Commit), - output_destroy: wl.Listener(*wlr.Output), - output_enable: wl.Listener(*wlr.Output), - data: usize, + data: ?*anyopaque, + + private: extern struct { + output_commit: wl.Listener(void), + output_destroy: wl.Listener(void), + }, }; diff --git a/src/types/seat.zig b/src/types/seat.zig index d6566de..8beeffc 100644 --- a/src/types/seat.zig +++ b/src/types/seat.zig @@ -26,16 +26,18 @@ pub const TouchPoint = extern struct { sx: f64, sy: f64, - surface_destroy: wl.Listener(*wlr.Surface), - focus_surface_destroy: wl.Listener(*wlr.Surface), - client_destroy: wl.Listener(*Seat.Client), - events: extern struct { destroy: wl.Signal(*TouchPoint), }, /// Seat.TouchState.touch_points link: wl.list.Link, + + private: extern struct { + surface_destroy: wl.Listener(void), + focus_surface_destroy: wl.Listener(void), + client_destroy: wl.Listener(void), + }, }; pub const Seat = extern struct { @@ -108,7 +110,7 @@ pub const Seat = extern struct { interface: *const Interface, seat: *Seat, - data: usize, + data: ?*anyopaque, }; pub const KeyboardGrab = extern struct { @@ -128,7 +130,7 @@ pub const Seat = extern struct { interface: *const Interface, seat: *Seat, - data: usize, + data: ?*anyopaque, }; pub const TouchGrab = extern struct { @@ -144,10 +146,15 @@ pub const Seat = extern struct { interface: *const Interface, seat: *Seat, - data: usize, + data: ?*anyopaque, }; pub const PointerState = extern struct { + pub const Button = extern struct { + button: u32, + n_pressed: usize, + }; + seat: *Seat, focused_client: ?*Seat.Client, focused_surface: ?*wlr.Surface, @@ -160,17 +167,19 @@ pub const Seat = extern struct { sent_axis_source: bool, cached_axis_source: wl.Pointer.AxisSource, - buttons: [16]u32, + buttons: [16]Button, button_count: usize, grab_button: u32, grab_serial: u32, grab_time: u32, - surface_destroy: wl.Listener(*wlr.Surface), - events: extern struct { focus_change: wl.Signal(*event.PointerFocusChange), }, + + private: extern struct { + surface_destroy: wl.Listener(void), + }, }; pub const KeyboardState = extern struct { @@ -180,18 +189,20 @@ pub const Seat = extern struct { focused_client: ?*Seat.Client, focused_surface: ?*wlr.Surface, - keyboard_destroy: wl.Listener(*wlr.Keyboard), - keyboard_keymap: wl.Listener(*wlr.Keyboard), - keyboard_repeat_info: wl.Listener(*wlr.Keyboard), - - surface_destroy: wl.Listener(*wlr.Surface), - grab: *KeyboardGrab, default_grab: *KeyboardGrab, events: extern struct { focus_change: wl.Signal(*event.KeyboardFocusChange), }, + + private: extern struct { + keyboard_destroy: wl.Listener(void), + keyboard_keymap: wl.Listener(void), + keyboard_repeat_info: wl.Listener(void), + + surface_destroy: wl.Listener(void), + }, }; pub const TouchState = extern struct { @@ -253,7 +264,6 @@ pub const Seat = extern struct { capabilities: u32, accumulated_capabilities: u32, - last_event: posix.timespec, selection_source: ?*wlr.DataSource, selection_serial: u32, @@ -273,11 +283,6 @@ pub const Seat = extern struct { keyboard_state: KeyboardState, touch_state: TouchState, - server_destroy: wl.Listener(*wl.Server), - selection_source_destroy: wl.Listener(*wlr.DataSource), - primary_selection_source_destroy: wl.Listener(*wlr.PrimarySelectionSource), - drag_source_destroy: wl.Listener(*wlr.DataSource), - events: extern struct { pointer_grab_begin: wl.Signal(*PointerGrab), pointer_grab_end: wl.Signal(*PointerGrab), @@ -302,7 +307,14 @@ pub const Seat = extern struct { destroy: wl.Signal(*wlr.Seat), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + display_destroy: wl.Listener(void), + selection_source_destroy: wl.Listener(void), + primary_selection_source_destroy: wl.Listener(void), + drag_source_destroy: wl.Listener(void), + }, extern fn wlr_seat_create(server: *wl.Server, name: [*:0]const u8) ?*Seat; pub fn create(server: *wl.Server, name: [*:0]const u8) !*Seat { diff --git a/src/types/security_context_v1.zig b/src/types/security_context_v1.zig index e68d9ba..0d1d351 100644 --- a/src/types/security_context_v1.zig +++ b/src/types/security_context_v1.zig @@ -20,10 +20,11 @@ pub const SecurityContextManagerV1 = extern struct { data: ?*anyopaque, - // private state + private: extern struct { + contexts: wl.list.Link, - contexts: wl.list.Link, - server_destroy: wl.Listener(void), + server_destroy: wl.Listener(void), + }, extern fn wlr_security_context_manager_v1_create(server: *wl.Server) ?*SecurityContextManagerV1; pub fn create(server: *wl.Server) error{OutOfMemory}!*SecurityContextManagerV1 { diff --git a/src/types/session_lock_v1.zig b/src/types/session_lock_v1.zig index baa0688..65a61ed 100644 --- a/src/types/session_lock_v1.zig +++ b/src/types/session_lock_v1.zig @@ -12,11 +12,11 @@ pub const SessionLockManagerV1 = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, - // private state - - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_session_lock_manager_v1_create(server: *wl.Server) ?*SessionLockManagerV1; pub fn create(server: *wl.Server) !*SessionLockManagerV1 { @@ -35,11 +35,11 @@ pub const SessionLockV1 = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, - // private state - - locked_sent: bool, + private: extern struct { + locked_sent: bool, + }, extern fn wlr_session_lock_v1_send_locked(lock: *SessionLockV1) void; pub const sendLocked = wlr_session_lock_v1_send_locked; @@ -81,13 +81,12 @@ pub const SessionLockSurfaceV1 = extern struct { destroy: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, - // private state - - synced: wlr.Surface.Synced, - - output_destroy: wl.Listener(*wlr.Output), + private: extern struct { + synced: wlr.Surface.Synced, + output_destroy: wl.Listener(void), + }, extern fn wlr_session_lock_surface_v1_configure(lock_surface: *SessionLockSurfaceV1, width: u32, height: u32) u32; pub const configure = wlr_session_lock_surface_v1_configure; diff --git a/src/types/shm.zig b/src/types/shm.zig index 69a3c8e..3e45afb 100644 --- a/src/types/shm.zig +++ b/src/types/shm.zig @@ -6,12 +6,12 @@ const wl = wayland.server.wl; pub const Shm = extern struct { global: *wl.Global, - // private state + private: extern struct { + formats: ?[*]u32, + formats_len: usize, - formats: [*]u32, - formats_len: usize, - - server_destroy: wl.Listener(*wl.Server), + server_destroy: wl.Listener(void), + }, extern fn wlr_shm_create(server: *wl.Server, version: u32, formats: [*]const u32, formats_len: usize) ?*Shm; pub fn create(server: *wl.Server, version: u32, formats: []const u32) error{OutOfMemory}!*Shm { diff --git a/src/types/single_pixel_buffer_v1.zig b/src/types/single_pixel_buffer_v1.zig index 9d47e8a..600d1e1 100644 --- a/src/types/single_pixel_buffer_v1.zig +++ b/src/types/single_pixel_buffer_v1.zig @@ -3,9 +3,9 @@ const wl = @import("wayland").server.wl; pub const SinglePixelBufferManagerV1 = extern struct { global: *wl.Global, - // private state - - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_single_pixel_buffer_manager_v1_create(server: *wl.Server) ?*SinglePixelBufferManagerV1; pub fn create(server: *wl.Server) !*SinglePixelBufferManagerV1 { diff --git a/src/types/subcompositor.zig b/src/types/subcompositor.zig index 8fd1372..3d7cc7b 100644 --- a/src/types/subcompositor.zig +++ b/src/types/subcompositor.zig @@ -6,12 +6,14 @@ const wl = wayland.server.wl; pub const Subcompositor = extern struct { global: *wl.Global, - server_destroy: wl.Listener(*wl.Server), - events: extern struct { destroy: wl.Signal(*wlr.Compositor), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_subcompositor_create(server: *wl.Server) ?*Subcompositor; pub fn create(server: *wl.Server) !*Subcompositor { return wlr_subcompositor_create(server) orelse error.OutOfMemory; @@ -25,9 +27,9 @@ pub const Subsurface = extern struct { /// wlr.Surface.State.subsurfaces_above/subsurfaces_below link: wl.list.Link, - // private state - - synced: *wlr.Surface.Synced, + private: extern struct { + synced: *wlr.Surface.Synced, + }, }; resource: *wl.Subsurface, @@ -44,22 +46,17 @@ pub const Subsurface = extern struct { reordered: bool, added: bool, - surface_client_commit: wl.Listener(void), - parent_destroy: wl.Listener(*wlr.Surface), - events: extern struct { destroy: wl.Signal(*Subsurface), }, - data: usize, + data: ?*anyopaque, - // private state + private: extern struct { + parent_synced: wlr.Surface.Synced, - parent_synced: wlr.Surface.Synced, - - previous: extern struct { - x: i32, - y: i32, + surface_client_commit: wl.Listener(void), + parent_destroy: wl.Listener(void), }, extern fn wlr_subsurface_try_from_wlr_surface(surface: *wlr.Surface) ?*wlr.Subsurface; diff --git a/src/types/switch.zig b/src/types/switch.zig index b69b6d0..0f8b6d9 100644 --- a/src/types/switch.zig +++ b/src/types/switch.zig @@ -32,5 +32,5 @@ pub const Switch = extern struct { toggle: wl.Signal(*event.Toggle), }, - data: usize, + data: ?*anyopaque, }; diff --git a/src/types/tablet_tool.zig b/src/types/tablet_tool.zig index 16aff77..525c438 100644 --- a/src/types/tablet_tool.zig +++ b/src/types/tablet_tool.zig @@ -44,7 +44,7 @@ pub const TabletTool = extern struct { destroy: wl.Signal(*TabletTool), }, - data: usize, + data: ?*anyopaque, }; pub const Tablet = extern struct { @@ -132,5 +132,5 @@ pub const Tablet = extern struct { paths: wl.Array, - data: usize, + data: ?*anyopaque, }; diff --git a/src/types/tablet_v2.zig b/src/types/tablet_v2.zig index 11ab35a..6e90614 100644 --- a/src/types/tablet_v2.zig +++ b/src/types/tablet_v2.zig @@ -9,14 +9,16 @@ pub const TabletManagerV2 = extern struct { clients: wl.list.Link, // private to wlroots seats: wl.list.Link, // private to wlroots - server_destroy: wl.Listener(void), - events: extern struct { destroy: wl.Listener(void), }, data: ?*anyopaque, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_tablet_v2_create(server: *wl.Server) ?*TabletManagerV2; pub fn create(server: *wl.Server) !*TabletManagerV2 { return wlr_tablet_v2_create(server) orelse error.OutOfMemory; @@ -44,9 +46,11 @@ pub const TabletV2Tablet = extern struct { wlr_device: *wlr.InputDevice, clients: wl.list.Link, // private to wlroots - tablet_destroy: wl.Listener(void), - current_client: ?*opaque {}, + + private: extern struct { + tablet_destroy: wl.Listener(void), + }, }; pub const TabletV2TabletTool = extern struct { @@ -85,11 +89,8 @@ pub const TabletV2TabletTool = extern struct { wlr_tool: *wlr.TabletTool, clients: wl.list.Link, // private to wlroots - tool_destroy: wl.Listener(void), - current_client: ?*opaque {}, focused_surface: ?*wlr.Surface, - surface_destroy: wl.Listener(void), grab: *Grab, default_grab: Grab, @@ -105,6 +106,11 @@ pub const TabletV2TabletTool = extern struct { set_cursor: wl.Signal(*event.SetCursor), }, + private: extern struct { + surface_destroy: wl.Listener(void), + tool_destroy: wl.Listener(void), + }, + extern fn wlr_send_tablet_v2_tablet_tool_proximity_in(tool: *TabletV2TabletTool, tablet: *TabletV2Tablet, surface: *wlr.Surface) void; pub const sendProximityIn = wlr_send_tablet_v2_tablet_tool_proximity_in; @@ -223,8 +229,6 @@ pub const TabletV2TabletPad = extern struct { group_count: usize, groups: [*]u32, - pad_destroy: wl.Listener(void), - current_client: ?*opaque {}, grab: *Grab, @@ -236,6 +240,10 @@ pub const TabletV2TabletPad = extern struct { ring_feedback: wl.Signal(*event.Feedback), }, + private: extern struct { + pad_destroy: wl.Listener(void), + }, + extern fn wlr_send_tablet_v2_tablet_pad_enter(pad: *TabletV2TabletPad, tablet: *TabletV2Tablet, surface: *wlr.Surface) u32; pub const sendEnter = wlr_send_tablet_v2_tablet_pad_enter; diff --git a/src/types/tearing_control_v1.zig b/src/types/tearing_control_v1.zig index bc16fa3..f325e5f 100644 --- a/src/types/tearing_control_v1.zig +++ b/src/types/tearing_control_v1.zig @@ -18,14 +18,20 @@ pub const TearingControlV1 = extern struct { }, surface: *wlr.Surface, + + private: extern struct { + previous: wp.TearingControlV1.PresentationHint, + addon: wlr.Addon, + synced: wlr.Surface.Synced, + + surface_commit: wl.Listener(void), + }, }; pub const TearingControlManagerV1 = extern struct { global: *wl.Global, surface_hints: wl.list.Head(TearingControlV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_object: wl.Signal(*TearingControlV1), destroy: wl.Signal(void), @@ -33,6 +39,10 @@ pub const TearingControlManagerV1 = extern struct { data: ?*anyopaque, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_tearing_control_manager_v1_create(server: *wl.Server, version: u32) ?*TearingControlManagerV1; pub fn create(server: *wl.Server, version: u32) !*TearingControlManagerV1 { return wlr_tearing_control_manager_v1_create(server, version) orelse error.OutOfMemory; diff --git a/src/types/text_input_v3.zig b/src/types/text_input_v3.zig index bed2233..902efb6 100644 --- a/src/types/text_input_v3.zig +++ b/src/types/text_input_v3.zig @@ -7,13 +7,15 @@ pub const TextInputManagerV3 = extern struct { global: *wl.Global, text_inputs: wl.list.Head(TextInputV3, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { text_input: wl.Signal(*wlr.TextInputV3), destroy: wl.Signal(*wlr.TextInputManagerV3), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_text_input_manager_v3_create(server: *wl.Server) ?*wlr.TextInputManagerV3; pub fn create(server: *wl.Server) !*wlr.TextInputManagerV3 { return wlr_text_input_manager_v3_create(server) orelse error.OutOfMemory; @@ -59,9 +61,6 @@ pub const TextInputV3 = extern struct { link: wl.list.Link, - surface_destroy: wl.Listener(*wlr.Surface), - seat_destroy: wl.Listener(*wlr.Seat), - events: extern struct { enable: wl.Signal(*wlr.TextInputV3), commit: wl.Signal(*wlr.TextInputV3), @@ -69,6 +68,11 @@ pub const TextInputV3 = extern struct { destroy: wl.Signal(*wlr.TextInputV3), }, + private: extern struct { + surface_destroy: wl.Listener(void), + seat_destroy: wl.Listener(void), + }, + extern fn wlr_text_input_v3_send_enter(text_input: *wlr.TextInputV3, surface: *wlr.Surface) void; pub const sendEnter = wlr_text_input_v3_send_enter; diff --git a/src/types/touch.zig b/src/types/touch.zig index 802077c..b8d37d0 100644 --- a/src/types/touch.zig +++ b/src/types/touch.zig @@ -55,5 +55,5 @@ pub const Touch = extern struct { frame: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, }; diff --git a/src/types/transient_seat_v1.zig b/src/types/transient_seat_v1.zig index 92b6c57..a936832 100644 --- a/src/types/transient_seat_v1.zig +++ b/src/types/transient_seat_v1.zig @@ -5,11 +5,15 @@ const wl = wayland.server.wl; pub const TransientSeatManagerV1 = extern struct { global: *wl.Global, - server_destroy: wl.Listener(*wl.Server), + events: extern struct { create_seat: wl.Signal(*TransientSeatV1), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_transient_seat_manager_v1_create(server: *wl.Server) ?*TransientSeatManagerV1; pub fn create(server: *wl.Server) !*TransientSeatManagerV1 { return wlr_transient_seat_manager_v1_create(server) orelse error.OutOfMemory; @@ -20,6 +24,10 @@ pub const TransientSeatV1 = extern struct { resource: *wl.Resource, seat: *wlr.Seat, + private: extern struct { + seat_destroy: wl.Listener(void), + }, + extern fn wlr_transient_seat_v1_ready(seat: *TransientSeatV1, wlr_seat: *wlr.Seat) void; pub const ready = wlr_transient_seat_v1_ready; diff --git a/src/types/viewporter.zig b/src/types/viewporter.zig index dc5f031..8b8829c 100644 --- a/src/types/viewporter.zig +++ b/src/types/viewporter.zig @@ -10,7 +10,9 @@ pub const Viewporter = extern struct { destroy: wl.Signal(void), }, - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_viewporter_create(server: *wl.Server) ?*Viewporter; pub fn create(server: *wl.Server) !*Viewporter { diff --git a/src/types/virtual_keyboard_v1.zig b/src/types/virtual_keyboard_v1.zig index 13d519b..4036853 100644 --- a/src/types/virtual_keyboard_v1.zig +++ b/src/types/virtual_keyboard_v1.zig @@ -7,13 +7,15 @@ pub const VirtualKeyboardManagerV1 = extern struct { global: *wl.Global, virtual_keyboards: wl.list.Head(VirtualKeyboardV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_virtual_keyboard: wl.Signal(*VirtualKeyboardV1), destroy: wl.Signal(*VirtualKeyboardManagerV1), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_virtual_keyboard_manager_v1_create(server: *wl.Server) ?*VirtualKeyboardManagerV1; pub fn create(server: *wl.Server) !*VirtualKeyboardManagerV1 { return wlr_virtual_keyboard_manager_v1_create(server) orelse error.OutOfMemory; diff --git a/src/types/virtual_pointer_v1.zig b/src/types/virtual_pointer_v1.zig index 3863e59..6d486cd 100644 --- a/src/types/virtual_pointer_v1.zig +++ b/src/types/virtual_pointer_v1.zig @@ -15,13 +15,15 @@ pub const VirtualPointerManagerV1 = extern struct { global: *wl.Global, virtual_pointers: wl.list.Head(VirtualPointerV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_virtual_pointer: wl.Signal(*event.NewPointer), destroy: wl.Signal(*VirtualPointerManagerV1), }, + private: extern struct { + server_destroy: wl.Listener(void), + }, + extern fn wlr_virtual_pointer_manager_v1_create(server: *wl.Server) ?*VirtualPointerManagerV1; pub fn create(server: *wl.Server) !*VirtualPointerManagerV1 { return wlr_virtual_pointer_manager_v1_create(server) orelse error.OutOfMemory; diff --git a/src/types/xdg_activation_v1.zig b/src/types/xdg_activation_v1.zig index 3b49e85..3e26bb3 100644 --- a/src/types/xdg_activation_v1.zig +++ b/src/types/xdg_activation_v1.zig @@ -12,6 +12,8 @@ pub const XdgActivationV1 = extern struct { }; }; + global: *wl.Global, + /// token timeout in milliseconds (0 to disable) token_timeout_msec: u32, @@ -23,13 +25,10 @@ pub const XdgActivationV1 = extern struct { new_token: wl.Signal(*XdgActivationTokenV1), }, - // Private state - - server: *wl.Server, - - global: *wl.Global, - - server_destroy: wl.Listener(*wl.Server), + private: extern struct { + server: *wl.Server, + server_destroy: wl.Listener(void), + }, extern fn wlr_xdg_activation_v1_create(server: *wl.Server) ?*XdgActivationV1; pub fn create(server: *wl.Server) !*XdgActivationV1 { @@ -57,19 +56,20 @@ pub const XdgActivationTokenV1 = extern struct { link: wl.list.Link, - data: usize, + data: ?*anyopaque, events: extern struct { destroy: wl.Signal(void), }, - // Private state - token: [*:0]u8, - resource: ?*wl.Resource, - timeout: ?*wl.EventSource, + private: extern struct { + token: ?[*:0]u8, + resource: ?*wl.Resource, + timeout: ?*wl.EventSource, - seat_destroy: wl.Listener(*wlr.Seat), - surface_destroy: wl.Listener(*wlr.Surface), + seat_destroy: wl.Listener(void), + surface_destroy: wl.Listener(void), + }, extern fn wlr_xdg_activation_token_v1_destroy(token: *XdgActivationTokenV1) void; pub const destroy = wlr_xdg_activation_token_v1_destroy; diff --git a/src/types/xdg_decoration_v1.zig b/src/types/xdg_decoration_v1.zig index 3f2ff29..8008e99 100644 --- a/src/types/xdg_decoration_v1.zig +++ b/src/types/xdg_decoration_v1.zig @@ -8,14 +8,12 @@ pub const XdgDecorationManagerV1 = extern struct { global: *wl.Global, decorations: wl.list.Head(XdgToplevelDecorationV1, .link), - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_toplevel_decoration: wl.Signal(*XdgToplevelDecorationV1), destroy: wl.Signal(*XdgDecorationManagerV1), }, - data: usize, + data: ?*anyopaque, extern fn wlr_xdg_decoration_manager_v1_create(server: *wl.Server) ?*XdgDecorationManagerV1; pub fn create(server: *wl.Server) !*XdgDecorationManagerV1 { @@ -60,15 +58,7 @@ pub const XdgToplevelDecorationV1 = extern struct { request_mode: wl.Signal(*XdgToplevelDecorationV1), }, - data: usize, - - // private state - - toplevel_destroy: wl.Listener(void), - surface_configure: wl.Listener(*wlr.XdgSurface.Configure), - surface_ack_configure: wl.Listener(*wlr.XdgSurface.Configure), - - synced: wlr.Surface.Synced, + data: ?*anyopaque, extern fn wlr_xdg_toplevel_decoration_v1_set_mode(decoration: *XdgToplevelDecorationV1, mode: Mode) u32; pub const setMode = wlr_xdg_toplevel_decoration_v1_set_mode; diff --git a/src/types/xdg_output_v1.zig b/src/types/xdg_output_v1.zig index 65469a4..51caea1 100644 --- a/src/types/xdg_output_v1.zig +++ b/src/types/xdg_output_v1.zig @@ -13,10 +13,12 @@ pub const XdgOutputManagerV1 = extern struct { destroy: wl.Signal(*XdgOutputManagerV1), }, - server_destroy: wl.Listener(*wl.Server), - layout_add: wl.Listener(*wlr.OutputLayout), - layout_change: wl.Listener(*wlr.OutputLayout), - layout_destroy: wl.Listener(*wlr.OutputLayout), + private: extern struct { + server_destroy: wl.Listener(void), + layout_add: wl.Listener(void), + layout_change: wl.Listener(void), + layout_destroy: wl.Listener(void), + }, extern fn wlr_xdg_output_manager_v1_create(server: *wl.Server, layout: *wlr.OutputLayout) ?*XdgOutputManagerV1; pub fn create(server: *wl.Server, layout: *wlr.OutputLayout) !*XdgOutputManagerV1 { @@ -37,6 +39,8 @@ pub const XdgOutputV1 = extern struct { width: i32, height: i32, - destroy: wl.Listener(*wlr.OutputLayout.Output), - description: wl.Listener(*wlr.Output), + private: extern struct { + destroy: wl.Listener(void), + description: wl.Listener(void), + }, }; diff --git a/src/types/xdg_shell.zig b/src/types/xdg_shell.zig index 019f4e5..505fe9a 100644 --- a/src/types/xdg_shell.zig +++ b/src/types/xdg_shell.zig @@ -11,8 +11,6 @@ pub const XdgShell = extern struct { popup_grabs: wl.list.Head(XdgPopupGrab, .link), ping_timeout: u32, - server_destroy: wl.Listener(*wl.Server), - events: extern struct { new_surface: wl.Signal(*wlr.XdgSurface), new_toplevel: wl.Signal(*wlr.XdgToplevel), @@ -20,7 +18,11 @@ pub const XdgShell = extern struct { destroy: wl.Signal(*wlr.XdgShell), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, extern fn wlr_xdg_shell_create(server: *wl.Server, version: u32) ?*wlr.XdgShell; pub fn create(server: *wl.Server, version: u32) !*wlr.XdgShell { @@ -92,7 +94,9 @@ pub const XdgPopupGrab = extern struct { /// XdgShell.popup_grabs link: wl.list.Link, - seat_destroy: wl.Listener(*wlr.Seat), + private: extern struct { + seat_destroy: wl.Listener(void), + }, }; pub const XdgPopup = extern struct { @@ -129,9 +133,9 @@ pub const XdgPopup = extern struct { /// Grab.popups grab_link: wl.list.Link, - // private state - - synced: wlr.Surface.Synced, + private: extern struct { + synced: wlr.Surface.Synced, + }, extern fn wlr_xdg_popup_from_resource(resource: *xdg.Popup) ?*wlr.XdgPopup; pub const fromResource = wlr_xdg_popup_from_resource; @@ -202,7 +206,10 @@ pub const XdgToplevel = extern struct { fullscreen: bool, fullscreen_output: ?*wlr.Output, - fullscreen_output_destroy: wl.Listener(*wlr.Output), + + private: extern struct { + fullscreen_output_destroy: wl.Listener(void), + }, }; pub const event = struct { @@ -231,7 +238,6 @@ pub const XdgToplevel = extern struct { resource: *xdg.Toplevel, base: *wlr.XdgSurface, parent: ?*wlr.XdgToplevel, - parent_unmap: wl.Listener(*XdgSurface), current: State, pending: State, @@ -253,9 +259,17 @@ pub const XdgToplevel = extern struct { set_app_id: wl.Signal(void), }, + private: extern struct { + synced: wlr.Surface.Synced, + parent_unmap: wl.Listener(void), + }, + extern fn wlr_xdg_toplevel_from_resource(resource: *xdg.Toplevel) ?*wlr.XdgToplevel; pub const fromResource = wlr_xdg_toplevel_from_resource; + extern fn wlr_xdg_toplevel_configure(toplevel: *wlr.XdgToplevel, configure: *const Configure) u32; + pub const configure = wlr_xdg_toplevel_configure; + extern fn wlr_xdg_toplevel_set_size(toplevel: *wlr.XdgToplevel, width: i32, height: i32) u32; pub const setSize = wlr_xdg_toplevel_set_size; @@ -300,8 +314,14 @@ pub const XdgSurface = extern struct { }; pub const State = extern struct { - configure_serial: u32, + committed: packed struct(u32) { + geometry: bool = false, + _: u31 = 0, + }, + geometry: wlr.Box, + + configure_serial: u32, }; pub const Configure = extern struct { @@ -342,6 +362,8 @@ pub const XdgSurface = extern struct { initialized: bool, initial_commit: bool, + geometry: wlr.Box, + events: extern struct { destroy: wl.Signal(void), ping_timeout: wl.Signal(void), @@ -350,13 +372,12 @@ pub const XdgSurface = extern struct { ack_configure: wl.Signal(*wlr.XdgSurface.Configure), }, - data: usize, + data: ?*anyopaque, - // private state - - synced: wlr.Surface.Synced, - - role_resource_destroy: wl.Listener(*wl.Resource), + private: extern struct { + synced: wlr.Surface.Synced, + role_resource_destroy: wl.Listener(void), + }, extern fn wlr_xdg_surface_from_resource(resource: *xdg.Surface) ?*wlr.XdgSurface; pub const fromResource = wlr_xdg_surface_from_resource; @@ -373,9 +394,6 @@ pub const XdgSurface = extern struct { extern fn wlr_xdg_surface_try_from_wlr_surface(surface: *wlr.Surface) ?*wlr.XdgSurface; pub const tryFromWlrSurface = wlr_xdg_surface_try_from_wlr_surface; - extern fn wlr_xdg_surface_get_geometry(surface: *wlr.XdgSurface, box: *wlr.Box) void; - pub const getGeometry = wlr_xdg_surface_get_geometry; - extern fn wlr_xdg_surface_for_each_surface( surface: *wlr.XdgSurface, iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, diff --git a/src/util/addon.zig b/src/util/addon.zig index b6d9f44..961595b 100644 --- a/src/util/addon.zig +++ b/src/util/addon.zig @@ -2,8 +2,9 @@ const wayland = @import("wayland"); const wl = wayland.server.wl; pub const AddonSet = extern struct { - // private state - addons: wl.list.Head(Addon, .link), + private: extern struct { + addons: wl.list.Head(Addon, .link), + }, extern fn wlr_addon_set_init(set: *AddonSet) void; pub const init = wlr_addon_set_init; @@ -23,10 +24,10 @@ pub const Addon = extern struct { impl: *const Interface, - // private state - - owner: ?*const anyopaque, - link: wl.list.Link, + private: extern struct { + owner: ?*const anyopaque, + link: wl.list.Link, + }, extern fn wlr_addon_init(addon: *Addon, set: *AddonSet, owner: ?*const anyopaque, impl: *const Interface) void; pub const init = wlr_addon_init; diff --git a/src/util/box.zig b/src/util/box.zig index de9b762..64b0b1f 100644 --- a/src/util/box.zig +++ b/src/util/box.zig @@ -16,6 +16,9 @@ pub const Box = extern struct { extern fn wlr_box_contains_point(box: ?*const Box, x: f64, y: f64) bool; pub const containsPoint = wlr_box_contains_point; + extern fn wlr_box_contains_box(bigger: *const Box, smaller: *const Box) bool; + pub const containsBox = wlr_box_contains_box; + extern fn wlr_box_empty(box: ?*const Box) bool; pub const empty = wlr_box_empty; diff --git a/src/wlroots.zig b/src/wlroots.zig index 8d827d0..9def378 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -26,6 +26,8 @@ pub const DrmLeaseConnectorV1 = @import("types/drm_lease_v1.zig").DrmLeaseConnec pub const DrmLeaseRequestV1 = @import("types/drm_lease_v1.zig").DrmLeaseRequestV1; pub const DrmLeaseV1 = @import("types/drm_lease_v1.zig").DrmLeaseV1; +pub const DrmSyncobjTimeline = opaque {}; // TODO + pub const FractionalScaleManagerV1 = @import("types/fractional_scale_v1.zig").FractionalScaleManagerV1; pub const ShmAttributes = @import("types/buffer.zig").ShmAttributes; @@ -185,8 +187,6 @@ pub usingnamespace if (config.has_xwayland) struct { pub const XwaylandSurfaceV1 = @import("xwayland/shell.zig").XwaylandSurfaceV1; } else struct {}; -pub const matrix = @import("types/matrix.zig"); - pub const AddonSet = @import("util/addon.zig").AddonSet; pub const Addon = @import("util/addon.zig").Addon; pub const Box = @import("util/box.zig").Box; @@ -222,8 +222,8 @@ pub const config = @import("config.zig"); pub const version = @import("version.zig"); comptime { - if (version.major != 0 or version.minor != 18) { - @compileError("zig-wlroots requires wlroots version 0.18, found version " ++ version.str); + if (version.major != 0 or version.minor != 19) { + @compileError("zig-wlroots requires wlroots version 0.19, found version " ++ version.str); } } test { diff --git a/src/xwayland/server.zig b/src/xwayland/server.zig index 3d8f90d..a8f37eb 100644 --- a/src/xwayland/server.zig +++ b/src/xwayland/server.zig @@ -43,10 +43,12 @@ pub const XwaylandServer = extern struct { destroy: wl.Signal(void), }, - client_destroy: wl.Listener(*wl.Client), - display_destroy: wl.Listener(*wl.Server), + data: ?*anyopaque, - data: usize, + private: extern struct { + client_destroy: wl.Listener(void), + server_destroy: wl.Listener(void), + }, extern fn wlr_xwayland_server_create(server: *wl.Server, options: *Options) ?*XwaylandServer; pub fn create(server: *wl.Server, options: *Options) !*XwaylandServer { diff --git a/src/xwayland/shell.zig b/src/xwayland/shell.zig index 3da1f08..66f96cc 100644 --- a/src/xwayland/shell.zig +++ b/src/xwayland/shell.zig @@ -14,13 +14,13 @@ pub const XwaylandShellV1 = extern struct { new_surface: wl.Signal(*XwaylandSurfaceV1), }, - // private state + private: extern struct { + client: *wl.Client, + surfaces: wl.list.Link, - client: ?*wl.Client, - surfaces: wl.list.Head(XwaylandSurfaceV1, .link), - - display_destroy: wl.Listener(void), - client_destroy: wl.Listener(void), + server_destroy: wl.Listener(void), + client_destroy: wl.Listener(void), + }, extern fn wlr_xwayland_shell_v1_create(server: *wl.Server, version: u32) ?*XwaylandShellV1; pub fn create(server: *wl.Server, version: u32) !*XwaylandShellV1 { @@ -41,11 +41,10 @@ pub const XwaylandSurfaceV1 = extern struct { surface: *wlr.Surface, serial: u64, - // private state - - resource: *wl.Resource, - /// XwaylandShellV1.surfaces - link: wl.list.Link, - shell: *XwaylandShellV1, - added: bool, + private: extern struct { + resource: *wl.Resource, + link: wl.list.Link, + shell: *wlr.XwaylandShellV1, + added: bool, + }, }; diff --git a/src/xwayland/xwayland.zig b/src/xwayland/xwayland.zig index 9ca990d..eb7d12f 100644 --- a/src/xwayland/xwayland.zig +++ b/src/xwayland/xwayland.zig @@ -110,22 +110,23 @@ pub const Xwayland = extern struct { seat: ?*wlr.Seat, events: extern struct { + destroy: wl.Signal(void), ready: wl.Signal(void), new_surface: wl.Signal(*XwaylandSurface), remove_startup_info: wl.Signal(*event.RemoveStartupInfo), }, - user_event_handler: ?*const fn (*Xwm, *xcb.GenericEvent) callconv(.C) c_int, + user_event_handler: ?*const fn (*Xwayland, *xcb.GenericEvent) callconv(.C) bool, - data: usize, + data: ?*anyopaque, - // private state - - server_start: wl.Listener(void), - server_ready: wl.Listener(*wlr.XwaylandServer.event.Ready), - server_destroy: wl.Listener(void), - seat_destroy: wl.Listener(*wlr.Seat), - shell_destroy: wl.Listener(void), + private: extern struct { + server_start: wl.Listener(void), + server_ready: wl.Listener(void), + server_destroy: wl.Listener(void), + seat_destroy: wl.Listener(void), + shell_destroy: wl.Listener(void), + }, extern fn wlr_xwayland_create(server: *wl.Server, compositor: *wlr.Compositor, lazy: bool) ?*Xwayland; pub fn create(server: *wl.Server, compositor: *wlr.Compositor, lazy: bool) !*Xwayland { @@ -194,15 +195,13 @@ pub const XwaylandSurface = extern struct { surface: ?*wlr.Surface, surface_addon: wlr.Addon, - surface_commit: wl.Listener(*wlr.Surface), - surface_map: wl.Listener(void), - surface_unmap: wl.Listener(void), x: i16, y: i16, width: u16, height: u16, override_redirect: bool, + opacity: f32, title: ?[*:0]u8, class: ?[*:0]u8, @@ -237,6 +236,13 @@ pub const XwaylandSurface = extern struct { maximized_horz: bool, minimized: bool, withdrawn: bool, + sticky: bool, + shaded: bool, + skip_taskbar: bool, + skip_pager: bool, + above: bool, + below: bool, + demands_attention: bool, has_alpha: bool, @@ -249,6 +255,14 @@ pub const XwaylandSurface = extern struct { request_maximize: wl.Signal(void), request_fullscreen: wl.Signal(void), request_activate: wl.Signal(void), + request_close: wl.Signal(void), + request_sticky: wl.Signal(void), + request_shaded: wl.Signal(void), + request_skip_taskbar: wl.Signal(void), + request_skip_pager: wl.Signal(void), + request_above: wl.Signal(void), + request_below: wl.Signal(void), + request_demands_attention: wl.Signal(void), associate: wl.Signal(void), dissociate: wl.Signal(void), @@ -264,13 +278,22 @@ pub const XwaylandSurface = extern struct { set_strut_partial: wl.Signal(void), set_override_redirect: wl.Signal(void), set_geometry: wl.Signal(void), + set_opacity: wl.Signal(void), + focus_in: wl.Signal(void), + grab_focus: wl.Signal(void), map_request: wl.Signal(void), ping_timeout: wl.Signal(void), }, - data: usize, + data: ?*anyopaque, + + private: extern struct { + surface_commit: wl.Listener(void), + surface_map: wl.Listener(void), + surface_unmap: wl.Listener(void), + }, extern fn wlr_xwayland_surface_activate(surface: *XwaylandSurface, activated: bool) void; pub const activate = wlr_xwayland_surface_activate; @@ -290,7 +313,7 @@ pub const XwaylandSurface = extern struct { extern fn wlr_xwayland_surface_set_minimized(surface: *XwaylandSurface, minimized: bool) void; pub const setMinimized = wlr_xwayland_surface_set_minimized; - extern fn wlr_xwayland_surface_set_maximized(surface: *XwaylandSurface, maximized: bool) void; + extern fn wlr_xwayland_surface_set_maximized(surface: *XwaylandSurface, maximized_horz: bool, maximized_vert: bool) void; pub const setMaximized = wlr_xwayland_surface_set_maximized; extern fn wlr_xwayland_surface_set_fullscreen(surface: *XwaylandSurface, fullscreen: bool) void; @@ -302,9 +325,9 @@ pub const XwaylandSurface = extern struct { extern fn wlr_xwayland_surface_ping(surface: *XwaylandSurface) void; pub const ping = wlr_xwayland_surface_ping; - extern fn wlr_xwayland_or_surface_wants_focus(surface: *const XwaylandSurface) bool; - pub const overrideRedirectWantsFocus = wlr_xwayland_or_surface_wants_focus; + extern fn wlr_xwayland_surface_override_redirect_wants_focus(surface: *const XwaylandSurface) bool; + pub const overrideRedirectWantsFocus = wlr_xwayland_surface_override_redirect_wants_focus; - extern fn wlr_xwayland_icccm_input_model(surface: *const XwaylandSurface) IcccmInputModel; - pub const icccmInputModel = wlr_xwayland_icccm_input_model; + extern fn wlr_xwayland_surface_icccm_input_model(surface: *const XwaylandSurface) IcccmInputModel; + pub const icccmInputModel = wlr_xwayland_surface_icccm_input_model; }; diff --git a/tinywl/build.zig b/tinywl/build.zig index 57eaff9..7d26495 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -37,7 +37,7 @@ pub fn build(b: *std.Build) void { // exposed to the wlroots module for @cImport() to work. This seems to be // the best way to do so with the current std.Build API. wlroots.resolved_target = target; - wlroots.linkSystemLibrary("wlroots-0.18", .{}); + wlroots.linkSystemLibrary("wlroots-0.19", .{}); const tinywl = b.addExecutable(.{ .name = "tinywl", diff --git a/tinywl/tinywl.zig b/tinywl/tinywl.zig index b9180f6..a219c65 100644 --- a/tinywl/tinywl.zig +++ b/tinywl/tinywl.zig @@ -120,6 +120,20 @@ const Server = struct { fn deinit(server: *Server) void { server.wl_server.destroyClients(); + + server.new_input.link.remove(); + server.new_output.link.remove(); + + server.new_xdg_toplevel.link.remove(); + server.new_xdg_popup.link.remove(); + server.request_set_cursor.link.remove(); + server.request_set_selection.link.remove(); + server.cursor_motion.link.remove(); + server.cursor_motion_absolute.link.remove(); + server.cursor_button.link.remove(); + server.cursor_axis.link.remove(); + server.cursor_frame.link.remove(); + server.backend.destroy(); server.wl_server.destroy(); } @@ -164,8 +178,8 @@ const Server = struct { return; }, }; - toplevel.scene_tree.node.data = @intFromPtr(toplevel); - xdg_surface.data = @intFromPtr(toplevel.scene_tree); + toplevel.scene_tree.node.data = toplevel; + xdg_surface.data = toplevel.scene_tree; xdg_surface.surface.events.commit.add(&toplevel.commit); xdg_surface.surface.events.map.add(&toplevel.map); @@ -181,7 +195,7 @@ const Server = struct { // These asserts are fine since tinywl.zig doesn't support anything else that can // make xdg popups (e.g. layer shell). const parent = wlr.XdgSurface.tryFromWlrSurface(xdg_popup.parent.?) orelse return; - const parent_tree = @as(?*wlr.SceneTree, @ptrFromInt(parent.data)) orelse { + const parent_tree = @as(?*wlr.SceneTree, @alignCast(@ptrCast(parent.data))) orelse { // The xdg surface user data could be left null due to allocation failure. return; }; @@ -189,7 +203,7 @@ const Server = struct { std.log.err("failed to allocate xdg popup node", .{}); return; }; - xdg_surface.data = @intFromPtr(scene_tree); + xdg_surface.data = scene_tree; const popup = gpa.create(Popup) catch { std.log.err("failed to allocate new popup", .{}); @@ -220,7 +234,7 @@ const Server = struct { var it: ?*wlr.SceneTree = node.parent; while (it) |n| : (it = n.node.parent) { - if (@as(?*Toplevel, @ptrFromInt(n.node.data))) |toplevel| { + if (@as(?*Toplevel, @alignCast(@ptrCast(n.node.data)))) |toplevel| { return ViewAtResult{ .toplevel = toplevel, .surface = scene_surface.surface, @@ -352,10 +366,8 @@ const Server = struct { new_right = new_left + 1; } - var geo_box: wlr.Box = undefined; - toplevel.xdg_toplevel.base.getGeometry(&geo_box); - toplevel.x = new_left - geo_box.x; - toplevel.y = new_top - geo_box.y; + toplevel.x = new_left - toplevel.xdg_toplevel.base.geometry.x; + toplevel.y = new_top - toplevel.xdg_toplevel.base.geometry.y; toplevel.scene_tree.node.setPosition(toplevel.x, toplevel.y); const new_width = new_right - new_left; @@ -465,6 +477,7 @@ const Output = struct { const output: *Output = @fieldParentPtr("destroy", listener); output.frame.link.remove(); + output.request_state.link.remove(); output.destroy.link.remove(); gpa.destroy(output); @@ -541,8 +554,7 @@ const Toplevel = struct { server.cursor_mode = .resize; server.resize_edges = event.edges; - var box: wlr.Box = undefined; - toplevel.xdg_toplevel.base.getGeometry(&box); + const box = toplevel.xdg_toplevel.base.geometry; const border_x = toplevel.x + box.x + if (event.edges.right) box.width else 0; const border_y = toplevel.y + box.y + if (event.edges.bottom) box.height else 0; @@ -585,7 +597,7 @@ const Keyboard = struct { modifiers: wl.Listener(*wlr.Keyboard) = .init(handleModifiers), key: wl.Listener(*wlr.Keyboard.event.Key) = .init(handleKey), - destroy: wl.Listener(void) = .init(handleDestroy), + destroy: wl.Listener(*wlr.InputDevice) = .init(handleDestroy), fn create(server: *Server, device: *wlr.InputDevice) !void { const keyboard = try gpa.create(Keyboard); @@ -607,6 +619,7 @@ const Keyboard = struct { wlr_keyboard.events.modifiers.add(&keyboard.modifiers); wlr_keyboard.events.key.add(&keyboard.key); + device.events.destroy.add(&keyboard.destroy); server.seat.setKeyboard(wlr_keyboard); server.keyboards.append(keyboard); @@ -641,11 +654,15 @@ const Keyboard = struct { } } - fn handleDestroy(listener: *wl.Listener(void)) void { + fn handleDestroy(listener: *wl.Listener(*wlr.InputDevice), _: *wlr.InputDevice) void { const keyboard: *Keyboard = @fieldParentPtr("destroy", listener); keyboard.link.remove(); + keyboard.modifiers.link.remove(); + keyboard.key.link.remove(); + keyboard.destroy.link.remove(); + gpa.destroy(keyboard); } }; From ac61c23adf23d55172eede102f3091e6636f6593 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 27 Apr 2025 12:57:53 +0200 Subject: [PATCH 02/54] linux-drm-syncobj: add basic bindings This is all that's needed for wlr_scene compositors --- src/types/linux_drm_syncobj_v1.zig | 16 ++++++++++++++++ src/wlroots.zig | 2 ++ 2 files changed, 18 insertions(+) create mode 100644 src/types/linux_drm_syncobj_v1.zig diff --git a/src/types/linux_drm_syncobj_v1.zig b/src/types/linux_drm_syncobj_v1.zig new file mode 100644 index 0000000..03f5242 --- /dev/null +++ b/src/types/linux_drm_syncobj_v1.zig @@ -0,0 +1,16 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +pub const LinuxDrmSyncobjManagerV1 = extern struct { + global: *wl.Global, + + private: extern struct { + drm_fd: c_int, + server_destroy: wl.Listener(void), + }, + + extern fn wlr_linux_drm_syncobj_manager_v1_create(server: *wl.Server, version: u32, drm_fd: c_int) ?*LinuxDrmSyncobjManagerV1; + pub const create = wlr_linux_drm_syncobj_manager_v1_create; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 9def378..8cc7f60 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -43,6 +43,8 @@ pub const DmabufBufferV1 = @import("types/linux_dmabuf_v1.zig").DmabufBufferV1; pub const LinuxDmabufV1 = @import("types/linux_dmabuf_v1.zig").LinuxDmabufV1; pub const LinuxDmabufFeedbackV1 = @import("types/linux_dmabuf_v1.zig").LinuxDmabufFeedbackV1; +pub const LinuxDrmSyncobjManagerV1 = @import("types/linux_drm_syncobj_v1.zig").LinuxDrmSyncobjManagerV1; + pub const Compositor = @import("types/compositor.zig").Compositor; pub const Surface = @import("types/compositor.zig").Surface; pub const Subcompositor = @import("types/subcompositor.zig").Subcompositor; From adef9176d0e3425f0ea2416751397d8d64533a6c Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 11:35:24 +0200 Subject: [PATCH 03/54] build: update to wlroots 0.19.0 --- src/xwayland/xwayland.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/xwayland/xwayland.zig b/src/xwayland/xwayland.zig index eb7d12f..00a33d5 100644 --- a/src/xwayland/xwayland.zig +++ b/src/xwayland/xwayland.zig @@ -290,6 +290,9 @@ pub const XwaylandSurface = extern struct { data: ?*anyopaque, private: extern struct { + wm_name: ?[*:0]u8, + net_wm_name: ?[*:0]u8, + surface_commit: wl.Listener(void), surface_map: wl.Listener(void), surface_unmap: wl.Listener(void), From b97bf9e76c2699ae9c03fa616c82d83d6c8a5de2 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 11:36:07 +0200 Subject: [PATCH 04/54] build: bump version to 0.19.0 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 6189868..76b08ec 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.0-dev", + .version = "0.19.0", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 6a9e3ba9e422df3fa4226f8c32b3d3c17100ebb1 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 12:14:18 +0200 Subject: [PATCH 05/54] build: bump version to 0.19.1-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 76b08ec..95e767b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.0", + .version = "0.19.1-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 5eb7dc228b486e0bf37be06241ada49066457a65 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 11:48:01 +0200 Subject: [PATCH 06/54] Presentation: fix typo --- src/types/presentation_time.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/presentation_time.zig b/src/types/presentation_time.zig index 626c223..58a6056 100644 --- a/src/types/presentation_time.zig +++ b/src/types/presentation_time.zig @@ -17,7 +17,7 @@ pub const Presentation = extern struct { }, extern fn wlr_presentation_create(server: *wl.Server, backend: *wlr.Backend, version: u32) ?*wlr.Presentation; - pub fn create(server: *wl.Server, backend: *wlr.Backend, version: c_int) !*wlr.Presentation { + pub fn create(server: *wl.Server, backend: *wlr.Backend, version: u32) !*wlr.Presentation { return wlr_presentation_create(server, backend, version) orelse error.OutOfMemory; } From c26b1ca236d03f7d3c3553ed0a18fe0c171e91b9 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 11:40:17 +0200 Subject: [PATCH 07/54] ci: fix wlroots version --- .builds/alpine.yml | 10 ++-------- .builds/archlinux.yml | 9 +-------- .builds/freebsd.yml | 11 +++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 6f3a771..b9b2d1e 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -14,6 +14,7 @@ packages: - xcb-util-wm-dev - pixman-dev - libevdev-dev + - wayland-dev - wayland-protocols - xwayland-dev - meson @@ -23,18 +24,11 @@ packages: - xz sources: - https://codeberg.org/ifreund/zig-wlroots - - https://gitlab.freedesktop.org/wayland/wayland.git - https://gitlab.freedesktop.org/wlroots/wlroots.git tasks: - install_deps: | - cd wayland - git checkout 1.23.0 - meson setup build -Ddocumentation=false -Dtests=false --prefix /usr - sudo ninja -C build install - cd .. - cd wlroots - git checkout 0.18.0 + git checkout 0.19.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ -Dcolor-management=disabled -Dlibliftoff=disabled \ -Dexamples=false -Dwerror=false -Db_ndebug=false \ diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index c178da7..49592c7 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -21,18 +21,11 @@ packages: - xz sources: - https://codeberg.org/ifreund/zig-wlroots - - https://gitlab.freedesktop.org/wayland/wayland.git - https://gitlab.freedesktop.org/wlroots/wlroots.git tasks: - install_deps: | - cd wayland - git checkout 1.23.0 - meson setup build -Ddocumentation=false -Dtests=false --prefix /usr - sudo ninja -C build install - cd .. - cd wlroots - git checkout 0.18.0 + git checkout 0.19.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ -Dcolor-management=disabled -Dlibliftoff=disabled \ -Dexamples=false -Dwerror=false -Db_ndebug=false \ diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index be38eaf..bf09267 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -7,6 +7,7 @@ packages: - devel/meson - devel/pkgconf - graphics/mesa-libs + - graphics/wayland - graphics/wayland-protocols - misc/hwdata - x11/libX11 @@ -26,19 +27,13 @@ packages: - wget sources: - https://codeberg.org/ifreund/zig-wlroots - - https://gitlab.freedesktop.org/wayland/wayland.git - https://gitlab.freedesktop.org/wlroots/wlroots.git tasks: - install_deps: | - cd wayland - git checkout 1.23.0 - meson setup build -Ddocumentation=false -Dtests=false --prefix /usr - sudo ninja -C build install - cd .. - cd wlroots - git checkout 0.18.0 + git checkout 0.19.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ + -Dallocators=gbm \ -Dcolor-management=disabled -Dlibliftoff=disabled \ -Dexamples=false -Dwerror=false -Db_ndebug=false \ -Dxcb-errors=disabled --prefix /usr From 6ba5821230d69204305a450abf1c0f8979f879f1 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 18 Jun 2025 12:14:57 +0200 Subject: [PATCH 08/54] build: bump version to 0.19.1 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 95e767b..1e57388 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.1-dev", + .version = "0.19.1", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From bb222027d3ab96cca4d217c5b3bab616edc14632 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Thu, 26 Jun 2025 19:43:36 +0200 Subject: [PATCH 09/54] ext-foreign-toplevel-list-v1: add bindings --- src/types/foreign_toplevel_list_v1.zig | 78 ++++++++++++++++++++++++++ src/wlroots.zig | 3 + 2 files changed, 81 insertions(+) create mode 100644 src/types/foreign_toplevel_list_v1.zig diff --git a/src/types/foreign_toplevel_list_v1.zig b/src/types/foreign_toplevel_list_v1.zig new file mode 100644 index 0000000..1852eb1 --- /dev/null +++ b/src/types/foreign_toplevel_list_v1.zig @@ -0,0 +1,78 @@ +const wl = @import("wayland").server.wl; + +pub const ExtForeignToplevelListV1 = extern struct { + global: *wl.Global, + resources: wl.list.Head(wl.Resource, null), + toplevels: wl.list.Head(ExtForeignToplevelHandleV1, .link), + + events: extern struct { + destroy: wl.Signal(void), + }, + + data: ?*anyopaque, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_foreign_toplevel_list_v1_create( + display: *wl.Server, + version: u32, + ) ?*ExtForeignToplevelListV1; + pub fn create( + display: *wl.Server, + version: u32, + ) !*ExtForeignToplevelListV1 { + return wlr_ext_foreign_toplevel_list_v1_create(display, version) orelse error.OutOfMemory; + } +}; + +pub const ExtForeignToplevelHandleV1 = extern struct { + list: *ExtForeignToplevelListV1, + resources: wl.list.Head(wl.Resource, null), + link: wl.list.Link, + + title: ?[*:0]const u8, + app_id: ?[*:0]const u8, + identifier: [*:0]const u8, + + events: extern struct { + destroy: wl.Signal(void), + }, + + data: ?*anyopaque, + + pub const State = extern struct { + title: ?[*:0]const u8, + app_id: ?[*:0]const u8, + }; + + extern fn wlr_ext_foreign_toplevel_handle_v1_create( + list: *ExtForeignToplevelListV1, + state: *const State, + ) ?*ExtForeignToplevelHandleV1; + pub fn create( + list: *ExtForeignToplevelListV1, + state: *const State, + ) !*ExtForeignToplevelHandleV1 { + return wlr_ext_foreign_toplevel_handle_v1_create(list, state) orelse error.ToplevelHandleCreateFailed; + } + + extern fn wlr_ext_foreign_toplevel_handle_v1_from_resource( + resource: *wl.Resource, + ) ?*ExtForeignToplevelHandleV1; + pub fn fromResource(resource: *wl.Resource) ?*ExtForeignToplevelHandleV1 { + return wlr_ext_foreign_toplevel_handle_v1_from_resource(resource); + } + + extern fn wlr_ext_foreign_toplevel_handle_v1_destroy( + toplevel: *ExtForeignToplevelHandleV1, + ) void; + pub const destroy = wlr_ext_foreign_toplevel_handle_v1_destroy; + + extern fn wlr_ext_foreign_toplevel_handle_v1_update_state( + toplevel: *ExtForeignToplevelHandleV1, + state: *const State, + ) void; + pub const updateState = wlr_ext_foreign_toplevel_handle_v1_update_state; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 8cc7f60..31635ec 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -204,6 +204,9 @@ pub const OutputConfigurationV1 = @import("types/output_management_v1.zig").Outp pub const ForeignToplevelManagerV1 = @import("types/foreign_toplevel_management_v1.zig").ForeignToplevelManagerV1; pub const ForeignToplevelHandleV1 = @import("types/foreign_toplevel_management_v1.zig").ForeignToplevelHandleV1; +pub const ExtForeignToplevelListV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelListV1; +pub const ExtForeignToplevelHandleV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelHandleV1; + pub const SecurityContextManagerV1 = @import("types/security_context_v1.zig").SecurityContextManagerV1; pub const SecurityContextV1State = @import("types/security_context_v1.zig").SecurityContextV1State; From 0ff50ee34621a12f83fe3f0704f30796169eb8c7 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 1 Jul 2025 09:31:36 +0200 Subject: [PATCH 10/54] build: bump version to 0.19.2 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 1e57388..8582e00 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.1", + .version = "0.19.2", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 201a020034e46b16039ecedf244636a87e1dcade Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 1 Jul 2025 09:33:25 +0200 Subject: [PATCH 11/54] build: bump version to 0.19.3-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 8582e00..b12a049 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.2", + .version = "0.19.3-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From bc2bddd99fd56fb371404e6cfb418734d8ff7c57 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Thu, 3 Jul 2025 01:13:00 +0200 Subject: [PATCH 12/54] ext-image-*: add bindings * ext-image-copy-capture-v1 * ext-image-capture-source-v1 (excluding toplevel capture) --- src/types/image_capture_source_v1.zig | 160 ++++++++++++++++++++++++++ src/types/image_copy_capture_v1.zig | 92 +++++++++++++++ src/wlroots.zig | 3 + 3 files changed, 255 insertions(+) create mode 100644 src/types/image_capture_source_v1.zig create mode 100644 src/types/image_copy_capture_v1.zig diff --git a/src/types/image_capture_source_v1.zig b/src/types/image_capture_source_v1.zig new file mode 100644 index 0000000..acb21ef --- /dev/null +++ b/src/types/image_capture_source_v1.zig @@ -0,0 +1,160 @@ +const wlr = @import("../wlroots.zig"); + +const posix = @import("std").posix; + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +const pixman = @import("pixman"); + +pub const ImageCaptureSourceV1 = extern struct { + impl: *const ImageCaptureSourceV1Interface, + resources: wl.list.Head(wl.Resource, null), + + width: u32, + height: u32, + + shm_formats: *u32, + shm_formats_len: isize, + + dmabuf_device: posix.dev_t, + dmabuf_formats: wlr.DrmFormatSet, + + events: extern struct { + constraints_update: wl.Signal(void), + frame: wl.Signal(void), + destroy: wl.Signal(void), + }, + + extern fn wlr_ext_image_capture_source_v1_init( + source: *ImageCaptureSourceV1, + impl: *const ImageCaptureSourceV1Interface, + ) void; + pub fn init( + source: *ImageCaptureSourceV1, + impl: *const ImageCaptureSourceV1Interface, + ) void { + return wlr_ext_image_capture_source_v1_init(source, impl); + } + + extern fn wlr_ext_image_capture_source_v1_finish(source: *ImageCaptureSourceV1) void; + pub fn finish(source: *ImageCaptureSourceV1) void { + return wlr_ext_image_capture_source_v1_finish(source); + } + + extern fn wlr_ext_image_capture_source_v1_create_resource( + source: *ImageCaptureSourceV1, + client: *wl.Client, + new_id: u32, + ) bool; + pub fn createResource( + source: *ImageCaptureSourceV1, + client: *wl.Client, + new_id: u32, + ) bool { + return wlr_ext_image_capture_source_v1_create_resource(source, client, new_id); + } + + extern fn wlr_ext_image_capture_source_v1_set_constraints_from_swapchain( + source: *ImageCaptureSourceV1, + swapchain: *wlr.Swapchain, + renderer: *wlr.Renderer, + ) bool; + pub fn setContraintsFromSwapchain( + source: *ImageCaptureSourceV1, + swapchain: *wlr.Swapchain, + renderer: *wlr.Renderer, + ) bool { + return wlr_ext_image_capture_source_v1_set_constraints_from_swapchain( + source, + swapchain, + renderer, + ); + } + + extern fn wlr_ext_image_capture_source_v1_from_resource( + resource: *wl.Resource, + ) ?*ImageCaptureSourceV1; + pub fn fromResource(resource: *wl.Resource) !*ImageCaptureSourceV1 { + return wlr_ext_image_capture_source_v1_from_resource(resource) orelse error.OutOfMemory; + } +}; + +pub const ImageCaptureSourceV1Interface = extern struct { + start: *const fn ( + source: *ImageCaptureSourceV1, + with_cursors: bool, + ) callconv(.C) void, + + stop: *const fn (source: *ImageCaptureSourceV1) callconv(.C) void, + + schedule_frame: *const fn (source: *ImageCaptureSourceV1) callconv(.C) void, + + copy_frame: *const fn ( + source: *ImageCaptureSourceV1, + dst_frame: *wlr.ImageCopyCaptureFrameV1, + frame_event: *ImageCaptureSourceV1FrameEvent, + ) callconv(.C) void, + + get_pointer_cursor: *const fn ( + source: *ImageCaptureSourceV1, + seat: *wlr.Seat, + ) callconv(.C) *ImageCaptureSourceV1Cursor, +}; + +pub const ImageCaptureSourceV1FrameEvent = extern struct { + damage: *const pixman.Region32, +}; + +pub const ImageCaptureSourceV1Cursor = extern struct { + base: ImageCaptureSourceV1, + + entered: bool, + x: i32, + y: i32, + hotspot: extern struct { + x: i32, + y: i32, + }, + + events: extern struct { + update: wl.Signal(void), + }, + + extern fn wlr_ext_image_capture_source_v1_cursor_init( + source_cursor: *ImageCaptureSourceV1Cursor, + impl: *const ImageCaptureSourceV1Interface, + ) void; + pub fn cursorInit( + source_cursor: *ImageCaptureSourceV1Cursor, + impl: *const ImageCaptureSourceV1Interface, + ) void { + return wlr_ext_image_capture_source_v1_cursor_init(source_cursor, impl); + } + + extern fn wlr_ext_image_capture_source_v1_cursor_finish( + source_cursor: *ImageCaptureSourceV1Cursor, + ) void; + pub fn finish(source_cursor: *ImageCaptureSourceV1Cursor) void { + return wlr_ext_image_capture_source_v1_cursor_finish(source_cursor); + } +}; + +pub const OutputImageCaptureSourceManagerV1 = extern struct { + global: *wl.Global, + + private: extern struct { + display_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_output_image_capture_source_manager_v1_create( + display: *wl.Server, + version: u32, + ) ?*OutputImageCaptureSourceManagerV1; + pub fn create( + display: *wl.Server, + version: u32, + ) !*OutputImageCaptureSourceManagerV1 { + return wlr_ext_output_image_capture_source_manager_v1_create(display, version) orelse error.OutOfMemory; + } +}; diff --git a/src/types/image_copy_capture_v1.zig b/src/types/image_copy_capture_v1.zig new file mode 100644 index 0000000..e2e2eee --- /dev/null +++ b/src/types/image_copy_capture_v1.zig @@ -0,0 +1,92 @@ +const wlr = @import("../wlroots.zig"); + +const posix = @import("std").posix; + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const FailureReason = wl.ext.ImageCopyCaptureFrameV1.FailureReason; + +const pixman = @import("pixman"); + +const ImageCopyCaptureSessionV1 = extern struct { + resource: *wl.Resource, + source: *wlr.ImageCaptureSourceV1, + frame: *ImageCopyCaptureFrameV1, + + source_destroy: wl.listener(void), + source_constraints_update: wl.listener(void), + source_frame: wl.listener(void), + + damage: pixman.Region32, +}; + +pub const ImageCopyCaptureManagerV1 = extern struct { + global: *wl.Global, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_image_copy_capture_manager_v1_create( + display: *wl.Server, + version: u32, + ) ?*ImageCopyCaptureManagerV1; + pub fn create( + display: *wl.Server, + version: u32, + ) !*ImageCopyCaptureManagerV1 { + return wlr_ext_image_copy_capture_manager_v1_create(display, version) orelse error.OutOfMemory; + } +}; + +pub const ImageCopyCaptureFrameV1 = extern struct { + resource: *wl.Resource, + capturing: bool, + buffer: *wlr.buffer, + buffer_damage: pixman.Region32, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + session: *ImageCopyCaptureSessionV1, + }, + + extern fn wlr_ext_image_copy_capture_frame_v1_ready( + frame: *ImageCopyCaptureFrameV1, + transform: wl.Output.Transform, + presentation_time: *const posix.timespec, + ) void; + pub fn ready( + frame: *ImageCopyCaptureFrameV1, + transform: wl.Output.Transform, + presentation_time: *const posix.timespec, + ) void { + return wlr_ext_image_copy_capture_frame_v1_ready(frame, transform, presentation_time); + } + + extern fn wlr_ext_image_copy_capture_frame_v1_fail( + frame: *ImageCopyCaptureFrameV1, + reason: FailureReason, + ) void; + pub fn fail( + frame: *ImageCopyCaptureFrameV1, + reason: FailureReason, + ) void { + return wlr_ext_image_copy_capture_frame_v1_fail(frame, reason); + } + + extern fn wlr_ext_image_copy_capture_frame_v1_copy_buffer( + frame: *ImageCopyCaptureFrameV1, + src: *wlr.Buffer, + renderer: *wlr.Renderer, + ) void; + pub fn copyBuffer( + frame: *ImageCopyCaptureFrameV1, + src: *wlr.Buffer, + renderer: *wlr.Renderer, + ) void { + return wlr_ext_image_copy_capture_frame_v1_copy_buffer(frame, src, renderer); + } +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 31635ec..e61f199 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -207,6 +207,9 @@ pub const ForeignToplevelHandleV1 = @import("types/foreign_toplevel_management_v pub const ExtForeignToplevelListV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelListV1; pub const ExtForeignToplevelHandleV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelHandleV1; +pub const ImageCopyCaptureManagerV1 = @import("types/image_copy_capture_v1.zig").ImageCopyCaptureManagerV1; +pub const OutputImageCaptureSourceManagerV1 = @import("types/image_capture_source_v1.zig").OutputImageCaptureSourceManagerV1; + pub const SecurityContextManagerV1 = @import("types/security_context_v1.zig").SecurityContextManagerV1; pub const SecurityContextV1State = @import("types/security_context_v1.zig").SecurityContextV1State; From 5fdbaf0dfd260c2db6a8ead9d351c758af0ea0b2 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 4 Jul 2025 12:12:25 +0200 Subject: [PATCH 13/54] ext-image-*: clean up bindings There are a few minor bugfixes included in this commit as well, but mostly just fixing namespacing and whatnot. --- build.zig | 2 + src/types/ext_image_capture_source_v1.zig | 107 +++++++++++++++ src/types/ext_image_copy_capture_v1.zig | 63 +++++++++ src/types/image_capture_source_v1.zig | 160 ---------------------- src/types/image_copy_capture_v1.zig | 92 ------------- src/wlroots.zig | 7 +- 6 files changed, 177 insertions(+), 254 deletions(-) create mode 100644 src/types/ext_image_capture_source_v1.zig create mode 100644 src/types/ext_image_copy_capture_v1.zig delete mode 100644 src/types/image_capture_source_v1.zig delete mode 100644 src/types/image_copy_capture_v1.zig diff --git a/build.zig b/build.zig index 2402b01..ee541ab 100644 --- a/build.zig +++ b/build.zig @@ -27,6 +27,7 @@ pub fn build(b: *std.Build) void { scanner.addSystemProtocol("staging/cursor-shape/cursor-shape-v1.xml"); scanner.addSystemProtocol("staging/tearing-control/tearing-control-v1.xml"); scanner.addSystemProtocol("staging/content-type/content-type-v1.xml"); + scanner.addSystemProtocol("staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml"); scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); @@ -43,6 +44,7 @@ pub fn build(b: *std.Build) void { scanner.generate("xdg_wm_base", 2); scanner.generate("ext_session_lock_manager_v1", 1); + scanner.generate("ext_image_copy_capture_manager_v1", 1); scanner.generate("zwp_pointer_gestures_v1", 3); scanner.generate("zwp_pointer_constraints_v1", 1); diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig new file mode 100644 index 0000000..0730381 --- /dev/null +++ b/src/types/ext_image_capture_source_v1.zig @@ -0,0 +1,107 @@ +const wlr = @import("../wlroots.zig"); + +const posix = @import("std").posix; + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +const pixman = @import("pixman"); + +pub const ExtImageCaptureSourceV1 = extern struct { + pub const Interface = extern struct { + start: ?*const fn (source: *ExtImageCaptureSourceV1, with_cursors: bool) callconv(.C) void, + stop: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.C) void, + schedule_frame: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.C) void, + copy_frame: *const fn ( + source: *ExtImageCaptureSourceV1, + dst_frame: *wlr.ExtImageCopyCaptureFrameV1, + frame_event: *event.Frame, + ) callconv(.C) void, + get_pointer_cursor: ?*const fn (source: *ExtImageCaptureSourceV1, seat: *wlr.Seat) callconv(.C) *Cursor, + }; + + pub const event = struct { + pub const Frame = extern struct { + damage: *const pixman.Region32, + }; + }; + + impl: *const Interface, + resources: wl.list.Head(wl.Resource, null), + + width: u32, + height: u32, + + shm_formats: *u32, + shm_formats_len: isize, + + dmabuf_device: posix.dev_t, + dmabuf_formats: wlr.DrmFormatSet, + + events: extern struct { + constraints_update: wl.Signal(void), + frame: wl.Signal(*event.Frame), + destroy: wl.Signal(void), + }, + + extern fn wlr_ext_image_capture_source_v1_init(source: *ExtImageCaptureSourceV1, impl: *const Interface) void; + pub const init = wlr_ext_image_capture_source_v1_init; + + extern fn wlr_ext_image_capture_source_v1_finish(source: *ExtImageCaptureSourceV1) void; + pub const finish = wlr_ext_image_capture_source_v1_finish; + + extern fn wlr_ext_image_capture_source_v1_create_resource( + source: *ExtImageCaptureSourceV1, + client: *wl.Client, + new_id: u32, + ) bool; + pub const createResource = wlr_ext_image_capture_source_v1_create_resource; + + extern fn wlr_ext_image_capture_source_v1_set_constraints_from_swapchain( + source: *ExtImageCaptureSourceV1, + swapchain: *wlr.Swapchain, + renderer: *wlr.Renderer, + ) bool; + pub const setContraintsFromSwapchain = wlr_ext_image_capture_source_v1_set_constraints_from_swapchain; + + extern fn wlr_ext_image_capture_source_v1_from_resource(resource: *wl.Resource) ?*ExtImageCaptureSourceV1; + pub const fromResource = wlr_ext_image_capture_source_v1_from_resource; + + pub const Cursor = extern struct { + base: ExtImageCaptureSourceV1, + + entered: bool, + x: i32, + y: i32, + hotspot: extern struct { + x: i32, + y: i32, + }, + + events: extern struct { + update: wl.Signal(void), + }, + + extern fn wlr_ext_image_capture_source_v1_cursor_init(source_cursor: *Cursor, impl: *const Interface) void; + pub const init = wlr_ext_image_capture_source_v1_cursor_init; + + extern fn wlr_ext_image_capture_source_v1_cursor_finish(source_cursor: *Cursor) void; + pub const finish = wlr_ext_image_capture_source_v1_cursor_finish; + }; +}; + +pub const ExtOutputImageCaptureSourceManagerV1 = extern struct { + global: *wl.Global, + + private: extern struct { + display_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_output_image_capture_source_manager_v1_create( + display: *wl.Server, + version: u32, + ) ?*ExtOutputImageCaptureSourceManagerV1; + pub fn create(display: *wl.Server, version: u32) !*ExtOutputImageCaptureSourceManagerV1 { + return wlr_ext_output_image_capture_source_manager_v1_create(display, version) orelse error.OutOfMemory; + } +}; diff --git a/src/types/ext_image_copy_capture_v1.zig b/src/types/ext_image_copy_capture_v1.zig new file mode 100644 index 0000000..2d93621 --- /dev/null +++ b/src/types/ext_image_copy_capture_v1.zig @@ -0,0 +1,63 @@ +const wlr = @import("../wlroots.zig"); + +const posix = @import("std").posix; + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const ext = wayland.server.ext; + +const pixman = @import("pixman"); + +pub const ExtImageCopyCaptureManagerV1 = extern struct { + global: *wl.Global, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_image_copy_capture_manager_v1_create( + display: *wl.Server, + version: u32, + ) ?*ExtImageCopyCaptureManagerV1; + pub fn create( + display: *wl.Server, + version: u32, + ) !*ExtImageCopyCaptureManagerV1 { + return wlr_ext_image_copy_capture_manager_v1_create(display, version) orelse error.OutOfMemory; + } +}; + +pub const ExtImageCopyCaptureFrameV1 = extern struct { + resource: *wl.Resource, + capturing: bool, + buffer: ?*wlr.Buffer, + buffer_damage: pixman.Region32, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + session: ?*opaque {}, + }, + + extern fn wlr_ext_image_copy_capture_frame_v1_ready( + frame: *ExtImageCopyCaptureFrameV1, + transform: wl.Output.Transform, + presentation_time: *const posix.timespec, + ) void; + pub const ready = wlr_ext_image_copy_capture_frame_v1_ready; + + extern fn wlr_ext_image_copy_capture_frame_v1_fail( + frame: *ExtImageCopyCaptureFrameV1, + reason: ext.ImageCopyCaptureFrameV1.FailureReason, + ) void; + pub const fail = wlr_ext_image_copy_capture_frame_v1_fail; + + extern fn wlr_ext_image_copy_capture_frame_v1_copy_buffer( + frame: *ExtImageCopyCaptureFrameV1, + src: *wlr.Buffer, + renderer: *wlr.Renderer, + ) void; + pub const copyBuffer = wlr_ext_image_copy_capture_frame_v1_copy_buffer; +}; diff --git a/src/types/image_capture_source_v1.zig b/src/types/image_capture_source_v1.zig deleted file mode 100644 index acb21ef..0000000 --- a/src/types/image_capture_source_v1.zig +++ /dev/null @@ -1,160 +0,0 @@ -const wlr = @import("../wlroots.zig"); - -const posix = @import("std").posix; - -const wayland = @import("wayland"); -const wl = wayland.server.wl; - -const pixman = @import("pixman"); - -pub const ImageCaptureSourceV1 = extern struct { - impl: *const ImageCaptureSourceV1Interface, - resources: wl.list.Head(wl.Resource, null), - - width: u32, - height: u32, - - shm_formats: *u32, - shm_formats_len: isize, - - dmabuf_device: posix.dev_t, - dmabuf_formats: wlr.DrmFormatSet, - - events: extern struct { - constraints_update: wl.Signal(void), - frame: wl.Signal(void), - destroy: wl.Signal(void), - }, - - extern fn wlr_ext_image_capture_source_v1_init( - source: *ImageCaptureSourceV1, - impl: *const ImageCaptureSourceV1Interface, - ) void; - pub fn init( - source: *ImageCaptureSourceV1, - impl: *const ImageCaptureSourceV1Interface, - ) void { - return wlr_ext_image_capture_source_v1_init(source, impl); - } - - extern fn wlr_ext_image_capture_source_v1_finish(source: *ImageCaptureSourceV1) void; - pub fn finish(source: *ImageCaptureSourceV1) void { - return wlr_ext_image_capture_source_v1_finish(source); - } - - extern fn wlr_ext_image_capture_source_v1_create_resource( - source: *ImageCaptureSourceV1, - client: *wl.Client, - new_id: u32, - ) bool; - pub fn createResource( - source: *ImageCaptureSourceV1, - client: *wl.Client, - new_id: u32, - ) bool { - return wlr_ext_image_capture_source_v1_create_resource(source, client, new_id); - } - - extern fn wlr_ext_image_capture_source_v1_set_constraints_from_swapchain( - source: *ImageCaptureSourceV1, - swapchain: *wlr.Swapchain, - renderer: *wlr.Renderer, - ) bool; - pub fn setContraintsFromSwapchain( - source: *ImageCaptureSourceV1, - swapchain: *wlr.Swapchain, - renderer: *wlr.Renderer, - ) bool { - return wlr_ext_image_capture_source_v1_set_constraints_from_swapchain( - source, - swapchain, - renderer, - ); - } - - extern fn wlr_ext_image_capture_source_v1_from_resource( - resource: *wl.Resource, - ) ?*ImageCaptureSourceV1; - pub fn fromResource(resource: *wl.Resource) !*ImageCaptureSourceV1 { - return wlr_ext_image_capture_source_v1_from_resource(resource) orelse error.OutOfMemory; - } -}; - -pub const ImageCaptureSourceV1Interface = extern struct { - start: *const fn ( - source: *ImageCaptureSourceV1, - with_cursors: bool, - ) callconv(.C) void, - - stop: *const fn (source: *ImageCaptureSourceV1) callconv(.C) void, - - schedule_frame: *const fn (source: *ImageCaptureSourceV1) callconv(.C) void, - - copy_frame: *const fn ( - source: *ImageCaptureSourceV1, - dst_frame: *wlr.ImageCopyCaptureFrameV1, - frame_event: *ImageCaptureSourceV1FrameEvent, - ) callconv(.C) void, - - get_pointer_cursor: *const fn ( - source: *ImageCaptureSourceV1, - seat: *wlr.Seat, - ) callconv(.C) *ImageCaptureSourceV1Cursor, -}; - -pub const ImageCaptureSourceV1FrameEvent = extern struct { - damage: *const pixman.Region32, -}; - -pub const ImageCaptureSourceV1Cursor = extern struct { - base: ImageCaptureSourceV1, - - entered: bool, - x: i32, - y: i32, - hotspot: extern struct { - x: i32, - y: i32, - }, - - events: extern struct { - update: wl.Signal(void), - }, - - extern fn wlr_ext_image_capture_source_v1_cursor_init( - source_cursor: *ImageCaptureSourceV1Cursor, - impl: *const ImageCaptureSourceV1Interface, - ) void; - pub fn cursorInit( - source_cursor: *ImageCaptureSourceV1Cursor, - impl: *const ImageCaptureSourceV1Interface, - ) void { - return wlr_ext_image_capture_source_v1_cursor_init(source_cursor, impl); - } - - extern fn wlr_ext_image_capture_source_v1_cursor_finish( - source_cursor: *ImageCaptureSourceV1Cursor, - ) void; - pub fn finish(source_cursor: *ImageCaptureSourceV1Cursor) void { - return wlr_ext_image_capture_source_v1_cursor_finish(source_cursor); - } -}; - -pub const OutputImageCaptureSourceManagerV1 = extern struct { - global: *wl.Global, - - private: extern struct { - display_destroy: wl.Listener(void), - }, - - extern fn wlr_ext_output_image_capture_source_manager_v1_create( - display: *wl.Server, - version: u32, - ) ?*OutputImageCaptureSourceManagerV1; - pub fn create( - display: *wl.Server, - version: u32, - ) !*OutputImageCaptureSourceManagerV1 { - return wlr_ext_output_image_capture_source_manager_v1_create(display, version) orelse error.OutOfMemory; - } -}; diff --git a/src/types/image_copy_capture_v1.zig b/src/types/image_copy_capture_v1.zig deleted file mode 100644 index e2e2eee..0000000 --- a/src/types/image_copy_capture_v1.zig +++ /dev/null @@ -1,92 +0,0 @@ -const wlr = @import("../wlroots.zig"); - -const posix = @import("std").posix; - -const wayland = @import("wayland"); -const wl = wayland.server.wl; -const FailureReason = wl.ext.ImageCopyCaptureFrameV1.FailureReason; - -const pixman = @import("pixman"); - -const ImageCopyCaptureSessionV1 = extern struct { - resource: *wl.Resource, - source: *wlr.ImageCaptureSourceV1, - frame: *ImageCopyCaptureFrameV1, - - source_destroy: wl.listener(void), - source_constraints_update: wl.listener(void), - source_frame: wl.listener(void), - - damage: pixman.Region32, -}; - -pub const ImageCopyCaptureManagerV1 = extern struct { - global: *wl.Global, - - private: extern struct { - server_destroy: wl.Listener(void), - }, - - extern fn wlr_ext_image_copy_capture_manager_v1_create( - display: *wl.Server, - version: u32, - ) ?*ImageCopyCaptureManagerV1; - pub fn create( - display: *wl.Server, - version: u32, - ) !*ImageCopyCaptureManagerV1 { - return wlr_ext_image_copy_capture_manager_v1_create(display, version) orelse error.OutOfMemory; - } -}; - -pub const ImageCopyCaptureFrameV1 = extern struct { - resource: *wl.Resource, - capturing: bool, - buffer: *wlr.buffer, - buffer_damage: pixman.Region32, - - events: extern struct { - destroy: wl.Signal(void), - }, - - private: extern struct { - session: *ImageCopyCaptureSessionV1, - }, - - extern fn wlr_ext_image_copy_capture_frame_v1_ready( - frame: *ImageCopyCaptureFrameV1, - transform: wl.Output.Transform, - presentation_time: *const posix.timespec, - ) void; - pub fn ready( - frame: *ImageCopyCaptureFrameV1, - transform: wl.Output.Transform, - presentation_time: *const posix.timespec, - ) void { - return wlr_ext_image_copy_capture_frame_v1_ready(frame, transform, presentation_time); - } - - extern fn wlr_ext_image_copy_capture_frame_v1_fail( - frame: *ImageCopyCaptureFrameV1, - reason: FailureReason, - ) void; - pub fn fail( - frame: *ImageCopyCaptureFrameV1, - reason: FailureReason, - ) void { - return wlr_ext_image_copy_capture_frame_v1_fail(frame, reason); - } - - extern fn wlr_ext_image_copy_capture_frame_v1_copy_buffer( - frame: *ImageCopyCaptureFrameV1, - src: *wlr.Buffer, - renderer: *wlr.Renderer, - ) void; - pub fn copyBuffer( - frame: *ImageCopyCaptureFrameV1, - src: *wlr.Buffer, - renderer: *wlr.Renderer, - ) void { - return wlr_ext_image_copy_capture_frame_v1_copy_buffer(frame, src, renderer); - } -}; diff --git a/src/wlroots.zig b/src/wlroots.zig index e61f199..23b5e8a 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -207,8 +207,11 @@ pub const ForeignToplevelHandleV1 = @import("types/foreign_toplevel_management_v pub const ExtForeignToplevelListV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelListV1; pub const ExtForeignToplevelHandleV1 = @import("types/foreign_toplevel_list_v1.zig").ExtForeignToplevelHandleV1; -pub const ImageCopyCaptureManagerV1 = @import("types/image_copy_capture_v1.zig").ImageCopyCaptureManagerV1; -pub const OutputImageCaptureSourceManagerV1 = @import("types/image_capture_source_v1.zig").OutputImageCaptureSourceManagerV1; +pub const ExtImageCaptureSourceV1 = @import("types/ext_image_capture_source_v1.zig").ExtImageCaptureSourceV1; +pub const ExtOutputImageCaptureSourceManagerV1 = @import("types/ext_image_capture_source_v1.zig").ExtOutputImageCaptureSourceManagerV1; + +pub const ExtImageCopyCaptureManagerV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureManagerV1; +pub const ExtImageCopyCaptureFrameV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1; pub const SecurityContextManagerV1 = @import("types/security_context_v1.zig").SecurityContextManagerV1; pub const SecurityContextV1State = @import("types/security_context_v1.zig").SecurityContextV1State; From f92ba27133ecf702d85c9d3894f98a336389bbd9 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 5 Jul 2025 21:00:19 +0200 Subject: [PATCH 14/54] Output: fix typo in State --- src/types/output.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/output.zig b/src/types/output.zig index 661413e..99de660 100644 --- a/src/types/output.zig +++ b/src/types/output.zig @@ -68,7 +68,7 @@ pub const Output = extern struct { buffer: ?*wlr.Buffer, buffer_src_box: wlr.FBox, - buffer_dst_box: wlr.FBox, + buffer_dst_box: wlr.Box, tearing_page_flip: bool, From 7d5f2d14eee0d7fa57a0f256cb9f1672b729808d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 19 Jul 2025 10:43:03 +0200 Subject: [PATCH 15/54] Keyboard: add interface bindings --- src/types/keyboard.zig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/types/keyboard.zig b/src/types/keyboard.zig index 214d6fd..3803349 100644 --- a/src/types/keyboard.zig +++ b/src/types/keyboard.zig @@ -42,7 +42,10 @@ pub const Keyboard = extern struct { }; }; - const Impl = opaque {}; + const Impl = extern struct { + name: [*:0]const u8, + led_update: ?*const fn (keyboard: *Keyboard, leds: u32) void, + }; base: wlr.InputDevice, @@ -76,13 +79,19 @@ pub const Keyboard = extern struct { data: ?*anyopaque, - extern fn wlr_keyboard_set_keymap(kb: *Keyboard, keymap: ?*xkb.Keymap) bool; + extern fn wlr_keyboard_init(keyboard: *Keyboard, impl: *const Impl, name: *[:0]const u8) void; + pub const init = wlr_keyboard_init; + + extern fn wlr_keyboard_finish(keyboard: *Keyboard) void; + pub const finish = wlr_keyboard_finish; + + extern fn wlr_keyboard_set_keymap(keyboard: *Keyboard, keymap: ?*xkb.Keymap) bool; pub const setKeymap = wlr_keyboard_set_keymap; extern fn wlr_keyboard_keymaps_match(km1: ?*xkb.Keymap, km2: ?*xkb.Keymap) bool; pub const keymapsMatch = wlr_keyboard_keymaps_match; - extern fn wlr_keyboard_set_repeat_info(kb: *Keyboard, rate: i32, delay: i32) void; + extern fn wlr_keyboard_set_repeat_info(keyboard: *Keyboard, rate: i32, delay: i32) void; pub const setRepeatInfo = wlr_keyboard_set_repeat_info; extern fn wlr_keyboard_led_update(keyboard: *Keyboard, leds: u32) void; @@ -93,6 +102,9 @@ pub const Keyboard = extern struct { return @as(ModifierMask, @bitCast(wlr_keyboard_get_modifiers(keyboard))); } + extern fn wlr_keyboard_notify_key(keyboard: *Keyboard, event: *event.Key) void; + pub const notifyKey = wlr_keyboard_notify_key; + extern fn wlr_keyboard_notify_modifiers( keyboard: *Keyboard, mods_depressed: u32, From e96d90ce224d10278fc31ca7c3150cbd1919ef1c Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 19 Jul 2025 13:29:10 +0200 Subject: [PATCH 16/54] Keyboard: fix typo --- src/types/keyboard.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/keyboard.zig b/src/types/keyboard.zig index 3803349..0e2adf9 100644 --- a/src/types/keyboard.zig +++ b/src/types/keyboard.zig @@ -79,7 +79,7 @@ pub const Keyboard = extern struct { data: ?*anyopaque, - extern fn wlr_keyboard_init(keyboard: *Keyboard, impl: *const Impl, name: *[:0]const u8) void; + extern fn wlr_keyboard_init(keyboard: *Keyboard, impl: *const Impl, name: [*:0]const u8) void; pub const init = wlr_keyboard_init; extern fn wlr_keyboard_finish(keyboard: *Keyboard) void; From 19f67739cdb12cc1e04eead3d2c7c81ea2a928f3 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 29 Jul 2025 12:42:57 +0200 Subject: [PATCH 17/54] Output: fix minor errors These haven't caused any issues yet in practice, I just read this file very carefully looking for a possible major error. --- src/types/output.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/types/output.zig b/src/types/output.zig index 99de660..d8ed2e6 100644 --- a/src/types/output.zig +++ b/src/types/output.zig @@ -84,13 +84,13 @@ pub const Output = extern struct { gamma_lut_size: usize, // TODO: Bind wlr_output_layer and related structs - layers: ?*anyopaque, + layers: ?*opaque {}, layers_len: usize, - wait_timeline: *wlr.DrmSyncobjTimeline, + wait_timeline: ?*wlr.DrmSyncobjTimeline, wait_point: u64, - signal_timeline: *wlr.DrmSyncobjTimeline, + signal_timeline: ?*wlr.DrmSyncobjTimeline, signal_point: u64, extern fn wlr_output_state_init(state: *State) void; @@ -194,7 +194,7 @@ pub const Output = extern struct { pub const RequestState = extern struct { output: *wlr.Output, - state: *wlr.Output.State, + state: *const wlr.Output.State, }; }; @@ -250,8 +250,8 @@ pub const Output = extern struct { destroy: wl.Signal(*Output), }, - idle_frame: *wl.EventSource, - idle_done: *wl.EventSource, + idle_frame: ?*wl.EventSource, + idle_done: ?*wl.EventSource, attach_render_locks: c_int, From ccf47c83e803e014e69f00193b0f8d6c36c7d232 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 11 Jul 2025 16:20:22 +0200 Subject: [PATCH 18/54] build: update to Zig 0.15 --- .builds/alpine.yml | 8 ++--- .builds/archlinux.yml | 8 ++--- .builds/freebsd.yml | 8 ++--- README.md | 2 +- build.zig | 8 +++-- build.zig.zon | 4 +-- src/backend.zig | 26 +++++++-------- src/render/allocator.zig | 4 +-- src/types/buffer.zig | 14 ++++---- src/types/compositor.zig | 22 ++++++------- src/types/data_device.zig | 12 +++---- src/types/ext_image_capture_source_v1.zig | 10 +++--- src/types/input_device.zig | 22 +++++-------- src/types/layer_shell_v1.zig | 8 ++--- src/types/output.zig | 10 +++--- src/types/primary_selection.zig | 4 +-- src/types/scene.zig | 10 +++--- src/types/seat.zig | 38 ++++++++++----------- src/types/tablet_v2.zig | 40 +++++++++++------------ src/types/xdg_shell.zig | 8 ++--- src/util/addon.zig | 2 +- src/util/log.zig | 2 +- src/wlroots.zig | 16 ++++----- src/xwayland/xwayland.zig | 2 +- tinywl/build.zig | 8 +++-- tinywl/build.zig.zon | 4 +-- 26 files changed, 147 insertions(+), 153 deletions(-) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index b9b2d1e..01fb203 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -37,10 +37,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz - tar xf zig-linux-x86_64-0.14.0.tar.xz - sudo mv zig-linux-x86_64-0.14.0/zig /usr/bin/ - sudo mv zig-linux-x86_64-0.14.0/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz + tar xf zig-x86_64-linux-0.15.1.tar.xz + sudo mv zig-x86_64-linux-0.15.1/zig /usr/bin/ + sudo mv zig-x86_64-linux-0.15.1/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index 49592c7..35810f4 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -34,10 +34,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz - tar xf zig-linux-x86_64-0.14.0.tar.xz - sudo mv zig-linux-x86_64-0.14.0/zig /usr/bin/ - sudo mv zig-linux-x86_64-0.14.0/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz + tar xf zig-x86_64-linux-0.15.1.tar.xz + sudo mv zig-x86_64-linux-0.15.1/zig /usr/bin/ + sudo mv zig-x86_64-linux-0.15.1/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index bf09267..588dd07 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -41,10 +41,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.14.0/zig-freebsd-x86_64-0.14.0-unofficial.tar.xz - tar xf zig-freebsd-x86_64-0.14.0-unofficial.tar.xz - sudo mv zig-freebsd-x86_64-0.14.0-unofficial/zig /usr/bin/ - sudo mv zig-freebsd-x86_64-0.14.0-unofficial/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-freebsd-0.15.1.tar.xz + tar xf zig-x86_64-freebsd-0.15.1.tar.xz + sudo mv zig-x86_64-freebsd-0.15.1/zig /usr/bin/ + sudo mv zig-x86_64-freebsd-0.15.1/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/README.md b/README.md index 3164916..60797c5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ request on [codeberg](https://codeberg.org/ifreund/zig-wlroots). ## Dependencies -- [zig](https://ziglang.org/) 0.14 +- [zig](https://ziglang.org/) 0.15 - [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.19 - [zig-wayland](https://codeberg.org/ifreund/zig-wayland) - [zig-xkbcommon](https://codeberg.org/ifreund/zig-xkbcommon) diff --git a/build.zig b/build.zig index ee541ab..57e8d1d 100644 --- a/build.zig +++ b/build.zig @@ -63,9 +63,11 @@ pub fn build(b: *std.Build) void { const pixman = (b.lazyDependency("pixman", .{}) orelse return).module("pixman"); const wlr_test = b.addTest(.{ - .root_source_file = b.path("src/wlroots.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("src/wlroots.zig"), + .target = target, + .optimize = optimize, + }), }); wlr_test.linkLibC(); diff --git a/build.zig.zon b/build.zig.zon index b12a049..b22ba51 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,8 +15,8 @@ .lazy = true, }, .wayland = .{ - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.3.0.tar.gz", - .hash = "wayland-0.3.0-lQa1kjPIAQDmhGYpY-zxiRzQJFHQ2VqhJkQLbKKdt5wl", + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz", + .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", .lazy = true, }, .xkbcommon = .{ diff --git a/src/backend.zig b/src/backend.zig index 9c5f385..5a6a96a 100644 --- a/src/backend.zig +++ b/src/backend.zig @@ -110,7 +110,7 @@ pub const Backend = extern struct { extern fn wlr_multi_for_each_backend( backend: *Backend, - callback: *const fn (backend: *Backend, data: ?*anyopaque) callconv(.C) void, + callback: *const fn (backend: *Backend, data: ?*anyopaque) callconv(.c) void, data: ?*anyopaque, ) void; pub inline fn multiForEachBackend( @@ -122,7 +122,7 @@ pub const Backend = extern struct { wlr_multi_for_each_backend( backend, struct { - fn wrapper(b: *Backend, d: ?*anyopaque) callconv(.C) void { + fn wrapper(b: *Backend, d: ?*anyopaque) callconv(.c) void { callback(b, @ptrCast(@alignCast(d))); } }.wrapper, @@ -168,18 +168,16 @@ pub const Backend = extern struct { // backend/x11.h - pub usingnamespace if (wlr.config.has_x11_backend) struct { - extern fn wlr_x11_backend_create(loop: *wl.EventLoop, x11_display: [*:0]const u8) ?*Backend; - pub fn createX11(loop: *wl.EventLoop, x11_display: [*:0]const u8) !*Backend { - return wlr_x11_backend_create(loop, x11_display) orelse error.BackendCreateFailed; - } + extern fn wlr_x11_backend_create(loop: *wl.EventLoop, x11_display: [*:0]const u8) ?*Backend; + pub fn createX11(loop: *wl.EventLoop, x11_display: [*:0]const u8) !*Backend { + return wlr_x11_backend_create(loop, x11_display) orelse error.BackendCreateFailed; + } - extern fn wlr_x11_output_create(x11: *Backend) ?*wlr.Output; - pub fn x11OutputCreate(x11: *Backend) !*wlr.Output { - return wlr_x11_output_create(x11) orelse error.OutOfMemory; - } + extern fn wlr_x11_output_create(x11: *Backend) ?*wlr.Output; + pub fn x11OutputCreate(x11: *Backend) !*wlr.Output { + return wlr_x11_output_create(x11) orelse error.OutOfMemory; + } - extern fn wlr_backend_is_x11(x11: *Backend) bool; - pub const isX11 = wlr_backend_is_x11; - } else struct {}; + extern fn wlr_backend_is_x11(x11: *Backend) bool; + pub const isX11 = wlr_backend_is_x11; }; diff --git a/src/render/allocator.zig b/src/render/allocator.zig index 0a807a5..eb144c3 100644 --- a/src/render/allocator.zig +++ b/src/render/allocator.zig @@ -5,8 +5,8 @@ const wl = wayland.server.wl; pub const Allocator = extern struct { pub const Interface = extern struct { - create_buffer: *const fn (alloc: *wlr.Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) callconv(.C) ?*wlr.Buffer, - destroy: *const fn (alloc: *wlr.Allocator) callconv(.C) void, + create_buffer: *const fn (alloc: *wlr.Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) callconv(.c) ?*wlr.Buffer, + destroy: *const fn (alloc: *wlr.Allocator) callconv(.c) void, }; impl: *const Interface, diff --git a/src/types/buffer.zig b/src/types/buffer.zig index dcf3d4d..fdda495 100644 --- a/src/types/buffer.zig +++ b/src/types/buffer.zig @@ -26,17 +26,17 @@ pub const Buffer = extern struct { }; pub const Impl = extern struct { - destroy: *const fn (buffer: *Buffer) callconv(.C) void, - get_dmabuf: ?*const fn (buffer: *Buffer, attribs: *wlr.DmabufAttributes) callconv(.C) bool, - get_shm: ?*const fn (buffer: *Buffer, attribs: *wlr.ShmAttributes) callconv(.C) bool, - begin_data_ptr_access: ?*const fn (buffer: *Buffer, flags: u32, data: **anyopaque, format: *u32, stride: *usize) callconv(.C) bool, - end_data_ptr_access: ?*const fn (buffer: *Buffer) callconv(.C) void, + destroy: *const fn (buffer: *Buffer) callconv(.c) void, + get_dmabuf: ?*const fn (buffer: *Buffer, attribs: *wlr.DmabufAttributes) callconv(.c) bool, + get_shm: ?*const fn (buffer: *Buffer, attribs: *wlr.ShmAttributes) callconv(.c) bool, + begin_data_ptr_access: ?*const fn (buffer: *Buffer, flags: u32, data: **anyopaque, format: *u32, stride: *usize) callconv(.c) bool, + end_data_ptr_access: ?*const fn (buffer: *Buffer) callconv(.c) void, }; pub const ResourceInterface = extern struct { name: [*:0]const u8, - is_instance: *const fn (resource: *wl.Resource) callconv(.C) bool, - from_resource: *const fn (resource: *wl.Resource) callconv(.C) ?*Buffer, + is_instance: *const fn (resource: *wl.Resource) callconv(.c) bool, + from_resource: *const fn (resource: *wl.Resource) callconv(.c) ?*Buffer, }; impl: *const Impl, diff --git a/src/types/compositor.zig b/src/types/compositor.zig index 95afc4c..0d7ae20 100644 --- a/src/types/compositor.zig +++ b/src/types/compositor.zig @@ -88,11 +88,11 @@ pub const Surface = extern struct { pub const Role = extern struct { name: [*:0]const u8, no_object: bool = false, - client_commit: ?*const fn (surface: *Surface) callconv(.C) void = null, - commit: ?*const fn (surface: *Surface) callconv(.C) void = null, - map: ?*const fn (surface: *Surface) callconv(.C) void = null, - unmap: ?*const fn (surface: *Surface) callconv(.C) void = null, - destroy: ?*const fn (surface: *Surface) callconv(.C) void = null, + client_commit: ?*const fn (surface: *Surface) callconv(.c) void = null, + commit: ?*const fn (surface: *Surface) callconv(.c) void = null, + map: ?*const fn (surface: *Surface) callconv(.c) void = null, + unmap: ?*const fn (surface: *Surface) callconv(.c) void = null, + destroy: ?*const fn (surface: *Surface) callconv(.c) void = null, }; pub const Output = extern struct { @@ -111,10 +111,10 @@ pub const Surface = extern struct { pub const Synced = extern struct { pub const Impl = extern struct { state_size: usize, - init_state: ?*const fn (state: *anyopaque) callconv(.C) void, - finish_state: ?*const fn (state: *anyopaque) callconv(.C) void, - move_state: ?*const fn (dst: *anyopaque, src: *anyopaque) callconv(.C) void, - commit: ?*const fn (synced: *Synced) callconv(.C) void = null, + init_state: ?*const fn (state: *anyopaque) callconv(.c) void, + finish_state: ?*const fn (state: *anyopaque) callconv(.c) void, + move_state: ?*const fn (dst: *anyopaque, src: *anyopaque) callconv(.c) void, + commit: ?*const fn (synced: *Synced) callconv(.c) void = null, }; surface: *Surface, @@ -261,7 +261,7 @@ pub const Surface = extern struct { extern fn wlr_surface_for_each_surface( surface: *Surface, - iterator: *const fn (surface: *Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, + iterator: *const fn (surface: *Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachSurface( @@ -273,7 +273,7 @@ pub const Surface = extern struct { wlr_surface_for_each_surface( surface, struct { - fn wrapper(s: *Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(s: *Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(s, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, diff --git a/src/types/data_device.zig b/src/types/data_device.zig index 9a2e567..e5ca4ae 100644 --- a/src/types/data_device.zig +++ b/src/types/data_device.zig @@ -46,12 +46,12 @@ pub const DataOffer = extern struct { pub const DataSource = extern struct { pub const Impl = extern struct { - send: *const fn (source: *DataSource, mime_type: [*:0]const u8, fd: i32) callconv(.C) void, - accept: ?*const fn (source: *DataSource, serial: u32, mime_type: ?[*:0]const u8) callconv(.C) void, - destroy: ?*const fn (source: *DataSource) callconv(.C) void, - dnd_drop: ?*const fn (source: *DataSource) callconv(.C) void, - dnd_finish: ?*const fn (source: *DataSource) callconv(.C) void, - dnd_action: ?*const fn (source: *DataSource, wl.DataDeviceManager.DndAction.Enum) callconv(.C) void, + send: *const fn (source: *DataSource, mime_type: [*:0]const u8, fd: i32) callconv(.c) void, + accept: ?*const fn (source: *DataSource, serial: u32, mime_type: ?[*:0]const u8) callconv(.c) void, + destroy: ?*const fn (source: *DataSource) callconv(.c) void, + dnd_drop: ?*const fn (source: *DataSource) callconv(.c) void, + dnd_finish: ?*const fn (source: *DataSource) callconv(.c) void, + dnd_action: ?*const fn (source: *DataSource, wl.DataDeviceManager.DndAction.Enum) callconv(.c) void, }; impl: *const Impl, diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig index 0730381..a16136a 100644 --- a/src/types/ext_image_capture_source_v1.zig +++ b/src/types/ext_image_capture_source_v1.zig @@ -9,15 +9,15 @@ const pixman = @import("pixman"); pub const ExtImageCaptureSourceV1 = extern struct { pub const Interface = extern struct { - start: ?*const fn (source: *ExtImageCaptureSourceV1, with_cursors: bool) callconv(.C) void, - stop: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.C) void, - schedule_frame: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.C) void, + start: ?*const fn (source: *ExtImageCaptureSourceV1, with_cursors: bool) callconv(.c) void, + stop: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.c) void, + schedule_frame: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.c) void, copy_frame: *const fn ( source: *ExtImageCaptureSourceV1, dst_frame: *wlr.ExtImageCopyCaptureFrameV1, frame_event: *event.Frame, - ) callconv(.C) void, - get_pointer_cursor: ?*const fn (source: *ExtImageCaptureSourceV1, seat: *wlr.Seat) callconv(.C) *Cursor, + ) callconv(.c) void, + get_pointer_cursor: ?*const fn (source: *ExtImageCaptureSourceV1, seat: *wlr.Seat) callconv(.c) *Cursor, }; pub const event = struct { diff --git a/src/types/input_device.zig b/src/types/input_device.zig index 7dff2a6..57d9a41 100644 --- a/src/types/input_device.zig +++ b/src/types/input_device.zig @@ -43,24 +43,20 @@ pub const InputDevice = extern struct { extern fn wlr_input_device_get_virtual_keyboard(wlr_dev: *InputDevice) ?*wlr.VirtualKeyboardV1; pub const getVirtualKeyboard = wlr_input_device_get_virtual_keyboard; - pub usingnamespace if (wlr.config.has_libinput_backend) struct { - extern fn wlr_input_device_is_libinput(wlr_dev: *InputDevice) bool; - pub const isLibinput = wlr_input_device_is_libinput; + extern fn wlr_input_device_is_libinput(wlr_dev: *InputDevice) bool; + pub const isLibinput = wlr_input_device_is_libinput; - extern fn wlr_libinput_get_device_handle(wlr_dev: *InputDevice) *LibinputDevice; - pub fn getLibinputDevice(wlr_dev: *InputDevice) ?*LibinputDevice { - if (!wlr_input_device_is_libinput(wlr_dev)) return null; - return wlr_libinput_get_device_handle(wlr_dev); - } - } else struct {}; + extern fn wlr_libinput_get_device_handle(wlr_dev: *InputDevice) *LibinputDevice; + pub fn getLibinputDevice(wlr_dev: *InputDevice) ?*LibinputDevice { + if (!wlr_input_device_is_libinput(wlr_dev)) return null; + return wlr_libinput_get_device_handle(wlr_dev); + } extern fn wlr_input_device_is_wl(wlr_dev: *InputDevice) bool; pub const isWl = wlr_input_device_is_wl; - pub usingnamespace if (wlr.config.has_x11_backend) struct { - extern fn wlr_input_device_is_x11(wlr_dev: *InputDevice) bool; - pub const isX11 = wlr_input_device_is_x11; - } else struct {}; + extern fn wlr_input_device_is_x11(wlr_dev: *InputDevice) bool; + pub const isX11 = wlr_input_device_is_x11; }; const LibinputDevice = opaque {}; diff --git a/src/types/layer_shell_v1.zig b/src/types/layer_shell_v1.zig index 3c32c25..d9c220b 100644 --- a/src/types/layer_shell_v1.zig +++ b/src/types/layer_shell_v1.zig @@ -107,7 +107,7 @@ pub const LayerSurfaceV1 = extern struct { extern fn wlr_layer_surface_v1_for_each_surface( surface: *LayerSurfaceV1, - iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.C) void, + iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachSurface( @@ -119,7 +119,7 @@ pub const LayerSurfaceV1 = extern struct { wlr_layer_surface_v1_for_each_surface( surface, struct { - fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(s, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, @@ -129,7 +129,7 @@ pub const LayerSurfaceV1 = extern struct { extern fn wlr_layer_surface_v1_for_each_popup_surface( surface: *LayerSurfaceV1, - iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.C) void, + iterator: *const fn (*wlr.Surface, c_int, c_int, ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachPopupSurface( @@ -141,7 +141,7 @@ pub const LayerSurfaceV1 = extern struct { wlr_layer_surface_v1_for_each_popup_surface( surface, struct { - fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(s, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, diff --git a/src/types/output.zig b/src/types/output.zig index d8ed2e6..3be9d7b 100644 --- a/src/types/output.zig +++ b/src/types/output.zig @@ -368,13 +368,11 @@ pub const Output = extern struct { extern fn wlr_wl_output_get_surface(output: *Output) *wayland.client.wl.Surface; pub const wlGetSurface = wlr_wl_output_get_surface; - pub usingnamespace if (wlr.config.has_x11_backend) struct { - extern fn wlr_output_is_x11(output: *Output) bool; - pub const isX11 = wlr_output_is_x11; + extern fn wlr_output_is_x11(output: *Output) bool; + pub const isX11 = wlr_output_is_x11; - extern fn wlr_x11_output_set_title(output: *Output, title: ?[*:0]const u8) void; - pub const x11SetTitle = wlr_x11_output_set_title; - } else struct {}; + extern fn wlr_x11_output_set_title(output: *Output, title: ?[*:0]const u8) void; + pub const x11SetTitle = wlr_x11_output_set_title; }; pub const OutputCursor = extern struct { diff --git a/src/types/primary_selection.zig b/src/types/primary_selection.zig index 42fea66..480c7e4 100644 --- a/src/types/primary_selection.zig +++ b/src/types/primary_selection.zig @@ -4,8 +4,8 @@ const wl = @import("wayland").server.wl; pub const PrimarySelectionSource = extern struct { pub const Impl = extern struct { - send: *const fn (source: *PrimarySelectionSource, mime_type: [*:0]const u8, fd: c_int) callconv(.C) void, - destroy: ?*const fn (source: *PrimarySelectionSource) callconv(.C) void, + send: *const fn (source: *PrimarySelectionSource, mime_type: [*:0]const u8, fd: c_int) callconv(.c) void, + destroy: ?*const fn (source: *PrimarySelectionSource) callconv(.c) void, }; impl: *const Impl, diff --git a/src/types/scene.zig b/src/types/scene.zig index 3b33395..72a676c 100644 --- a/src/types/scene.zig +++ b/src/types/scene.zig @@ -47,7 +47,7 @@ pub const SceneNode = extern struct { extern fn wlr_scene_node_for_each_buffer( node: *SceneNode, - iterator: *const fn (buffer: *SceneBuffer, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, + iterator: *const fn (buffer: *SceneBuffer, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachBuffer( @@ -59,7 +59,7 @@ pub const SceneNode = extern struct { wlr_scene_node_for_each_buffer( node, struct { - fn wrapper(b: *SceneBuffer, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(b: *SceneBuffer, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(b, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, @@ -250,7 +250,7 @@ pub const SceneBuffer = extern struct { frame_done: wl.Signal(*posix.timespec), }, - point_accepts_input: ?*const fn (buffer: *SceneBuffer, sx: *f64, sy: *f64) callconv(.C) bool, + point_accepts_input: ?*const fn (buffer: *SceneBuffer, sx: *f64, sy: *f64) callconv(.c) bool, primary_output: ?*wlr.SceneOutput, @@ -372,7 +372,7 @@ pub const SceneOutput = extern struct { extern fn wlr_scene_output_for_each_buffer( scene_output: *SceneOutput, - iterator: *const fn (buffer: *SceneBuffer, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, + iterator: *const fn (buffer: *SceneBuffer, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachBuffer( @@ -384,7 +384,7 @@ pub const SceneOutput = extern struct { wlr_scene_output_for_each_buffer( scene_output, struct { - fn wrapper(b: *SceneBuffer, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(b: *SceneBuffer, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(b, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, diff --git a/src/types/seat.zig b/src/types/seat.zig index 8beeffc..9fa2fd1 100644 --- a/src/types/seat.zig +++ b/src/types/seat.zig @@ -86,15 +86,15 @@ pub const Seat = extern struct { surface: *wlr.Surface, sx: f64, sy: f64, - ) callconv(.C) void, - clear_focus: *const fn (grab: *PointerGrab) callconv(.C) void, - motion: *const fn (grab: *PointerGrab, time_msec: u32, sx: f64, sy: f64) callconv(.C) void, + ) callconv(.c) void, + clear_focus: *const fn (grab: *PointerGrab) callconv(.c) void, + motion: *const fn (grab: *PointerGrab, time_msec: u32, sx: f64, sy: f64) callconv(.c) void, button: *const fn ( grab: *PointerGrab, time_msec: u32, button: u32, state: wl.Pointer.ButtonState, - ) callconv(.C) u32, + ) callconv(.c) u32, axis: *const fn ( grab: *PointerGrab, time_msec: u32, @@ -103,9 +103,9 @@ pub const Seat = extern struct { value_discrete: i32, source: wl.Pointer.AxisSource, source: wl.Pointer.AxisRelativeDirection, - ) callconv(.C) void, - frame: ?*const fn (grab: *PointerGrab) callconv(.C) void, - cancel: ?*const fn (grab: *PointerGrab) callconv(.C) void, + ) callconv(.c) void, + frame: ?*const fn (grab: *PointerGrab) callconv(.c) void, + cancel: ?*const fn (grab: *PointerGrab) callconv(.c) void, }; interface: *const Interface, @@ -121,11 +121,11 @@ pub const Seat = extern struct { keycodes: ?[*]const u32, num_keycodes: usize, modifiers: ?*const wlr.Keyboard.Modifiers, - ) callconv(.C) void, - clear_focus: *const fn (grab: *KeyboardGrab) callconv(.C) void, - key: *const fn (grab: *KeyboardGrab, time_msec: u32, key: u32, state: u32) callconv(.C) void, - modifiers: *const fn (grab: *KeyboardGrab, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.C) void, - cancel: ?*const fn (grab: *KeyboardGrab) callconv(.C) void, + ) callconv(.c) void, + clear_focus: *const fn (grab: *KeyboardGrab) callconv(.c) void, + key: *const fn (grab: *KeyboardGrab, time_msec: u32, key: u32, state: u32) callconv(.c) void, + modifiers: *const fn (grab: *KeyboardGrab, modifiers: ?*const wlr.Keyboard.Modifiers) callconv(.c) void, + cancel: ?*const fn (grab: *KeyboardGrab) callconv(.c) void, }; interface: *const Interface, @@ -135,13 +135,13 @@ pub const Seat = extern struct { pub const TouchGrab = extern struct { pub const Interface = extern struct { - down: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.C) u32, - up: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.C) u32, - motion: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.C) void, - enter: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.C) void, - frame: ?*const fn (grab: *TouchGrab) callconv(.C) void, - cancel: ?*const fn (grab: *TouchGrab) callconv(.C) void, - wl_cancel: ?*const fn (grab: *TouchGrab, seat_client: *wlr.Seat.Client) callconv(.C) void, + down: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) u32, + up: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) u32, + motion: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void, + enter: *const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void, + frame: ?*const fn (grab: *TouchGrab) callconv(.c) void, + cancel: ?*const fn (grab: *TouchGrab) callconv(.c) void, + wl_cancel: ?*const fn (grab: *TouchGrab, seat_client: *wlr.Seat.Client) callconv(.c) void, }; interface: *const Interface, diff --git a/src/types/tablet_v2.zig b/src/types/tablet_v2.zig index 6e90614..39052d6 100644 --- a/src/types/tablet_v2.zig +++ b/src/types/tablet_v2.zig @@ -66,19 +66,19 @@ pub const TabletV2TabletTool = extern struct { pub const Grab = extern struct { pub const Interface = extern struct { - proximity_in: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.C) void, - down: ?*const fn (*Grab) callconv(.C) void, - up: ?*const fn (*Grab) callconv(.C) void, - motion: ?*const fn (*Grab, f64, f64) callconv(.C) void, - pressure: ?*const fn (*Grab, f64) callconv(.C) void, - distance: ?*const fn (*Grab, f64) callconv(.C) void, - tilt: ?*const fn (*Grab, f64, f64) callconv(.C) void, - rotation: ?*const fn (*Grab, f64) callconv(.C) void, - slider: ?*const fn (*Grab, f64) callconv(.C) void, - wheel: ?*const fn (*Grab, f64, i32) callconv(.C) void, - proximity_out: ?*const fn (*Grab) callconv(.C) void, - button: ?*const fn (*Grab, u32, zwp.TabletToolV2.ButtonState) callconv(.C) void, - cancel: ?*const fn (*Grab) callconv(.C) void, + proximity_in: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.c) void, + down: ?*const fn (*Grab) callconv(.c) void, + up: ?*const fn (*Grab) callconv(.c) void, + motion: ?*const fn (*Grab, f64, f64) callconv(.c) void, + pressure: ?*const fn (*Grab, f64) callconv(.c) void, + distance: ?*const fn (*Grab, f64) callconv(.c) void, + tilt: ?*const fn (*Grab, f64, f64) callconv(.c) void, + rotation: ?*const fn (*Grab, f64) callconv(.c) void, + slider: ?*const fn (*Grab, f64) callconv(.c) void, + wheel: ?*const fn (*Grab, f64, i32) callconv(.c) void, + proximity_out: ?*const fn (*Grab) callconv(.c) void, + button: ?*const fn (*Grab, u32, zwp.TabletToolV2.ButtonState) callconv(.c) void, + cancel: ?*const fn (*Grab) callconv(.c) void, }; interface: *const Interface, tool: *TabletV2TabletTool, @@ -207,13 +207,13 @@ pub const TabletV2TabletPad = extern struct { pub const Grab = extern struct { pub const Interface = extern struct { - enter: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.C) u32, - button: ?*const fn (*Grab, usize, u32, zwp.TabletPadV2.ButtonState) callconv(.C) void, - strip: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.C) void, - ring: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.C) void, - leave: ?*const fn (*Grab, *wlr.Surface) callconv(.C) u32, - mode: ?*const fn (*Grab, usize, u32, u32) callconv(.C) u32, - cancel: ?*const fn (*Grab) callconv(.C) void, + enter: ?*const fn (*Grab, *TabletV2Tablet, *wlr.Surface) callconv(.c) u32, + button: ?*const fn (*Grab, usize, u32, zwp.TabletPadV2.ButtonState) callconv(.c) void, + strip: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.c) void, + ring: ?*const fn (*Grab, u32, f64, bool, u32) callconv(.c) void, + leave: ?*const fn (*Grab, *wlr.Surface) callconv(.c) u32, + mode: ?*const fn (*Grab, usize, u32, u32) callconv(.c) u32, + cancel: ?*const fn (*Grab) callconv(.c) void, }; interface: *const Interface, diff --git a/src/types/xdg_shell.zig b/src/types/xdg_shell.zig index 505fe9a..39c0aee 100644 --- a/src/types/xdg_shell.zig +++ b/src/types/xdg_shell.zig @@ -396,7 +396,7 @@ pub const XdgSurface = extern struct { extern fn wlr_xdg_surface_for_each_surface( surface: *wlr.XdgSurface, - iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, + iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachSurface( @@ -408,7 +408,7 @@ pub const XdgSurface = extern struct { wlr_xdg_surface_for_each_surface( surface, struct { - fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(s, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, @@ -418,7 +418,7 @@ pub const XdgSurface = extern struct { extern fn wlr_xdg_surface_for_each_popup_surface( surface: *wlr.XdgSurface, - iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.C) void, + iterator: *const fn (surface: *wlr.Surface, sx: c_int, sy: c_int, data: ?*anyopaque) callconv(.c) void, user_data: ?*anyopaque, ) void; pub inline fn forEachPopupSurface( @@ -430,7 +430,7 @@ pub const XdgSurface = extern struct { wlr_xdg_surface_for_each_popup_surface( surface, struct { - fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.C) void { + fn wrapper(s: *wlr.Surface, sx: c_int, sy: c_int, d: ?*anyopaque) callconv(.c) void { iterator(s, sx, sy, @ptrCast(@alignCast(d))); } }.wrapper, diff --git a/src/util/addon.zig b/src/util/addon.zig index 961595b..1e85f55 100644 --- a/src/util/addon.zig +++ b/src/util/addon.zig @@ -19,7 +19,7 @@ pub const AddonSet = extern struct { pub const Addon = extern struct { pub const Interface = extern struct { name: [*:0]const u8, - destroy: *const fn (*Addon) callconv(.C) void, + destroy: *const fn (*Addon) callconv(.c) void, }; impl: *const Interface, diff --git a/src/util/log.zig b/src/util/log.zig index 68c576a..9c629d5 100644 --- a/src/util/log.zig +++ b/src/util/log.zig @@ -10,7 +10,7 @@ pub const Importance = enum(c_int) { extern fn wlr_log_init( verbosity: Importance, - callback: ?*const fn (importance: Importance, fmt: [*:0]const u8, args: *std.builtin.VaList) callconv(.C) void, + callback: ?*const fn (importance: Importance, fmt: [*:0]const u8, args: *std.builtin.VaList) callconv(.c) void, ) void; pub const init = wlr_log_init; diff --git a/src/wlroots.zig b/src/wlroots.zig index 23b5e8a..cd13fce 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -179,15 +179,13 @@ pub const XcursorTheme = @import("xcursor.zig").XcursorTheme; pub const XcursorManager = @import("types/xcursor_manager.zig").XcursorManager; pub const XcursorManagerTheme = @import("types/xcursor_manager.zig").XcursorManagerTheme; -pub usingnamespace if (config.has_xwayland) struct { - pub const XwaylandServer = @import("xwayland/server.zig").XwaylandServer; - pub const Xwayland = @import("xwayland/xwayland.zig").Xwayland; - pub const XwaylandSurface = @import("xwayland/xwayland.zig").XwaylandSurface; - pub const XwaylandCursor = @import("xwayland/xwayland.zig").XwaylandCursor; - pub const Xwm = @import("xwayland/xwayland.zig").Xwm; - pub const XwaylandShellV1 = @import("xwayland/shell.zig").XwaylandShellV1; - pub const XwaylandSurfaceV1 = @import("xwayland/shell.zig").XwaylandSurfaceV1; -} else struct {}; +pub const XwaylandServer = @import("xwayland/server.zig").XwaylandServer; +pub const Xwayland = @import("xwayland/xwayland.zig").Xwayland; +pub const XwaylandSurface = @import("xwayland/xwayland.zig").XwaylandSurface; +pub const XwaylandCursor = @import("xwayland/xwayland.zig").XwaylandCursor; +pub const Xwm = @import("xwayland/xwayland.zig").Xwm; +pub const XwaylandShellV1 = @import("xwayland/shell.zig").XwaylandShellV1; +pub const XwaylandSurfaceV1 = @import("xwayland/shell.zig").XwaylandSurfaceV1; pub const AddonSet = @import("util/addon.zig").AddonSet; pub const Addon = @import("util/addon.zig").Addon; diff --git a/src/xwayland/xwayland.zig b/src/xwayland/xwayland.zig index 00a33d5..52db9d8 100644 --- a/src/xwayland/xwayland.zig +++ b/src/xwayland/xwayland.zig @@ -116,7 +116,7 @@ pub const Xwayland = extern struct { remove_startup_info: wl.Signal(*event.RemoveStartupInfo), }, - user_event_handler: ?*const fn (*Xwayland, *xcb.GenericEvent) callconv(.C) bool, + user_event_handler: ?*const fn (*Xwayland, *xcb.GenericEvent) callconv(.c) bool, data: ?*anyopaque, diff --git a/tinywl/build.zig b/tinywl/build.zig index 7d26495..ee6b01b 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -41,9 +41,11 @@ pub fn build(b: *std.Build) void { const tinywl = b.addExecutable(.{ .name = "tinywl", - .root_source_file = b.path("tinywl.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("tinywl.zig"), + .target = target, + .optimize = optimize, + }), }); tinywl.linkLibC(); diff --git a/tinywl/build.zig.zon b/tinywl/build.zig.zon index 6604f84..d59c1f5 100644 --- a/tinywl/build.zig.zon +++ b/tinywl/build.zig.zon @@ -8,8 +8,8 @@ .hash = "pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX", }, .wayland = .{ - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.3.0.tar.gz", - .hash = "wayland-0.3.0-lQa1kjPIAQDmhGYpY-zxiRzQJFHQ2VqhJkQLbKKdt5wl", + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz", + .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", }, .wlroots = .{ .path = "..", From dd380a1cc3e3e9639b3ebe3be3462041121964d7 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 22 Aug 2025 15:00:37 +0200 Subject: [PATCH 19/54] tinywl: fix fmt --- tinywl/tinywl.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinywl/tinywl.zig b/tinywl/tinywl.zig index a219c65..7500951 100644 --- a/tinywl/tinywl.zig +++ b/tinywl/tinywl.zig @@ -195,7 +195,7 @@ const Server = struct { // These asserts are fine since tinywl.zig doesn't support anything else that can // make xdg popups (e.g. layer shell). const parent = wlr.XdgSurface.tryFromWlrSurface(xdg_popup.parent.?) orelse return; - const parent_tree = @as(?*wlr.SceneTree, @alignCast(@ptrCast(parent.data))) orelse { + const parent_tree = @as(?*wlr.SceneTree, @ptrCast(@alignCast(parent.data))) orelse { // The xdg surface user data could be left null due to allocation failure. return; }; @@ -234,7 +234,7 @@ const Server = struct { var it: ?*wlr.SceneTree = node.parent; while (it) |n| : (it = n.node.parent) { - if (@as(?*Toplevel, @alignCast(@ptrCast(n.node.data)))) |toplevel| { + if (@as(?*Toplevel, @ptrCast(@alignCast(n.node.data)))) |toplevel| { return ViewAtResult{ .toplevel = toplevel, .surface = scene_surface.surface, From d7f46abafcd1f660ffc99d9d9eef466049371c0f Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 22 Aug 2025 15:01:24 +0200 Subject: [PATCH 20/54] build: bump version to 0.19.3 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index b22ba51..06871d7 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.3-dev", + .version = "0.19.3", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 01a33c3e28f94040a697b309e3d991c6b9a811bb Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 22 Aug 2025 15:02:11 +0200 Subject: [PATCH 21/54] build: bump version to 0.19.4-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 06871d7..3b41a9e 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.3", + .version = "0.19.4-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From b6e7843a9640fc824ae5770783405496ddb77571 Mon Sep 17 00:00:00 2001 From: Ahmed Hamza Aydin Date: Fri, 6 Feb 2026 22:16:15 +0100 Subject: [PATCH 22/54] Swapchain: add bindings --- src/render/swapchain.zig | 50 ++++++++++++++++++++++++++++++++++++++++ src/wlroots.zig | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/render/swapchain.zig diff --git a/src/render/swapchain.zig b/src/render/swapchain.zig new file mode 100644 index 0000000..710ac0c --- /dev/null +++ b/src/render/swapchain.zig @@ -0,0 +1,50 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +pub const Swapchain = extern struct { + pub const Slot = extern struct { + buffer: ?*wlr.Buffer, + /// Waiting for release + acquired: bool, + + private: extern struct { + release: wl.Listener(void), + }, + }; + + /// `null` if destroyed + allocator: ?*wlr.Allocator, + + width: c_int, + height: c_int, + format: wlr.DrmFormat, + + slots: [4]Slot, + + private: extern struct { + allocator_destroy: wl.Listener(void), + }, + + extern fn wlr_swapchain_create(alloc: *wlr.Allocator, width: c_int, height: c_int, format: *wlr.DrmFormat) ?*Swapchain; + pub fn create(alloc: *wlr.Allocator, width: c_int, height: c_int, format: *wlr.DrmFormat) !*Swapchain { + return wlr_swapchain_create(alloc, width, height, format) orelse error.SwapchainCreateFailed; + } + + extern fn wlr_swapchain_destroy(swapchain: *Swapchain) void; + pub const destroy = wlr_swapchain_destroy; + + /// Acquire a buffer from the swap chain. + /// + /// The returned buffer is locked. When the caller is done with it, they must + /// unlock it by calling `wlr.Buffer.unlock`. + extern fn wlr_swapchain_acquire(swapchain: *Swapchain) ?*wlr.Buffer; + pub fn acquire(swapchain: *Swapchain) !*wlr.Buffer { + return wlr_swapchain_acquire(swapchain) orelse error.SwapchainAquireBufferFailed; + } + + /// Returns `true` if this buffer has been created by this swapchain, and false otherwise + extern fn wlr_swapchain_has_buffer(swapchain: *Swapchain, buffer: *wlr.Buffer) bool; + pub const hasBuffer = wlr_swapchain_has_buffer; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index cd13fce..fd1e300 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -12,7 +12,7 @@ pub const RenderTimer = @import("render/renderer.zig").RenderTimer; pub const RenderPass = @import("render/renderer.zig").RenderPass; pub const Texture = @import("render/texture.zig").Texture; pub const Allocator = @import("render/allocator.zig").Allocator; -pub const Swapchain = opaque {}; // TODO +pub const Swapchain = @import("render/swapchain.zig").Swapchain; pub const DrmFormat = @import("render/drm_format_set.zig").DrmFormat; pub const DrmFormatSet = @import("render/drm_format_set.zig").DrmFormatSet; From 95c4341e3afe9496331baf2156a3ee15b2cb7bc0 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 24 Feb 2026 12:16:19 +0100 Subject: [PATCH 23/54] ext-data-control-v1: add bindings --- src/types/ext_data_control_v1.zig | 41 +++++++++++++++++++++++++++++++ src/wlroots.zig | 3 +++ 2 files changed, 44 insertions(+) create mode 100644 src/types/ext_data_control_v1.zig diff --git a/src/types/ext_data_control_v1.zig b/src/types/ext_data_control_v1.zig new file mode 100644 index 0000000..9adfbbc --- /dev/null +++ b/src/types/ext_data_control_v1.zig @@ -0,0 +1,41 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +pub const ExtDataControlManagerV1 = extern struct { + global: *wl.Global, + devices: wl.list.Head(ExtDataControlDeviceV1, .link), + + events: extern struct { + destroy: wl.Signal(void), + new_device: wl.Signal(*ExtDataControlDeviceV1), + }, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_data_control_manager_v1_create(server: *wl.Server, version: u32) ?*ExtDataControlManagerV1; + pub fn create(server: *wl.Server, version: u32) !*ExtDataControlManagerV1 { + return wlr_ext_data_control_manager_v1_create(server, version) orelse error.OutOfMemory; + } +}; + +pub const ExtDataControlDeviceV1 = extern struct { + resource: *wl.Resource, + manager: *ExtDataControlManagerV1, + /// ExtDataControlManagerV1.devices + link: wl.list.Link, + + seat: *wlr.Seat, + selection_offer_resource: ?*wl.Resource, + primary_selection_offer_resource: ?*wl.Resource, + + seat_destroy: wl.Listener(void), + seat_set_selection: wl.Listener(void), + seat_set_primary_selection: wl.Listener(void), + + extern fn wlr_ext_data_control_device_v1_destroy(device: *ExtDataControlDeviceV1) void; + pub const destroy = wlr_ext_data_control_device_v1_destroy; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index fd1e300..fd1d34b 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -139,6 +139,9 @@ pub const Drag = @import("types/data_device.zig").Drag; pub const DataControlManagerV1 = @import("types/data_control_v1.zig").DataControlManagerV1; pub const DataControlDeviceV1 = @import("types/data_control_v1.zig").DataControlDeviceV1; +pub const ExtDataControlManagerV1 = @import("types/ext_data_control_v1.zig").ExtDataControlManagerV1; +pub const ExtDataControlDeviceV1 = @import("types/ext_data_control_v1.zig").ExtDataControlDeviceV1; + pub const PrimarySelectionSource = @import("types/primary_selection.zig").PrimarySelectionSource; pub const PrimarySelectionDeviceManagerV1 = @import("types/primary_selection_v1.zig").PrimarySelectionDeviceManagerV1; From a17a59f233fa0664508b078512da7bb098d5b199 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 15 Mar 2026 15:40:34 +0100 Subject: [PATCH 24/54] build: bump version to 0.19.4 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 3b41a9e..dbd1214 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.4-dev", + .version = "0.19.4", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From fb3d3021a957b6065c0232535a017821749e84dc Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 15 Mar 2026 15:40:50 +0100 Subject: [PATCH 25/54] build: bump version to 0.19.5-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index dbd1214..68d9400 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.4", + .version = "0.19.5-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 6ffee8b21d24e0e4aadcf204f65ebe7ad3c3bacf Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 27 Mar 2026 13:10:04 +0100 Subject: [PATCH 26/54] build: update to wlroots 0.20 --- .builds/alpine.yml | 2 +- .builds/archlinux.yml | 2 +- .builds/freebsd.yml | 2 +- README.md | 2 +- build.zig | 4 +- build.zig.zon | 2 +- protocol/virtual-keyboard-unstable-v1.xml | 113 ++++++++++++++++++++++ src/render/color.zig | 50 ++++++++++ src/render/renderer.zig | 11 +++ src/types/ext_data_control_v1.zig | 8 +- src/types/ext_image_capture_source_v1.zig | 2 +- src/types/ext_image_copy_capture_v1.zig | 22 +++++ src/types/gamma_control_v1.zig | 2 + src/types/input_method_v2.zig | 8 +- src/types/keyboard.zig | 8 +- src/types/output.zig | 51 ++++++---- src/types/scene.zig | 27 +++++- src/types/seat.zig | 4 + src/types/text_input_v3.zig | 12 +-- src/types/virtual_keyboard_v1.zig | 10 +- src/types/xdg_shell.zig | 9 +- src/version.zig | 9 ++ src/wlroots.zig | 9 +- src/xcursor.zig | 7 ++ src/xwayland/xwayland.zig | 13 ++- tinywl/build.zig | 2 +- 26 files changed, 335 insertions(+), 56 deletions(-) create mode 100644 protocol/virtual-keyboard-unstable-v1.xml create mode 100644 src/render/color.zig diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 01fb203..f565f3b 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -28,7 +28,7 @@ sources: tasks: - install_deps: | cd wlroots - git checkout 0.19.0 + git checkout 0.20.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ -Dcolor-management=disabled -Dlibliftoff=disabled \ -Dexamples=false -Dwerror=false -Db_ndebug=false \ diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index 35810f4..863e09c 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -25,7 +25,7 @@ sources: tasks: - install_deps: | cd wlroots - git checkout 0.19.0 + git checkout 0.20.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ -Dcolor-management=disabled -Dlibliftoff=disabled \ -Dexamples=false -Dwerror=false -Db_ndebug=false \ diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index 588dd07..f3423f9 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -31,7 +31,7 @@ sources: tasks: - install_deps: | cd wlroots - git checkout 0.19.0 + git checkout 0.20.0 meson setup build --auto-features=enabled -Drenderers=gles2 \ -Dallocators=gbm \ -Dcolor-management=disabled -Dlibliftoff=disabled \ diff --git a/README.md b/README.md index 60797c5..6952614 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ request on [codeberg](https://codeberg.org/ifreund/zig-wlroots). ## Dependencies - [zig](https://ziglang.org/) 0.15 -- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.19 +- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.20 - [zig-wayland](https://codeberg.org/ifreund/zig-wayland) - [zig-xkbcommon](https://codeberg.org/ifreund/zig-xkbcommon) - [zig-pixman](https://codeberg.org/ifreund/zig-pixman) diff --git a/build.zig b/build.zig index 57e8d1d..9789e84 100644 --- a/build.zig +++ b/build.zig @@ -31,6 +31,7 @@ pub fn build(b: *std.Build) void { scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); + scanner.addCustomProtocol(b.path("protocol/virtual-keyboard-unstable-v1.xml")); // These must be manually kept in sync with the versions wlroots supports // until wlroots gives the option to request a specific version. @@ -51,6 +52,7 @@ pub fn build(b: *std.Build) void { scanner.generate("zxdg_decoration_manager_v1", 1); scanner.generate("zwp_tablet_manager_v2", 1); scanner.generate("zwp_linux_dmabuf_v1", 4); + scanner.generate("zwp_virtual_keyboard_manager_v1", 1); scanner.generate("wp_cursor_shape_manager_v1", 1); scanner.generate("wp_tearing_control_manager_v1", 1); scanner.generate("wp_content_type_manager_v1", 1); @@ -81,7 +83,7 @@ pub fn build(b: *std.Build) void { wlr_test.root_module.addImport("pixman", pixman); wlr_test.linkSystemLibrary("pixman-1"); - wlr_test.linkSystemLibrary("wlroots-0.19"); + wlr_test.linkSystemLibrary("wlroots-0.20"); const test_step = b.step("test", "Run the tests"); test_step.dependOn(&wlr_test.step); diff --git a/build.zig.zon b/build.zig.zon index 68d9400..504ba1b 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.19.5-dev", + .version = "0.20.0-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", diff --git a/protocol/virtual-keyboard-unstable-v1.xml b/protocol/virtual-keyboard-unstable-v1.xml new file mode 100644 index 0000000..5095c91 --- /dev/null +++ b/protocol/virtual-keyboard-unstable-v1.xml @@ -0,0 +1,113 @@ + + + + Copyright © 2008-2011 Kristian Høgsberg + Copyright © 2010-2013 Intel Corporation + Copyright © 2012-2013 Collabora, Ltd. + Copyright © 2018 Purism SPC + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + The virtual keyboard provides an application with requests which emulate + the behaviour of a physical keyboard. + + This interface can be used by clients on its own to provide raw input + events, or it can accompany the input method protocol. + + + + + Provide a file descriptor to the compositor which can be + memory-mapped to provide a keyboard mapping description. + + Format carries a value from the keymap_format enumeration. + + + + + + + + + + + + + A key was pressed or released. + The time argument is a timestamp with millisecond granularity, with an + undefined base. All requests regarding a single object must share the + same clock. + + Keymap must be set before issuing this request. + + State carries a value from the key_state enumeration. + + + + + + + + + Notifies the compositor that the modifier and/or group state has + changed, and it should update state. + + The client should use wl_keyboard.modifiers event to synchronize its + internal state with seat state. + + Keymap must be set before issuing this request. + + + + + + + + + + + + + + + A virtual keyboard manager allows an application to provide keyboard + input events as if they came from a physical keyboard. + + + + + + + + + Creates a new virtual keyboard associated to a seat. + + If the compositor enables a keyboard to perform arbitrary actions, it + should present an error when an untrusted client requests a new + keyboard. + + + + + + diff --git a/src/render/color.zig b/src/render/color.zig new file mode 100644 index 0000000..74a2963 --- /dev/null +++ b/src/render/color.zig @@ -0,0 +1,50 @@ +const wlr = @import("../wlroots.zig"); + +pub const NamedPrimaries = enum(c_int) { + srgb = 1, + bt2020 = 2, +}; + +pub const TransferFunction = enum(c_int) { + srgb = 1, + st2084_pq = 2, + ext_linear = 4, + gamma22 = 8, + bt1886 = 16, +}; + +pub const Encoding = enum(c_int) { + none = 0, + identity = 1, + bt709 = 2, + fcc = 4, + bt601 = 8, + smpte240 = 16, + bt2020 = 32, + bt2020_cl = 64, + ictcp = 128, +}; + +pub const Range = enum(c_int) { + none, + limited, + full, +}; + +pub const Cie1931Xy = extern struct { + x: f32, + y: f32, +}; + +pub const Primaries = extern struct { + red: Cie1931Xy, + green: Cie1931Xy, + blue: Cie1931Xy, + white: Cie1931Xy, +}; + +pub const Luminances = extern struct { + min: f32, + max: f32, + reference: f32, +}; diff --git a/src/render/renderer.zig b/src/render/renderer.zig index fa8bffd..0d0dd92 100644 --- a/src/render/renderer.zig +++ b/src/render/renderer.zig @@ -10,6 +10,8 @@ pub const Renderer = extern struct { /// Bitmask of wlr.BufferCap render_buffer_caps: u32, + /// Bitmask of wlr.ColorEncoding + color_encodings: u32, events: extern struct { destroy: wl.Signal(*Renderer), @@ -17,6 +19,7 @@ pub const Renderer = extern struct { }, features: extern struct { + input_color_transform: bool, output_color_transform: bool, timeline: bool, }, @@ -120,6 +123,14 @@ pub const RenderPass = opaque { transform: wl.Output.Transform, filter_mode: ScaleFilterMode, blend_mode: BlendMode, + + transfer_function: wlr.color.TransferFunction, + primaries: *const wlr.color.Primaries, + color_encoding: wlr.color.Encoding, + color_range: wlr.color.Range, + /// Default 1.0 + luminance_multiplier: *const f32, + wait_timeline: ?*wlr.DrmSyncobjTimeline = null, wait_point: u64, }; diff --git a/src/types/ext_data_control_v1.zig b/src/types/ext_data_control_v1.zig index 9adfbbc..0e31706 100644 --- a/src/types/ext_data_control_v1.zig +++ b/src/types/ext_data_control_v1.zig @@ -32,9 +32,11 @@ pub const ExtDataControlDeviceV1 = extern struct { selection_offer_resource: ?*wl.Resource, primary_selection_offer_resource: ?*wl.Resource, - seat_destroy: wl.Listener(void), - seat_set_selection: wl.Listener(void), - seat_set_primary_selection: wl.Listener(void), + private: extern struct { + seat_destroy: wl.Listener(void), + seat_set_selection: wl.Listener(void), + seat_set_primary_selection: wl.Listener(void), + }, extern fn wlr_ext_data_control_device_v1_destroy(device: *ExtDataControlDeviceV1) void; pub const destroy = wlr_ext_data_control_device_v1_destroy; diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig index a16136a..9aeda94 100644 --- a/src/types/ext_image_capture_source_v1.zig +++ b/src/types/ext_image_capture_source_v1.zig @@ -11,7 +11,7 @@ pub const ExtImageCaptureSourceV1 = extern struct { pub const Interface = extern struct { start: ?*const fn (source: *ExtImageCaptureSourceV1, with_cursors: bool) callconv(.c) void, stop: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.c) void, - schedule_frame: ?*const fn (source: *ExtImageCaptureSourceV1) callconv(.c) void, + request_frame: ?*const fn (source: *ExtImageCaptureSourceV1, schedule_frame: bool) callconv(.c) void, copy_frame: *const fn ( source: *ExtImageCaptureSourceV1, dst_frame: *wlr.ExtImageCopyCaptureFrameV1, diff --git a/src/types/ext_image_copy_capture_v1.zig b/src/types/ext_image_copy_capture_v1.zig index 2d93621..f4efdc2 100644 --- a/src/types/ext_image_copy_capture_v1.zig +++ b/src/types/ext_image_copy_capture_v1.zig @@ -11,6 +11,10 @@ const pixman = @import("pixman"); pub const ExtImageCopyCaptureManagerV1 = extern struct { global: *wl.Global, + events: extern struct { + new_session: wl.Signal(*ExtImageCopyCaptureSessionV1), + }, + private: extern struct { server_destroy: wl.Listener(void), }, @@ -27,6 +31,24 @@ pub const ExtImageCopyCaptureManagerV1 = extern struct { } }; +pub const ExtImageCopyCaptureSessionV1 = extern struct { + resource: *wl.Resource, + source: *wlr.ExtImageCaptureSourceV1, + frame: *ExtImageCopyCaptureFrameV1, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + source_destroy: wl.Listener(void), + source_constraints_update: wl.Listener(void), + source_frame: wl.Listener(void), + + damage: pixman.Region32, + }, +}; + pub const ExtImageCopyCaptureFrameV1 = extern struct { resource: *wl.Resource, capturing: bool, diff --git a/src/types/gamma_control_v1.zig b/src/types/gamma_control_v1.zig index 11a163d..36d2ef5 100644 --- a/src/types/gamma_control_v1.zig +++ b/src/types/gamma_control_v1.zig @@ -14,6 +14,8 @@ pub const GammaControlManagerV1 = extern struct { global: *wl.Global, controls: wl.list.Head(GammaControlV1, .link), + fallback_gamma_size: usize, + events: extern struct { destroy: wl.Signal(*GammaControlManagerV1), set_gamma: wl.Signal(*event.SetGamma), diff --git a/src/types/input_method_v2.zig b/src/types/input_method_v2.zig index 2521a26..a02347e 100644 --- a/src/types/input_method_v2.zig +++ b/src/types/input_method_v2.zig @@ -8,8 +8,8 @@ pub const InputMethodManagerV2 = extern struct { input_methods: wl.list.Head(InputMethodV2, .link), events: extern struct { - input_method: wl.Signal(*wlr.InputMethodV2), - destroy: wl.Signal(*wlr.InputMethodManagerV2), + new_input_method: wl.Signal(*wlr.InputMethodV2), + destroy: wl.Signal(void), }, private: extern struct { @@ -86,10 +86,10 @@ pub const InputMethodV2 = extern struct { link: wl.list.Link, events: extern struct { - commit: wl.Signal(*wlr.InputMethodV2), + commit: wl.Signal(void), new_popup_surface: wl.Signal(*wlr.InputPopupSurfaceV2), grab_keyboard: wl.Signal(*wlr.InputMethodV2.KeyboardGrab), - destroy: wl.Signal(*wlr.InputMethodV2), + destroy: wl.Signal(void), }, private: extern struct { diff --git a/src/types/keyboard.zig b/src/types/keyboard.zig index 0e2adf9..1543af0 100644 --- a/src/types/keyboard.zig +++ b/src/types/keyboard.zig @@ -8,12 +8,16 @@ const wl = wayland.server.wl; const xkb = @import("xkbcommon"); pub const Keyboard = extern struct { + pub const led_count = 5; pub const led = struct { pub const num_lock = 1 << 0; pub const caps_lock = 1 << 1; pub const scroll_lock = 1 << 2; + pub const compose = 1 << 3; + pub const kana = 1 << 4; }; + pub const modifier_count = 8; pub const ModifierMask = packed struct(u32) { shift: bool = false, caps: bool = false, @@ -57,8 +61,8 @@ pub const Keyboard = extern struct { keymap_fd: c_int, keymap: ?*xkb.Keymap, xkb_state: ?*xkb.State, - led_indexes: [3]xkb.LED_Index, - mod_indexes: [8]xkb.ModIndex, + led_indexes: [led_count]xkb.LED_Index, + mod_indexes: [modifier_count]xkb.ModIndex, leds: u32, keycodes: [32]u32, diff --git a/src/types/output.zig b/src/types/output.zig index 3be9d7b..54514e3 100644 --- a/src/types/output.zig +++ b/src/types/output.zig @@ -33,6 +33,18 @@ pub const Output = extern struct { enabled, }; + pub const ImageDescription = extern struct { + primaries: wlr.color.NamedPrimaries, + transfer_function: wlr.color.TransferFunction, + mastering_display_primaries: wlr.color.Primaries, + mastering_luminance: extern struct { + min: f64, + max: f64, + }, + max_cll: f64, + max_fall: f64, + }; + pub const State = extern struct { pub const Fields = packed struct(u32) { buffer: bool = false, @@ -42,13 +54,14 @@ pub const Output = extern struct { scale: bool = false, transform: bool = false, adaptive_sync_enabled: bool = false, - gamma_lut: bool = false, render_format: bool = false, subpixel: bool = false, layers: bool = false, wait_timeline: bool = false, signal_timeline: bool = false, - _: u19 = 0, + color_transform: bool = false, + image_description: bool = false, + _: u18 = 0, }; pub const ModeType = enum(c_int) { @@ -80,9 +93,6 @@ pub const Output = extern struct { refresh: i32, }, - gamma_lut: ?[*]u16, - gamma_lut_size: usize, - // TODO: Bind wlr_output_layer and related structs layers: ?*opaque {}, layers_len: usize, @@ -93,6 +103,10 @@ pub const Output = extern struct { signal_timeline: ?*wlr.DrmSyncobjTimeline, signal_point: u64, + color_transform: ?*wlr.ColorTransform, + + image_description: ?*ImageDescription, + extern fn wlr_output_state_init(state: *State) void; pub fn init() State { var state: State = undefined; @@ -130,19 +144,6 @@ pub const Output = extern struct { extern fn wlr_output_state_set_buffer(state: *State, buffer: *wlr.Buffer) void; pub const setBuffer = wlr_output_state_set_buffer; - extern fn wlr_output_state_set_gamma_lut(state: *State, ramp_size: usize, r: *const u16, g: *const u16, b: *const u16) bool; - pub const setGammaLut = wlr_output_state_set_gamma_lut; - - /// Clearing the gamma lut can't fail. Furthermore, a separate function for this - /// allows using non-optional pointers for the r/b/g parameters of setGammaLut. - pub fn clearGammaLut(state: *State) void { - state.committed.gamma_lut = true; - - std.c.free(state.gamma_lut); - state.gamma_lut = null; - state.gamma_lut_size = 0; - } - extern fn wlr_output_state_set_damage(state: *State, damage: *const pixman.Region32) void; pub const setDamage = wlr_output_state_set_damage; @@ -159,13 +160,13 @@ pub const Output = extern struct { pub const Precommit = extern struct { output: *wlr.Output, - when: *posix.timespec, + when: posix.timespec, state: *const State, }; pub const Commit = extern struct { output: *wlr.Output, - when: *posix.timespec, + when: posix.timespec, state: *const Output.State, }; @@ -214,6 +215,7 @@ pub const Output = extern struct { serial: ?[*:0]u8, phys_width: i32, phys_height: i32, + default_primaries: ?*wlr.color.Primaries, modes: wl.list.Head(Output.Mode, .link), current_mode: ?*Output.Mode, @@ -221,12 +223,18 @@ pub const Output = extern struct { height: i32, refresh: i32, + /// Bitfield of wlr.ColorNamedPrimaries + supported_primaries: u32, + /// Bitfield of wlr.ColorTransferFunction + supported_transfer_functions: u32, + enabled: bool, scale: f32, subpixel: wl.Output.Subpixel, transform: wl.Output.Transform, adaptive_sync_status: AdaptiveSyncStatus, render_format: u32, + image_description: ?*const ImageDescription, adaptive_sync_supported: bool, @@ -275,6 +283,9 @@ pub const Output = extern struct { private: extern struct { server_destroy: wl.Listener(void), + image_description_value: ImageDescription, + color_transform: ?*wlr.ColorTransform, + default_primaries_value: wlr.color.Primaries, }, extern fn wlr_output_create_global(output: *Output, server: *wl.Server) void; diff --git a/src/types/scene.zig b/src/types/scene.zig index 72a676c..a87c776 100644 --- a/src/types/scene.zig +++ b/src/types/scene.zig @@ -148,11 +148,15 @@ pub const Scene = extern struct { linux_dmabuf_v1: ?*wlr.LinuxDmabufV1, gamma_control_manager_v1: ?*wlr.GammaControlManagerV1, + color_manager: ?*wlr.ColorManagerV1, + + restack_xwayland_surfaces: bool, private: extern struct { linux_dmabuf_v1_destroy: wl.Listener(void), gamma_control_manager_v1_destroy: wl.Listener(void), gamma_control_manager_v1_set_gamma: wl.Listener(void), + color_manager_v1_destroy: wl.Listener(void), debug_damage_option: c_int, direct_scanout: bool, @@ -199,8 +203,6 @@ pub const SceneSurface = extern struct { addon: wlr.Addon, outputs_update: wl.Listener(void), - output_enter: wl.Listener(void), - output_leave: wl.Listener(void), output_sample: wl.Listener(void), frame_done: wl.Listener(void), surface_destroy: wl.Listener(void), @@ -236,6 +238,12 @@ pub const SceneBuffer = extern struct { pub const OutputSample = extern struct { output: *SceneOutput, direct_scanout: bool, + release_timeline: *wlr.DrmSyncobjTimeline, + release_point: u64, + }; + pub const FrameDone = extern struct { + output: *wlr.SceneOutput, + when: posix.timespec, }; }; @@ -247,7 +255,7 @@ pub const SceneBuffer = extern struct { output_enter: wl.Signal(*SceneOutput), output_leave: wl.Signal(*SceneOutput), output_sample: wl.Signal(*event.OutputSample), - frame_done: wl.Signal(*posix.timespec), + frame_done: wl.Signal(*event.FrameDone), }, point_accepts_input: ?*const fn (buffer: *SceneBuffer, sx: *f64, sy: *f64) callconv(.c) bool, @@ -261,6 +269,10 @@ pub const SceneBuffer = extern struct { dst_height: c_int, transform: wl.Output.Transform, opaque_region: pixman.Region32, + transfer_function: wlr.color.TransferFunction, + primaries: wlr.color.NamedPrimaries, + color_encoding: wlr.color.Encoding, + color_range: wlr.color.Range, private: extern struct { active_outputs: u64, @@ -309,7 +321,7 @@ pub const SceneBuffer = extern struct { extern fn wlr_scene_buffer_set_filter_mode(scene_buffer: *SceneBuffer, filter_mode: wlr.RenderPass.ScaleFilterMode) void; pub const setFilterMode = wlr_scene_buffer_set_filter_mode; - extern fn wlr_scene_buffer_send_frame_done(scene_buffer: *SceneBuffer, now: *posix.timespec) void; + extern fn wlr_scene_buffer_send_frame_done(scene_buffer: *SceneBuffer, event: *event.FrameDone) void; pub const sendFrameDone = wlr_scene_buffer_send_frame_done; }; @@ -339,6 +351,11 @@ pub const SceneOutput = extern struct { gamma_lut_changed: bool, gamma_lut: ?*wlr.GammaControlV1, + gamma_lut_color_transform: ?*wlr.ColorTransform, + + prev_gamma_lut_color_transform: ?*wlr.ColorTransform, + prev_supplied_color_transform: ?*wlr.ColorTransform, + combined_color_transform: ?*wlr.ColorTransform, output_commit: wl.Listener(void), output_damage: wl.Listener(void), @@ -350,6 +367,8 @@ pub const SceneOutput = extern struct { in_timeline: ?*wlr.DrmSyncobjTimeline, in_point: u64, + out_timeline: ?*wlr.DrmSyncobjTimeline, + out_point: u64, }, pub const StateOptions = extern struct { diff --git a/src/types/seat.zig b/src/types/seat.zig index 9fa2fd1..21cb7e7 100644 --- a/src/types/seat.zig +++ b/src/types/seat.zig @@ -142,6 +142,7 @@ pub const Seat = extern struct { frame: ?*const fn (grab: *TouchGrab) callconv(.c) void, cancel: ?*const fn (grab: *TouchGrab) callconv(.c) void, wl_cancel: ?*const fn (grab: *TouchGrab, seat_client: *wlr.Seat.Client) callconv(.c) void, + clear_focus: ?*const fn (grab: *TouchGrab, time_msec: u32, point: *TouchPoint) callconv(.c) void, }; interface: *const Interface, @@ -486,6 +487,9 @@ pub const Seat = extern struct { extern fn wlr_seat_touch_notify_cancel(seat: *Seat, seat_client: *wlr.Seat.Client) void; pub const touchNotifyCancel = wlr_seat_touch_notify_cancel; + extern fn wlr_seat_touch_notify_clear_focus(seat: *Seat, seat_client: *wlr.Seat.Client) void; + pub const touchNotifyClearFocus = wlr_seat_touch_notify_clear_focus; + extern fn wlr_seat_touch_num_points(seat: *Seat) c_int; pub const touchNumPoints = wlr_seat_touch_num_points; diff --git a/src/types/text_input_v3.zig b/src/types/text_input_v3.zig index 902efb6..b2f22b7 100644 --- a/src/types/text_input_v3.zig +++ b/src/types/text_input_v3.zig @@ -8,8 +8,8 @@ pub const TextInputManagerV3 = extern struct { text_inputs: wl.list.Head(TextInputV3, .link), events: extern struct { - text_input: wl.Signal(*wlr.TextInputV3), - destroy: wl.Signal(*wlr.TextInputManagerV3), + new_text_input: wl.Signal(*wlr.TextInputV3), + destroy: wl.Signal(void), }, private: extern struct { @@ -62,10 +62,10 @@ pub const TextInputV3 = extern struct { link: wl.list.Link, events: extern struct { - enable: wl.Signal(*wlr.TextInputV3), - commit: wl.Signal(*wlr.TextInputV3), - disable: wl.Signal(*wlr.TextInputV3), - destroy: wl.Signal(*wlr.TextInputV3), + enable: wl.Signal(void), + commit: wl.Signal(void), + disable: wl.Signal(void), + destroy: wl.Signal(void), }, private: extern struct { diff --git a/src/types/virtual_keyboard_v1.zig b/src/types/virtual_keyboard_v1.zig index 4036853..bb464ea 100644 --- a/src/types/virtual_keyboard_v1.zig +++ b/src/types/virtual_keyboard_v1.zig @@ -2,6 +2,7 @@ const wlr = @import("../wlroots.zig"); const wayland = @import("wayland"); const wl = wayland.server.wl; +const zwp = wayland.server.zwp; pub const VirtualKeyboardManagerV1 = extern struct { global: *wl.Global, @@ -24,10 +25,17 @@ pub const VirtualKeyboardManagerV1 = extern struct { pub const VirtualKeyboardV1 = extern struct { keyboard: wlr.Keyboard, - resource: *wl.Resource, + resource: *zwp.VirtualKeyboardV1, seat: *wlr.Seat, has_keymap: bool, /// VirtualKeyboardManagerV1.virtual_keyboards link: wl.list.Link, + + private: extern struct { + seat_destroy: wl.Listener(void), + }, + + extern fn wlr_virtual_keyboard_v1_from_resource(resource: *zwp.VirtualKeyboardV1) ?*VirtualKeyboardV1; + pub const fromResource = wlr_virtual_keyboard_v1_from_resource; }; diff --git a/src/types/xdg_shell.zig b/src/types/xdg_shell.zig index 39c0aee..3931a49 100644 --- a/src/types/xdg_shell.zig +++ b/src/types/xdg_shell.zig @@ -161,6 +161,7 @@ pub const XdgToplevel = extern struct { activated: bool, suspended: bool, tiled: wlr.Edges, + constrained: wlr.Edges, width: i32, height: i32, max_width: i32, @@ -191,6 +192,7 @@ pub const XdgToplevel = extern struct { activated: bool, suspended: bool, tiled: wlr.Edges, + constrained: wlr.Edges, width: i32, height: i32, bounds: extern struct { @@ -287,7 +289,12 @@ pub const XdgToplevel = extern struct { extern fn wlr_xdg_toplevel_set_tiled(toplevel: *wlr.XdgToplevel, tiled_edges: u32) u32; pub fn setTiled(toplevel: *wlr.XdgToplevel, tiled_edges: wlr.Edges) u32 { - return wlr_xdg_toplevel_set_tiled(toplevel, @as(u32, @bitCast(tiled_edges))); + return wlr_xdg_toplevel_set_tiled(toplevel, @bitCast(tiled_edges)); + } + + extern fn wlr_xdg_toplevel_set_constrained(toplevel: *wlr.XdgToplevel, constrained_edges: u32) u32; + pub fn setConstrained(toplevel: *wlr.XdgToplevel, constrained_edges: wlr.Edges) u32 { + return wlr_xdg_toplevel_set_constrained(toplevel, @bitCast(constrained_edges)); } extern fn wlr_xdg_toplevel_set_bounds(toplevel: *wlr.XdgToplevel, width: i32, height: i32) u32; diff --git a/src/version.zig b/src/version.zig index 07d23bd..11a495b 100644 --- a/src/version.zig +++ b/src/version.zig @@ -7,3 +7,12 @@ pub const minor = c.WLR_VERSION_MINOR; pub const micro = c.WLR_VERSION_MICRO; pub const num = c.WLR_VERSION_NUM; + +extern fn wlr_version_get_major() c_int; +pub const runtimeMajor = wlr_version_get_major; + +extern fn wlr_version_get_minor() c_int; +pub const runtimeMinor = wlr_version_get_minor; + +extern fn wlr_version_get_micro() c_int; +pub const runtimeMicro = wlr_version_get_micro; diff --git a/src/wlroots.zig b/src/wlroots.zig index fd1d34b..de5a988 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -16,7 +16,10 @@ pub const Swapchain = @import("render/swapchain.zig").Swapchain; pub const DrmFormat = @import("render/drm_format_set.zig").DrmFormat; pub const DrmFormatSet = @import("render/drm_format_set.zig").DrmFormatSet; +pub const color = @import("render/color.zig"); + pub const ColorTransform = opaque {}; // TODO +pub const ColorManagerV1 = opaque {}; // TODO pub const Drm = @import("types/drm.zig").Drm; @@ -34,6 +37,7 @@ pub const ShmAttributes = @import("types/buffer.zig").ShmAttributes; pub const BufferCap = @import("types/buffer.zig").BufferCap; pub const Buffer = @import("types/buffer.zig").Buffer; pub const ClientBuffer = @import("types/buffer.zig").ClientBuffer; +pub const ReadonlyDataBuffer = opaque {}; pub const SinglePixelBufferManagerV1 = @import("types/single_pixel_buffer_v1.zig").SinglePixelBufferManagerV1; @@ -185,7 +189,6 @@ pub const XcursorManagerTheme = @import("types/xcursor_manager.zig").XcursorMana pub const XwaylandServer = @import("xwayland/server.zig").XwaylandServer; pub const Xwayland = @import("xwayland/xwayland.zig").Xwayland; pub const XwaylandSurface = @import("xwayland/xwayland.zig").XwaylandSurface; -pub const XwaylandCursor = @import("xwayland/xwayland.zig").XwaylandCursor; pub const Xwm = @import("xwayland/xwayland.zig").Xwm; pub const XwaylandShellV1 = @import("xwayland/shell.zig").XwaylandShellV1; pub const XwaylandSurfaceV1 = @import("xwayland/shell.zig").XwaylandSurfaceV1; @@ -234,8 +237,8 @@ pub const config = @import("config.zig"); pub const version = @import("version.zig"); comptime { - if (version.major != 0 or version.minor != 19) { - @compileError("zig-wlroots requires wlroots version 0.19, found version " ++ version.str); + if (version.major != 0 or version.minor != 20) { + @compileError("zig-wlroots requires wlroots version 0.20, found version " ++ version.str); } } test { diff --git a/src/xcursor.zig b/src/xcursor.zig index 975319a..2ef39b2 100644 --- a/src/xcursor.zig +++ b/src/xcursor.zig @@ -7,6 +7,13 @@ pub const XcursorImage = extern struct { hotspot_y: u32, delay: u32, buffer: [*]u8, + + private: extern struct { + readonly_buffer: ?*wlr.ReadonlyDataBuffer, + }, + + extern fn wlr_xcursor_image_get_buffer(image: *XcursorImage) *wlr.Buffer; + pub const getBuffer = wlr_xcursor_image_get_buffer; }; pub const Xcursor = extern struct { diff --git a/src/xwayland/xwayland.zig b/src/xwayland/xwayland.zig index 52db9d8..e0b3a50 100644 --- a/src/xwayland/xwayland.zig +++ b/src/xwayland/xwayland.zig @@ -86,7 +86,6 @@ const xcb = struct { }; pub const Xwm = opaque {}; -pub const XwaylandCursor = opaque {}; pub const Xwayland = extern struct { pub const event = struct { @@ -101,7 +100,6 @@ pub const Xwayland = extern struct { own_server: bool, xwm: ?*Xwm, shell_v1: *wlr.XwaylandShellV1, - cursor: ?*XwaylandCursor, display_name: [*:0]const u8, @@ -121,6 +119,12 @@ pub const Xwayland = extern struct { data: ?*anyopaque, private: extern struct { + cursor_buffer: ?*wlr.Buffer, + cursor_hotspot: extern struct { + x: i32, + y: i32, + }, + server_start: wl.Listener(void), server_ready: wl.Listener(void), server_destroy: wl.Listener(void), @@ -141,7 +145,7 @@ pub const Xwayland = extern struct { extern fn wlr_xwayland_destroy(wlr_xwayland: *Xwayland) void; pub const destroy = wlr_xwayland_destroy; - extern fn wlr_xwayland_set_cursor(wlr_xwayland: *Xwayland, pixels: [*]u8, stride: u32, width: u32, height: u32, hotspot_x: i32, hotspot_y: i32) void; + extern fn wlr_xwayland_set_cursor(wlr_xwayland: *Xwayland, buffer: *wlr.Buffer, hotspot_x: i32, hotspot_y: i32) void; pub const setCursor = wlr_xwayland_set_cursor; extern fn wlr_xwayland_set_seat(xwayland: *Xwayland, seat: *wlr.Seat) void; @@ -209,7 +213,6 @@ pub const XwaylandSurface = extern struct { role: ?[*:0]u8, startup_id: ?[*:0]u8, pid: posix.pid_t, - has_utf8_title: bool, children: wl.list.Head(XwaylandSurface, .parent_link), parent: ?*XwaylandSurface, @@ -274,11 +277,13 @@ pub const XwaylandSurface = extern struct { set_startup_id: wl.Signal(void), set_window_type: wl.Signal(void), set_hints: wl.Signal(void), + set_size_hints: wl.Signal(void), set_decorations: wl.Signal(void), set_strut_partial: wl.Signal(void), set_override_redirect: wl.Signal(void), set_geometry: wl.Signal(void), set_opacity: wl.Signal(void), + set_icon: wl.Signal(void), focus_in: wl.Signal(void), grab_focus: wl.Signal(void), diff --git a/tinywl/build.zig b/tinywl/build.zig index ee6b01b..5ebf22e 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -37,7 +37,7 @@ pub fn build(b: *std.Build) void { // exposed to the wlroots module for @cImport() to work. This seems to be // the best way to do so with the current std.Build API. wlroots.resolved_target = target; - wlroots.linkSystemLibrary("wlroots-0.19", .{}); + wlroots.linkSystemLibrary("wlroots-0.20", .{}); const tinywl = b.addExecutable(.{ .name = "tinywl", From 149c17476ccec90b9904d6a1a8d38858d4ac925f Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 28 Mar 2026 10:59:20 +0100 Subject: [PATCH 27/54] InputMethodV2: fix type of keyboard grab destroy signal wlroots didn't mention this breaking change in the changelog :/ --- src/types/input_method_v2.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/input_method_v2.zig b/src/types/input_method_v2.zig index a02347e..196879d 100644 --- a/src/types/input_method_v2.zig +++ b/src/types/input_method_v2.zig @@ -46,7 +46,7 @@ pub const InputMethodV2 = extern struct { keyboard: ?*wlr.Keyboard, events: extern struct { - destroy: wl.Signal(*wlr.InputMethodV2.KeyboardGrab), + destroy: wl.Signal(void), }, private: extern struct { From 387ef3d4d23ab532264c26dda0e658b6e3668c11 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Sat, 28 Mar 2026 09:25:07 +0100 Subject: [PATCH 28/54] ExtImageCaptureSourceV1: add toOutput() --- src/types/ext_image_capture_source_v1.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig index 9aeda94..90990a3 100644 --- a/src/types/ext_image_capture_source_v1.zig +++ b/src/types/ext_image_capture_source_v1.zig @@ -88,6 +88,9 @@ pub const ExtImageCaptureSourceV1 = extern struct { extern fn wlr_ext_image_capture_source_v1_cursor_finish(source_cursor: *Cursor) void; pub const finish = wlr_ext_image_capture_source_v1_cursor_finish; }; + + extern fn wlr_output_try_from_ext_image_capture_source_v1(source: *ExtImageCaptureSourceV1) ?*wlr.Output; + pub const toOutput = wlr_output_try_from_ext_image_capture_source_v1; }; pub const ExtOutputImageCaptureSourceManagerV1 = extern struct { From c1985f82d89867c5693713f9d0481a747dd075d3 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Sun, 6 Jul 2025 21:22:58 +0200 Subject: [PATCH 29/54] ext-image-capture-source-v1: add toplevel capture --- src/types/ext_image_capture_source_v1.zig | 62 +++++++++++++++++++++++ src/wlroots.zig | 2 + 2 files changed, 64 insertions(+) diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig index 90990a3..8dc71fe 100644 --- a/src/types/ext_image_capture_source_v1.zig +++ b/src/types/ext_image_capture_source_v1.zig @@ -91,6 +91,26 @@ pub const ExtImageCaptureSourceV1 = extern struct { extern fn wlr_output_try_from_ext_image_capture_source_v1(source: *ExtImageCaptureSourceV1) ?*wlr.Output; pub const toOutput = wlr_output_try_from_ext_image_capture_source_v1; + + extern fn wlr_ext_image_capture_source_v1_create_with_scene_node( + node: *wlr.SceneNode, + event_loop: *wl.EventLoop, + allocator: *wlr.Allocator, + renderer: *wlr.Renderer, + ) ?*ExtImageCaptureSourceV1; + pub fn createWithSceneNode( + node: *wlr.SceneNode, + event_loop: *wl.EventLoop, + allocator: *wlr.Allocator, + renderer: *wlr.Renderer, + ) !*ExtImageCaptureSourceV1 { + return wlr_ext_image_capture_source_v1_create_with_scene_node( + node, + event_loop, + allocator, + renderer, + ) orelse error.OutOfMemory; + } }; pub const ExtOutputImageCaptureSourceManagerV1 = extern struct { @@ -108,3 +128,45 @@ pub const ExtOutputImageCaptureSourceManagerV1 = extern struct { return wlr_ext_output_image_capture_source_manager_v1_create(display, version) orelse error.OutOfMemory; } }; + +pub const ExtForeignToplevelImageCaptureSourceManagerV1 = extern struct { + global: *wl.Global, + + events: extern struct { + destroy: wl.Signal(void), + new_request: wl.Signal(*ExtForeignToplevelImageCaptureSourceManagerV1Request), + }, + + private: extern struct { + display_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create( + display: *wl.Server, + version: u32, + ) ?*ExtForeignToplevelImageCaptureSourceManagerV1; + pub fn create( + display: *wl.Server, + version: u32, + ) !*ExtForeignToplevelImageCaptureSourceManagerV1 { + return wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create( + display, + version, + ) orelse error.OutOfMemory; + } +}; + +pub const ExtForeignToplevelImageCaptureSourceManagerV1Request = extern struct { + toplevel_handle: *wlr.ExtForeignToplevelHandleV1, + client: *wl.Client, + + private: extern struct { + new_id: u32, + }, + + extern fn wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept( + request: *ExtForeignToplevelImageCaptureSourceManagerV1Request, + source: *ExtImageCaptureSourceV1, + ) bool; + pub const accept = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index de5a988..b5ca3ae 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -213,6 +213,8 @@ pub const ExtForeignToplevelHandleV1 = @import("types/foreign_toplevel_list_v1.z pub const ExtImageCaptureSourceV1 = @import("types/ext_image_capture_source_v1.zig").ExtImageCaptureSourceV1; pub const ExtOutputImageCaptureSourceManagerV1 = @import("types/ext_image_capture_source_v1.zig").ExtOutputImageCaptureSourceManagerV1; +pub const ExtForeignToplevelImageCaptureSourceManagerV1 = @import("types/ext_image_capture_source_v1.zig").ExtForeignToplevelImageCaptureSourceManagerV1; +pub const ExtForeignToplevelImageCaptureSourceManagerV1Request = @import("types/ext_image_capture_source_v1.zig").ExtForeignToplevelImageCaptureSourceManagerV1Request; pub const ExtImageCopyCaptureManagerV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureManagerV1; pub const ExtImageCopyCaptureFrameV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1; From 1c4e26d07991e080539736887edb46716fec6134 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Sun, 6 Jul 2025 21:23:33 +0200 Subject: [PATCH 30/54] scene: bind missing function --- src/types/scene.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/scene.zig b/src/types/scene.zig index a87c776..2a6bcdd 100644 --- a/src/types/scene.zig +++ b/src/types/scene.zig @@ -211,6 +211,9 @@ pub const SceneSurface = extern struct { extern fn wlr_scene_surface_try_from_buffer(buffer: *SceneBuffer) ?*SceneSurface; pub const tryFromBuffer = wlr_scene_surface_try_from_buffer; + + extern fn wlr_scene_surface_send_frame_done(scene_surface: *SceneSurface, when: *const posix.timespec) void; + pub const sendFrameDone = wlr_scene_surface_send_frame_done; }; pub const SceneRect = extern struct { From fd67681709e4bdd19eb9b2e738497105db67ff86 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 28 Mar 2026 11:18:28 +0100 Subject: [PATCH 31/54] ext-image-capture-source-v1: minor cleanup --- src/types/ext_image_capture_source_v1.zig | 49 +++++++++++------------ src/wlroots.zig | 1 - 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/types/ext_image_capture_source_v1.zig b/src/types/ext_image_capture_source_v1.zig index 8dc71fe..203ae4f 100644 --- a/src/types/ext_image_capture_source_v1.zig +++ b/src/types/ext_image_capture_source_v1.zig @@ -121,52 +121,49 @@ pub const ExtOutputImageCaptureSourceManagerV1 = extern struct { }, extern fn wlr_ext_output_image_capture_source_manager_v1_create( - display: *wl.Server, + server: *wl.Server, version: u32, ) ?*ExtOutputImageCaptureSourceManagerV1; - pub fn create(display: *wl.Server, version: u32) !*ExtOutputImageCaptureSourceManagerV1 { - return wlr_ext_output_image_capture_source_manager_v1_create(display, version) orelse error.OutOfMemory; + pub fn create(server: *wl.Server, version: u32) !*ExtOutputImageCaptureSourceManagerV1 { + return wlr_ext_output_image_capture_source_manager_v1_create(server, version) orelse error.OutOfMemory; } }; pub const ExtForeignToplevelImageCaptureSourceManagerV1 = extern struct { + pub const Request = extern struct { + toplevel_handle: *wlr.ExtForeignToplevelHandleV1, + client: *wl.Client, + + private: extern struct { + new_id: u32, + }, + + extern fn wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept( + request: *Request, + source: *ExtImageCaptureSourceV1, + ) bool; + pub const accept = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept; + }; + global: *wl.Global, events: extern struct { destroy: wl.Signal(void), - new_request: wl.Signal(*ExtForeignToplevelImageCaptureSourceManagerV1Request), + new_request: wl.Signal(*Request), }, private: extern struct { - display_destroy: wl.Listener(void), + server_destroy: wl.Listener(void), }, extern fn wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create( - display: *wl.Server, + server: *wl.Server, version: u32, ) ?*ExtForeignToplevelImageCaptureSourceManagerV1; - pub fn create( - display: *wl.Server, - version: u32, - ) !*ExtForeignToplevelImageCaptureSourceManagerV1 { + pub fn create(server: *wl.Server, version: u32) !*ExtForeignToplevelImageCaptureSourceManagerV1 { return wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create( - display, + server, version, ) orelse error.OutOfMemory; } }; - -pub const ExtForeignToplevelImageCaptureSourceManagerV1Request = extern struct { - toplevel_handle: *wlr.ExtForeignToplevelHandleV1, - client: *wl.Client, - - private: extern struct { - new_id: u32, - }, - - extern fn wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept( - request: *ExtForeignToplevelImageCaptureSourceManagerV1Request, - source: *ExtImageCaptureSourceV1, - ) bool; - pub const accept = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept; -}; diff --git a/src/wlroots.zig b/src/wlroots.zig index b5ca3ae..59b17fe 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -214,7 +214,6 @@ pub const ExtForeignToplevelHandleV1 = @import("types/foreign_toplevel_list_v1.z pub const ExtImageCaptureSourceV1 = @import("types/ext_image_capture_source_v1.zig").ExtImageCaptureSourceV1; pub const ExtOutputImageCaptureSourceManagerV1 = @import("types/ext_image_capture_source_v1.zig").ExtOutputImageCaptureSourceManagerV1; pub const ExtForeignToplevelImageCaptureSourceManagerV1 = @import("types/ext_image_capture_source_v1.zig").ExtForeignToplevelImageCaptureSourceManagerV1; -pub const ExtForeignToplevelImageCaptureSourceManagerV1Request = @import("types/ext_image_capture_source_v1.zig").ExtForeignToplevelImageCaptureSourceManagerV1Request; pub const ExtImageCopyCaptureManagerV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureManagerV1; pub const ExtImageCopyCaptureFrameV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1; From 22180881fd3f67b2449a34dd7dd978c3291ccc15 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 18:16:49 +0200 Subject: [PATCH 32/54] wl_fixes: add bindings --- src/types/fixes.zig | 21 +++++++++++++++++++++ src/wlroots.zig | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 src/types/fixes.zig diff --git a/src/types/fixes.zig b/src/types/fixes.zig new file mode 100644 index 0000000..0e9b63b --- /dev/null +++ b/src/types/fixes.zig @@ -0,0 +1,21 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; + +pub const Fixes = extern struct { + global: *wl.Global, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_fixes_create(server: *wl.Server, version: u32) ?*Fixes; + pub fn create(server: *wl.Server, version: u32) error{OutOfMemory}!*Fixes { + return wlr_fixes_create(server, version) orelse error.OutOfMemory; + } +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 59b17fe..1a5bbac 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -234,6 +234,8 @@ pub const SceneOutputLayout = @import("types/scene.zig").SceneOutputLayout; pub const SceneTimer = @import("types/scene.zig").SceneTimer; pub const SceneLayerSurfaceV1 = @import("types/scene.zig").SceneLayerSurfaceV1; +pub const Fixes = @import("types/fixes.zig").Fixes; + pub const config = @import("config.zig"); pub const version = @import("version.zig"); From 1cd9a8697b8a38fa4dd6769ae1fa7ba9ed970d4f Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 18:51:52 +0200 Subject: [PATCH 33/54] color-management: add bindings --- build.zig | 2 + src/render/renderer.zig | 7 ++++ src/types/color_management_v1.zig | 61 +++++++++++++++++++++++++++++++ src/types/scene.zig | 3 ++ src/wlroots.zig | 4 +- 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/types/color_management_v1.zig diff --git a/build.zig b/build.zig index 9789e84..0ca3949 100644 --- a/build.zig +++ b/build.zig @@ -28,6 +28,7 @@ pub fn build(b: *std.Build) void { scanner.addSystemProtocol("staging/tearing-control/tearing-control-v1.xml"); scanner.addSystemProtocol("staging/content-type/content-type-v1.xml"); scanner.addSystemProtocol("staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml"); + scanner.addSystemProtocol("staging/color-management/color-management-v1.xml"); scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); @@ -56,6 +57,7 @@ pub fn build(b: *std.Build) void { scanner.generate("wp_cursor_shape_manager_v1", 1); scanner.generate("wp_tearing_control_manager_v1", 1); scanner.generate("wp_content_type_manager_v1", 1); + scanner.generate("wp_color_manager_v1", 2); scanner.generate("zwlr_layer_shell_v1", 4); scanner.generate("zwlr_output_power_manager_v1", 1); diff --git a/src/render/renderer.zig b/src/render/renderer.zig index 0d0dd92..2fdde72 100644 --- a/src/render/renderer.zig +++ b/src/render/renderer.zig @@ -2,6 +2,7 @@ const wlr = @import("../wlroots.zig"); const wayland = @import("wayland"); const wl = wayland.server.wl; +const wp = wayland.server.wp; const pixman = @import("pixman"); @@ -86,6 +87,12 @@ pub const Renderer = extern struct { extern fn wlr_gles2_renderer_get_buffer_fbo(renderer: *Renderer, buffer: *wlr.Buffer) c_uint; pub const gles2GetBufferFbo = wlr_gles2_renderer_get_buffer_fbo; + + extern fn wlr_color_manager_v1_transfer_function_list_from_renderer(renderer: *Renderer, len: *usize) ?[*]wp.ColorManagerV1.TransferFunction; + pub const transferFunctionList = wlr_color_manager_v1_transfer_function_list_from_renderer; + + extern fn wlr_color_manager_v1_primaries_list_from_renderer(renderer: *Renderer, len: *usize) ?[*]wp.ColorManagerV1.Primaries; + pub const primariesList = wlr_color_manager_v1_primaries_list_from_renderer; }; pub const RenderTimer = opaque { diff --git a/src/types/color_management_v1.zig b/src/types/color_management_v1.zig new file mode 100644 index 0000000..315a415 --- /dev/null +++ b/src/types/color_management_v1.zig @@ -0,0 +1,61 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const wp = wayland.server.wp; + +pub const ColorManagerV1 = extern struct { + pub const Features = extern struct { + icc_v2_v4: bool, + parametric: bool, + set_primaries: bool, + set_tf_power: bool, + set_luminances: bool, + set_mastering_display_primaries: bool, + extended_target_volume: bool, + windows_scrgb: bool, + }; + + pub const Options = extern struct { + features: Features, + render_intents: ?[*]const wp.ColorManagerV1.RenderIntent, + render_intents_len: usize, + transfer_functions: ?[*]const wp.ColorManagerV1.TransferFunction, + transfer_functions_len: usize, + primaries: ?[*]const wp.ColorManagerV1.Primaries, + primaries_len: usize, + }; + + global: *wl.Global, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + features: Features, + render_intents: ?[*]const wp.ColorManagerV1.RenderIntent, + render_intents_len: usize, + transfer_functions: ?[*]const wp.ColorManagerV1.TransferFunction, + transfer_functions_len: usize, + primaries: ?[*]const wp.ColorManagerV1.Primaries, + primaries_len: usize, + outputs: wl.list.Link, + surface_feedbacks: wl.list.Link, + last_image_desc_identity: u64, + server_destroy: wl.Listener(void), + }, + + extern fn wlr_color_manager_v1_create( + server: *wl.Server, + version: u32, + options: *const Options, + ) ?*ColorManagerV1; + pub fn create( + server: *wl.Server, + version: u32, + options: *const Options, + ) error{ColorManagerV1CreateFailed}!*ColorManagerV1 { + return wlr_color_manager_v1_create(server, version, options) orelse error.ColorManagerV1CreateFailed; + } +}; diff --git a/src/types/scene.zig b/src/types/scene.zig index 2a6bcdd..9d2e2b6 100644 --- a/src/types/scene.zig +++ b/src/types/scene.zig @@ -183,6 +183,9 @@ pub const Scene = extern struct { extern fn wlr_scene_set_gamma_control_manager_v1(scene: *Scene, gamma_control: *wlr.GammaControlManagerV1) void; pub const setGammaControlManagerV1 = wlr_scene_set_gamma_control_manager_v1; + extern fn wlr_scene_set_color_manager_v1(scene: *Scene, manager: *wlr.ColorManagerV1) void; + pub const setColorManagerV1 = wlr_scene_set_color_manager_v1; + extern fn wlr_scene_output_create(scene: *Scene, output: *wlr.Output) ?*SceneOutput; pub fn createSceneOutput(scene: *Scene, output: *wlr.Output) !*SceneOutput { return wlr_scene_output_create(scene, output) orelse error.OutOfMemory; diff --git a/src/wlroots.zig b/src/wlroots.zig index 1a5bbac..38fb1f1 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -18,8 +18,8 @@ pub const DrmFormatSet = @import("render/drm_format_set.zig").DrmFormatSet; pub const color = @import("render/color.zig"); -pub const ColorTransform = opaque {}; // TODO -pub const ColorManagerV1 = opaque {}; // TODO +pub const ColorTransform = opaque {}; +pub const ColorManagerV1 = @import("types/color_management_v1.zig"); pub const Drm = @import("types/drm.zig").Drm; From 2e048df756dbf0b5d5bb9f4c3ccf33f25cc80de6 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:05:46 +0200 Subject: [PATCH 34/54] color-representation: add bindings --- build.zig | 2 ++ src/types/color_representation_v1.zig | 43 +++++++++++++++++++++++++++ src/wlroots.zig | 1 + 3 files changed, 46 insertions(+) create mode 100644 src/types/color_representation_v1.zig diff --git a/build.zig b/build.zig index 0ca3949..d3b685e 100644 --- a/build.zig +++ b/build.zig @@ -29,6 +29,7 @@ pub fn build(b: *std.Build) void { scanner.addSystemProtocol("staging/content-type/content-type-v1.xml"); scanner.addSystemProtocol("staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml"); scanner.addSystemProtocol("staging/color-management/color-management-v1.xml"); + scanner.addSystemProtocol("staging/color-representation/color-representation-v1.xml"); scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); @@ -58,6 +59,7 @@ pub fn build(b: *std.Build) void { scanner.generate("wp_tearing_control_manager_v1", 1); scanner.generate("wp_content_type_manager_v1", 1); scanner.generate("wp_color_manager_v1", 2); + scanner.generate("wp_color_representation_manager_v1", 1); scanner.generate("zwlr_layer_shell_v1", 4); scanner.generate("zwlr_output_power_manager_v1", 1); diff --git a/src/types/color_representation_v1.zig b/src/types/color_representation_v1.zig new file mode 100644 index 0000000..53fc08b --- /dev/null +++ b/src/types/color_representation_v1.zig @@ -0,0 +1,43 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const wp = wayland.server.wp; + +pub const ColorRepresentationManagerV1 = extern struct { + pub const CoeffsAndRange = extern struct { + coeffs: wp.ColorRepresentationSurfaceV1.Coefficients, + range: wp.ColorRepresentationSurfaceV1.Range, + }; + + pub const Options = extern struct { + supported_alpha_modes: ?[*]const wp.ColorRepresentationSurfaceV1.AlphaMode, + supported_alpha_modes_len: usize, + supported_coeffs_and_ranges: ?[*]const CoeffsAndRange, + supported_coeffs_and_ranges_len: usize, + }; + + global: *wl.Global, + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + supported_alpha_modes: ?[*]wp.ColorRepresentationSurfaceV1.AlphaMode, + supported_alpha_modes_len: usize, + supported_coeffs_and_ranges: ?[*]CoeffsAndRange, + supported_coeffs_and_ranges_len: usize, + display_destroy: wl.Listener(void), + }, + + extern fn wlr_color_representation_manager_v1_create(server: *wl.Server, version: u32, options: *const Options) ?*ColorRepresentationManagerV1; + pub fn create(server: *wl.Server, version: u32, options: *const Options) error{ColorRepresentationManagerV1CreateFailed}!*ColorRepresentationManagerV1 { + return wlr_color_representation_manager_v1_create(server, version, options) orelse error.ColorRepresentationManagerV1CreateFailed; + } + + extern fn wlr_color_representation_manager_v1_create_with_renderer(server: *wl.Server, version: u32, renderer: wlr.Renderer) ?*ColorRepresentationManagerV1; + pub fn createWithRenderer(server: *wl.Server, version: u32, renderer: wlr.Renderer) error{ColorRepresentationManagerV1CreateFailed}!*ColorRepresentationManagerV1 { + return wlr_color_representation_manager_v1_create_with_renderer(server, version, renderer) orelse error.ColorRepresentationManagerV1CreateFailed; + } +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 38fb1f1..aa6451c 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -20,6 +20,7 @@ pub const color = @import("render/color.zig"); pub const ColorTransform = opaque {}; pub const ColorManagerV1 = @import("types/color_management_v1.zig"); +pub const ColorRepresentationManagerV1 = @import("types/color_representation_v1.zig"); pub const Drm = @import("types/drm.zig").Drm; From bb4697de24d36bbef93c5aa743bc8bd46f36f784 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:13:11 +0200 Subject: [PATCH 35/54] Renderer: improve ergonomics --- src/render/renderer.zig | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/render/renderer.zig b/src/render/renderer.zig index 2fdde72..a8426cc 100644 --- a/src/render/renderer.zig +++ b/src/render/renderer.zig @@ -89,10 +89,20 @@ pub const Renderer = extern struct { pub const gles2GetBufferFbo = wlr_gles2_renderer_get_buffer_fbo; extern fn wlr_color_manager_v1_transfer_function_list_from_renderer(renderer: *Renderer, len: *usize) ?[*]wp.ColorManagerV1.TransferFunction; - pub const transferFunctionList = wlr_color_manager_v1_transfer_function_list_from_renderer; + /// Caller must free returned slice with std.c.free() + pub fn transferFunctionList(renderer: *Renderer) []wp.ColorManagerV1.TransferFunction { + var len: usize = 0; + const ptr = wlr_color_manager_v1_transfer_function_list_from_renderer(renderer, &len) orelse return &.{}; + return ptr[0..len]; + } extern fn wlr_color_manager_v1_primaries_list_from_renderer(renderer: *Renderer, len: *usize) ?[*]wp.ColorManagerV1.Primaries; - pub const primariesList = wlr_color_manager_v1_primaries_list_from_renderer; + /// Caller must free returned slice with std.c.free() + pub fn primariesList(renderer: *Renderer) []wp.ColorManagerV1.Primaries { + var len: usize = 0; + const ptr = wlr_color_manager_v1_primaries_list_from_renderer(renderer, &len) orelse return &.{}; + return ptr[0..len]; + } }; pub const RenderTimer = opaque { From 39a9ef5108b7ae4adb18a164464007d6166aa7f9 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:17:37 +0200 Subject: [PATCH 36/54] color-management: fix namespacing --- src/wlroots.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wlroots.zig b/src/wlroots.zig index aa6451c..b7448f8 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -19,8 +19,8 @@ pub const DrmFormatSet = @import("render/drm_format_set.zig").DrmFormatSet; pub const color = @import("render/color.zig"); pub const ColorTransform = opaque {}; -pub const ColorManagerV1 = @import("types/color_management_v1.zig"); -pub const ColorRepresentationManagerV1 = @import("types/color_representation_v1.zig"); +pub const ColorManagerV1 = @import("types/color_management_v1.zig").ColorManagerV1; +pub const ColorRepresentationManagerV1 = @import("types/color_representation_v1.zig").ColorRepresentationManagerV1; pub const Drm = @import("types/drm.zig").Drm; From 1c20960ae4edf39b7ff63e273e2785a6ec0b1297 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:25:08 +0200 Subject: [PATCH 37/54] color-management: more ergonomic create() --- src/types/color_management_v1.zig | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/types/color_management_v1.zig b/src/types/color_management_v1.zig index 315a415..d8acec4 100644 --- a/src/types/color_management_v1.zig +++ b/src/types/color_management_v1.zig @@ -54,8 +54,21 @@ pub const ColorManagerV1 = extern struct { pub fn create( server: *wl.Server, version: u32, - options: *const Options, + options: struct { + features: Features, + render_intents: []const wp.ColorManagerV1.RenderIntent, + transfer_functions: []const wp.ColorManagerV1.TransferFunction, + primaries: []const wp.ColorManagerV1.Primaries, + }, ) error{ColorManagerV1CreateFailed}!*ColorManagerV1 { - return wlr_color_manager_v1_create(server, version, options) orelse error.ColorManagerV1CreateFailed; + return wlr_color_manager_v1_create(server, version, &.{ + .features = options.features, + .render_intents = options.render_intents.ptr, + .render_intents_len = options.render_intents.len, + .transfer_functions = options.transfer_functions.ptr, + .transfer_functions_len = options.transfer_functions.len, + .primaries = options.primaries.ptr, + .primaries_len = options.primaries.len, + }) orelse error.ColorManagerV1CreateFailed; } }; From 6801bf31542a58c20a084cefbc6a9485a3811c42 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:27:14 +0200 Subject: [PATCH 38/54] color-management: Features default field values --- src/types/color_management_v1.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/types/color_management_v1.zig b/src/types/color_management_v1.zig index d8acec4..b7b6ac2 100644 --- a/src/types/color_management_v1.zig +++ b/src/types/color_management_v1.zig @@ -6,14 +6,14 @@ const wp = wayland.server.wp; pub const ColorManagerV1 = extern struct { pub const Features = extern struct { - icc_v2_v4: bool, - parametric: bool, - set_primaries: bool, - set_tf_power: bool, - set_luminances: bool, - set_mastering_display_primaries: bool, - extended_target_volume: bool, - windows_scrgb: bool, + icc_v2_v4: bool = false, + parametric: bool = false, + set_primaries: bool = false, + set_tf_power: bool = false, + set_luminances: bool = false, + set_mastering_display_primaries: bool = false, + extended_target_volume: bool = false, + windows_scrgb: bool = false, }; pub const Options = extern struct { From eb7631742812665c10ff3a9b4b069c3d0cc2017b Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sun, 29 Mar 2026 19:29:59 +0200 Subject: [PATCH 39/54] color-representation: fix createWithRenderer() --- src/types/color_representation_v1.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/color_representation_v1.zig b/src/types/color_representation_v1.zig index 53fc08b..8604900 100644 --- a/src/types/color_representation_v1.zig +++ b/src/types/color_representation_v1.zig @@ -36,8 +36,8 @@ pub const ColorRepresentationManagerV1 = extern struct { return wlr_color_representation_manager_v1_create(server, version, options) orelse error.ColorRepresentationManagerV1CreateFailed; } - extern fn wlr_color_representation_manager_v1_create_with_renderer(server: *wl.Server, version: u32, renderer: wlr.Renderer) ?*ColorRepresentationManagerV1; - pub fn createWithRenderer(server: *wl.Server, version: u32, renderer: wlr.Renderer) error{ColorRepresentationManagerV1CreateFailed}!*ColorRepresentationManagerV1 { + extern fn wlr_color_representation_manager_v1_create_with_renderer(server: *wl.Server, version: u32, renderer: *wlr.Renderer) ?*ColorRepresentationManagerV1; + pub fn createWithRenderer(server: *wl.Server, version: u32, renderer: *wlr.Renderer) error{ColorRepresentationManagerV1CreateFailed}!*ColorRepresentationManagerV1 { return wlr_color_representation_manager_v1_create_with_renderer(server, version, renderer) orelse error.ColorRepresentationManagerV1CreateFailed; } }; From b149cb02e042004c3c9bc788b25cb5b2ffabe1ec Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 30 Mar 2026 13:42:59 +0200 Subject: [PATCH 40/54] Keyboard: fix led_update callconv --- src/types/keyboard.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/keyboard.zig b/src/types/keyboard.zig index 1543af0..ed8ba07 100644 --- a/src/types/keyboard.zig +++ b/src/types/keyboard.zig @@ -48,7 +48,7 @@ pub const Keyboard = extern struct { const Impl = extern struct { name: [*:0]const u8, - led_update: ?*const fn (keyboard: *Keyboard, leds: u32) void, + led_update: ?*const fn (keyboard: *Keyboard, leds: u32) callconv(.c) void, }; base: wlr.InputDevice, From ed377c27fab58ef579c5603f5e03e778dfd73018 Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Mon, 30 Mar 2026 13:24:10 +0200 Subject: [PATCH 41/54] wlroots.zig: expose ExtImageCopyCaptureSessionV1 --- src/wlroots.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wlroots.zig b/src/wlroots.zig index b7448f8..26f580e 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -218,6 +218,7 @@ pub const ExtForeignToplevelImageCaptureSourceManagerV1 = @import("types/ext_ima pub const ExtImageCopyCaptureManagerV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureManagerV1; pub const ExtImageCopyCaptureFrameV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1; +pub const ExtImageCopyCaptureSessionV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureSessionV1; pub const SecurityContextManagerV1 = @import("types/security_context_v1.zig").SecurityContextManagerV1; pub const SecurityContextV1State = @import("types/security_context_v1.zig").SecurityContextV1State; From b2b8850d1828c25bdb8fa5ba72829e98e02c7f12 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 30 Mar 2026 13:46:33 +0200 Subject: [PATCH 42/54] tinywl: fix build --- tinywl/build.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tinywl/build.zig b/tinywl/build.zig index 5ebf22e..9a83f31 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -9,6 +9,7 @@ pub fn build(b: *std.Build) void { const scanner = Scanner.create(b, .{}); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); scanner.addSystemProtocol("stable/tablet/tablet-v2.xml"); + scanner.addSystemProtocol("staging/color-management/color-management-v1.xml"); // Some of these versions may be out of date with what wlroots implements. // This is not a problem in practice though as long as tinywl successfully compiles. @@ -23,6 +24,7 @@ pub fn build(b: *std.Build) void { scanner.generate("wl_data_device_manager", 3); scanner.generate("xdg_wm_base", 2); scanner.generate("zwp_tablet_manager_v2", 1); + scanner.generate("wp_color_manager_v1", 2); const wayland = b.createModule(.{ .root_source_file = scanner.result }); const xkbcommon = b.dependency("xkbcommon", .{}).module("xkbcommon"); From a9fa805d4c7c7cc51a0de8f14bf7a16889ca53a6 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 31 Mar 2026 10:03:03 +0200 Subject: [PATCH 43/54] build: bump version to 0.20.0 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 504ba1b..311d829 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.20.0-dev", + .version = "0.20.0", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 02c4efe9568901fa96b7a1827d419eda5614a86d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 31 Mar 2026 10:05:49 +0200 Subject: [PATCH 44/54] build: bump version to 0.21.0-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 311d829..54158ac 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.20.0", + .version = "0.21.0-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 27e61303706675cd8d1fad9991da596e49a144fb Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 25 Apr 2026 12:53:00 +0200 Subject: [PATCH 45/54] build: update to Zig 0.16 --- .builds/alpine.yml | 8 ++++---- .builds/archlinux.yml | 8 ++++---- .builds/freebsd.yml | 8 ++++---- .gitignore | 1 + README.md | 2 +- build.zig | 11 +++++------ build.zig.zon | 4 ++-- src/wlroots.zig | 17 +++++++++++++++-- tinywl/build.zig | 9 ++++----- tinywl/build.zig.zon | 4 ++-- tinywl/tinywl.zig | 27 +++++++++++++++++++-------- 11 files changed, 61 insertions(+), 38 deletions(-) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index f565f3b..b8eecdf 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -37,10 +37,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz - tar xf zig-x86_64-linux-0.15.1.tar.xz - sudo mv zig-x86_64-linux-0.15.1/zig /usr/bin/ - sudo mv zig-x86_64-linux-0.15.1/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz + tar xf zig-x86_64-linux-0.16.0.tar.xz + sudo mv zig-x86_64-linux-0.16.0/zig /usr/bin/ + sudo mv zig-x86_64-linux-0.16.0/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index 863e09c..ad57693 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -34,10 +34,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-linux-0.15.1.tar.xz - tar xf zig-x86_64-linux-0.15.1.tar.xz - sudo mv zig-x86_64-linux-0.15.1/zig /usr/bin/ - sudo mv zig-x86_64-linux-0.15.1/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz + tar xf zig-x86_64-linux-0.16.0.tar.xz + sudo mv zig-x86_64-linux-0.16.0/zig /usr/bin/ + sudo mv zig-x86_64-linux-0.16.0/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index f3423f9..c638f22 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -41,10 +41,10 @@ tasks: cd .. # Eat Github's resources rather than the Zig Software Foundation's resources! - wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.15.1/zig-x86_64-freebsd-0.15.1.tar.xz - tar xf zig-x86_64-freebsd-0.15.1.tar.xz - sudo mv zig-x86_64-freebsd-0.15.1/zig /usr/bin/ - sudo mv zig-x86_64-freebsd-0.15.1/lib /usr/lib/zig + wget -nv https://github.com/ifreund/zig-tarball-mirror/releases/download/0.16.0/zig-x86_64-freebsd-0.16.0.tar.xz + tar xf zig-x86_64-freebsd-0.16.0.tar.xz + sudo mv zig-x86_64-freebsd-0.16.0/zig /usr/bin/ + sudo mv zig-x86_64-freebsd-0.16.0/lib /usr/lib/zig - test: | cd zig-wlroots zig build -Denable-tests test --summary all diff --git a/.gitignore b/.gitignore index 19892e4..ded0a60 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .zig-cache +zig-pkg diff --git a/README.md b/README.md index 6952614..b93edb4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ request on [codeberg](https://codeberg.org/ifreund/zig-wlroots). ## Dependencies -- [zig](https://ziglang.org/) 0.15 +- [zig](https://ziglang.org/) 0.16 - [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.20 - [zig-wayland](https://codeberg.org/ifreund/zig-wayland) - [zig-xkbcommon](https://codeberg.org/ifreund/zig-xkbcommon) diff --git a/build.zig b/build.zig index d3b685e..57618bc 100644 --- a/build.zig +++ b/build.zig @@ -73,21 +73,20 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/wlroots.zig"), .target = target, .optimize = optimize, + .link_libc = true, }), }); - wlr_test.linkLibC(); - wlr_test.root_module.addImport("wayland", wayland); - wlr_test.linkSystemLibrary("wayland-server"); + wlr_test.root_module.linkSystemLibrary("wayland-server", .{}); wlr_test.root_module.addImport("xkbcommon", xkbcommon); - wlr_test.linkSystemLibrary("xkbcommon"); + wlr_test.root_module.linkSystemLibrary("xkbcommon", .{}); wlr_test.root_module.addImport("pixman", pixman); - wlr_test.linkSystemLibrary("pixman-1"); + wlr_test.root_module.linkSystemLibrary("pixman-1", .{}); - wlr_test.linkSystemLibrary("wlroots-0.20"); + wlr_test.root_module.linkSystemLibrary("wlroots-0.20", .{}); const test_step = b.step("test", "Run the tests"); test_step.dependOn(&wlr_test.step); diff --git a/build.zig.zon b/build.zig.zon index 54158ac..7c2e6bc 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,8 +15,8 @@ .lazy = true, }, .wayland = .{ - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz", - .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.6.0.tar.gz", + .hash = "wayland-0.6.0-lQa1kqz8AQADQmdNJsNhLoNHcnEGEUjrOaPV-dtEnEmX", .lazy = true, }, .xkbcommon = .{ diff --git a/src/wlroots.zig b/src/wlroots.zig index 26f580e..8196322 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -246,8 +246,21 @@ comptime { @compileError("zig-wlroots requires wlroots version 0.20, found version " ++ version.str); } } + test { - const std = @import("std"); @setEvalBranchQuota(100000); - std.testing.refAllDeclsRecursive(@This()); + refAllDeclsRecursive(@This()); +} + +fn refAllDeclsRecursive(comptime T: type) void { + const std = @import("std"); + inline for (comptime std.meta.declarations(T)) |decl| { + if (@TypeOf(@field(T, decl.name)) == type) { + switch (@typeInfo(@field(T, decl.name))) { + .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)), + else => {}, + } + } + _ = &@field(T, decl.name); + } } diff --git a/tinywl/build.zig b/tinywl/build.zig index 9a83f31..9d08ddf 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -47,18 +47,17 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("tinywl.zig"), .target = target, .optimize = optimize, + .link_libc = true, }), }); - tinywl.linkLibC(); - tinywl.root_module.addImport("wayland", wayland); tinywl.root_module.addImport("xkbcommon", xkbcommon); tinywl.root_module.addImport("wlroots", wlroots); - tinywl.linkSystemLibrary("wayland-server"); - tinywl.linkSystemLibrary("xkbcommon"); - tinywl.linkSystemLibrary("pixman-1"); + tinywl.root_module.linkSystemLibrary("wayland-server", .{}); + tinywl.root_module.linkSystemLibrary("xkbcommon", .{}); + tinywl.root_module.linkSystemLibrary("pixman-1", .{}); b.installArtifact(tinywl); } diff --git a/tinywl/build.zig.zon b/tinywl/build.zig.zon index d59c1f5..eba4965 100644 --- a/tinywl/build.zig.zon +++ b/tinywl/build.zig.zon @@ -8,8 +8,8 @@ .hash = "pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX", }, .wayland = .{ - .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.4.0.tar.gz", - .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", + .url = "https://codeberg.org/ifreund/zig-wayland/archive/v0.6.0.tar.gz", + .hash = "wayland-0.6.0-lQa1kqz8AQADQmdNJsNhLoNHcnEGEUjrOaPV-dtEnEmX", }, .wlroots = .{ .path = "..", diff --git a/tinywl/tinywl.zig b/tinywl/tinywl.zig index 7500951..c09f6e2 100644 --- a/tinywl/tinywl.zig +++ b/tinywl/tinywl.zig @@ -8,7 +8,7 @@ const xkb = @import("xkbcommon"); const gpa = std.heap.c_allocator; -pub fn main() anyerror!void { +pub fn main(init: std.process.Init) anyerror!void { wlr.log.init(.debug, null); var server: Server = undefined; @@ -18,14 +18,17 @@ pub fn main() anyerror!void { var buf: [11]u8 = undefined; const socket = try server.wl_server.addSocketAuto(&buf); - if (std.os.argv.len >= 2) { - const cmd = std.mem.span(std.os.argv[1]); - var child = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", cmd }, gpa); - var env_map = try std.process.getEnvMap(gpa); + const argv = init.minimal.args.vector; + if (argv.len >= 2) { + var env_map = try init.minimal.environ.createMap(gpa); defer env_map.deinit(); try env_map.put("WAYLAND_DISPLAY", socket); - child.env_map = &env_map; - try child.spawn(); + + const cmd = std.mem.span(argv[1]); + _ = try std.process.spawn(init.io, .{ + .argv = &.{ "/bin/sh", "-c", cmd }, + .environ_map = &env_map, + }); } try server.backend.start(); @@ -460,7 +463,7 @@ const Output = struct { const scene_output = output.server.scene.getSceneOutput(output.wlr_output).?; _ = scene_output.commit(null); - var now = posix.clock_gettime(posix.CLOCK.MONOTONIC) catch @panic("CLOCK_MONOTONIC not supported"); + var now = timestamp(); scene_output.sendFrameDone(&now); } @@ -666,3 +669,11 @@ const Keyboard = struct { gpa.destroy(keyboard); } }; + +fn timestamp() posix.timespec { + var timespec: posix.timespec = undefined; + switch (posix.errno(posix.system.clock_gettime(posix.CLOCK.MONOTONIC, ×pec))) { + .SUCCESS => return timespec, + else => @panic("CLOCK_MONOTONIC not supported"), + } +} From 934aad3926b0cdf35934d9f338e67dad3c6eefb7 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 25 Apr 2026 13:36:13 +0200 Subject: [PATCH 46/54] build: workaround missing SFrame in zig linker --- .builds/archlinux.yml | 6 ++++-- build.zig | 3 +++ tinywl/build.zig | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml index ad57693..44e594d 100644 --- a/.builds/archlinux.yml +++ b/.builds/archlinux.yml @@ -40,10 +40,12 @@ tasks: sudo mv zig-x86_64-linux-0.16.0/lib /usr/lib/zig - test: | cd zig-wlroots - zig build -Denable-tests test --summary all + # Arch's glibc version has SFrame sections in crt objects, force llvm/lld usage as a workaround + # https://codeberg.org/ziglang/zig/issues/31272 + zig build -Denable-tests -Dllvm test --summary all - tinywl: | cd zig-wlroots/tinywl - zig build --summary all + zig build -Dllvm --summary all - fmt: | cd zig-wlroots zig fmt --check src/ diff --git a/build.zig b/build.zig index 57618bc..a28b241 100644 --- a/build.zig +++ b/build.zig @@ -6,6 +6,7 @@ pub fn build(b: *std.Build) void { }); const enable_tests = b.option(bool, "enable-tests", "allow running tests") orelse false; + const use_llvm = b.option(bool, "llvm", "force usage of LLVM and LLD") orelse false; // Hack to allow making all dependencies required for tests lazy. if (!enable_tests) return; @@ -75,6 +76,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, .link_libc = true, }), + .use_llvm = use_llvm, + .use_lld = use_llvm, }); wlr_test.root_module.addImport("wayland", wayland); diff --git a/tinywl/build.zig b/tinywl/build.zig index 9d08ddf..08b682a 100644 --- a/tinywl/build.zig +++ b/tinywl/build.zig @@ -6,6 +6,8 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const use_llvm = b.option(bool, "llvm", "force usage of LLVM and LLD") orelse false; + const scanner = Scanner.create(b, .{}); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); scanner.addSystemProtocol("stable/tablet/tablet-v2.xml"); @@ -49,6 +51,8 @@ pub fn build(b: *std.Build) void { .optimize = optimize, .link_libc = true, }), + .use_llvm = use_llvm, + .use_lld = use_llvm, }); tinywl.root_module.addImport("wayland", wayland); From e4117fb31f2fe357e09b41d65e3570fc572a38ea Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Sat, 25 Apr 2026 00:50:05 +0300 Subject: [PATCH 47/54] xdg-foreign-v2: add bindings --- build.zig | 3 ++ src/types/xdg_foreign_registry.zig | 50 ++++++++++++++++++++ src/types/xdg_foreign_v2.zig | 73 ++++++++++++++++++++++++++++++ src/wlroots.zig | 8 ++++ 4 files changed, 134 insertions(+) create mode 100644 src/types/xdg_foreign_registry.zig create mode 100644 src/types/xdg_foreign_v2.zig diff --git a/build.zig b/build.zig index a28b241..9320330 100644 --- a/build.zig +++ b/build.zig @@ -22,6 +22,7 @@ pub fn build(b: *std.Build) void { scanner.addSystemProtocol("unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"); scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml"); scanner.addSystemProtocol("unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"); + scanner.addSystemProtocol("unstable/xdg-foreign/xdg-foreign-unstable-v2.xml"); scanner.addSystemProtocol("unstable/tablet/tablet-unstable-v2.xml"); scanner.addSystemProtocol("staging/ext-session-lock/ext-session-lock-v1.xml"); scanner.addSystemProtocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml"); @@ -53,6 +54,8 @@ pub fn build(b: *std.Build) void { scanner.generate("zwp_pointer_gestures_v1", 3); scanner.generate("zwp_pointer_constraints_v1", 1); scanner.generate("zxdg_decoration_manager_v1", 1); + scanner.generate("zxdg_importer_v2", 1); + scanner.generate("zxdg_exporter_v2", 1); scanner.generate("zwp_tablet_manager_v2", 1); scanner.generate("zwp_linux_dmabuf_v1", 4); scanner.generate("zwp_virtual_keyboard_manager_v1", 1); diff --git a/src/types/xdg_foreign_registry.zig b/src/types/xdg_foreign_registry.zig new file mode 100644 index 0000000..8ce4fa1 --- /dev/null +++ b/src/types/xdg_foreign_registry.zig @@ -0,0 +1,50 @@ +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const xdg = wayland.server.xdg; + +const wlr = @import("../wlroots.zig"); + +pub const XdgForeignRegistry = extern struct { + exported_surfaces: wl.list.Head(XdgForeignExported, .link), + + events: extern struct { + destroy: wl.Signal(void), + }, + + private: extern struct { + server_destroy: wl.Listener(void), + }, + + extern fn wlr_xdg_foreign_registry_create(server: *wl.Server) ?*wlr.XdgForeignRegistry; + pub fn create(server: *wl.Server) !*wlr.XdgForeignRegistry { + return wlr_xdg_foreign_registry_create(server) orelse error.OutOfMemory; + } + + extern fn wlr_xdg_foreign_registry_find_by_handle(registry: *XdgForeignRegistry, handle: [*:0]const u8) ?*XdgForeignExported; + pub fn find_by_handle(registry: *XdgForeignRegistry, handle: [*:0]const u8) ?*XdgForeignExported { + return wlr_xdg_foreign_registry_find_by_handle(registry, handle); + } +}; + +pub const XdgForeignExported = extern struct { + // XdgForeignRegistry.exported_surfaces + link: wl.list.Link, + registry: *XdgForeignRegistry, + + toplevel: *wlr.XdgToplevel, + handle: [37]u8, + + events: extern struct { + destroy: wl.Signal(void), + }, + + extern fn wlr_xdg_foreign_exported_init(surface: *XdgForeignExported, registry: *XdgForeignRegistry) bool; + pub fn init(surface: *XdgForeignExported, registry: *XdgForeignRegistry) bool { + return wlr_xdg_foreign_exported_init(surface, registry); + } + + extern fn wlr_xdg_foreign_exported_finish(surface: *XdgForeignExported) void; + pub fn finish(surface: *XdgForeignExported) void { + return wlr_xdg_foreign_exported_finish(surface); + } +}; diff --git a/src/types/xdg_foreign_v2.zig b/src/types/xdg_foreign_v2.zig new file mode 100644 index 0000000..f66303b --- /dev/null +++ b/src/types/xdg_foreign_v2.zig @@ -0,0 +1,73 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const xdg = wayland.server.xdg; +const zxdg = wayland.server.zxdg; + +pub const XdgForeignV2 = extern struct { + exporter: extern struct { + global: *wl.Global, + objects: wl.list.Head(XdgExportedV2, .link), + }, + importer: extern struct { + global: *wl.Global, + objects: wl.list.Head(XdgImportedV2, .link), + }, + + registry: *wlr.XdgForeignRegistry, + + events: extern struct { + destroy: wl.Signal(void), + }, + + data: ?*anyopaque, + + private: extern struct { + foreign_registry_destroy: wl.Listener(void), + server_destroy: wl.Listener(void), + }, + + extern fn wlr_xdg_foreign_v2_create(server: *wl.Server, registry: *wlr.XdgForeignRegistry) ?*wlr.XdgForeignV2; + pub fn create(server: *wl.Server, registry: *wlr.XdgForeignRegistry) !*wlr.XdgForeignV2 { + return wlr_xdg_foreign_v2_create(server, registry) orelse error.OutOfMemory; + } +}; + +pub const XdgExportedV2 = extern struct { + base: wlr.XdgForeignExported, + + resource: *zxdg.ExportedV2, + // XdgForeignV2.exporter.objects + link: wl.list.Link, + + private: extern struct { + xdg_toplevel_destroy: wl.Listener(void), + }, +}; + +pub const XdgImportedV2 = extern struct { + exported: *wlr.XdgForeignExported, + + resource: *zxdg.ImportedV2, + // XdgForeignV2.importer.objects + link: wl.list.Link, + children: wl.list.Head(XdgImportedChildV2, .link), + + private: extern struct { + exported_destroyed: wl.Listener(void), + }, +}; + +pub const XdgImportedChildV2 = extern struct { + imported: ?*XdgImportedV2, + toplevel: *wlr.XdgToplevel, + + // XdgImportedV2.children + link: wl.list.Link, + + private: extern struct { + xdg_toplevel_destroy: wl.Listener(void), + xdg_toplevel_set_parent: wl.Listener(void), + }, +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index 8196322..a7c8548 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -75,6 +75,14 @@ pub const XdgToplevelDecorationV1 = @import("types/xdg_decoration_v1.zig").XdgTo pub const XdgActivationV1 = @import("types/xdg_activation_v1.zig").XdgActivationV1; pub const XdgActivationTokenV1 = @import("types/xdg_activation_v1.zig").XdgActivationTokenV1; +pub const XdgForeignRegistry = @import("types/xdg_foreign_registry.zig").XdgForeignRegistry; +pub const XdgForeignExported = @import("types/xdg_foreign_registry.zig").XdgForeignExported; + +pub const XdgForeignV2 = @import("types/xdg_foreign_v2.zig").XdgForeignV2; +pub const XdgExportedV2 = @import("types/xdg_foreign_v2.zig").XdgExportedV2; +pub const XdgImportedV2 = @import("types/xdg_foreign_v2.zig").XdgImportedV2; +pub const XdgImportedChildV2 = @import("types/xdg_foreign_v2.zig").XdgImportedChildV2; + pub const LayerShellV1 = @import("types/layer_shell_v1.zig").LayerShellV1; pub const LayerSurfaceV1 = @import("types/layer_shell_v1.zig").LayerSurfaceV1; From d30e7e2fe5eee14ed1aeb3b58d5f4a745b21bbac Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 25 Apr 2026 13:57:55 +0200 Subject: [PATCH 48/54] build: fix version number Bumping to 0.21.0-dev was a mistake, that should only be done once wlroots 0.21 is released and zig-wlroots upgrades. --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 7c2e6bc..3252ed4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.21.0-dev", + .version = "0.20.1-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From 7a18c03dca6afa0d80bd9e3a0619e5e5ccd18e20 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 25 Apr 2026 13:58:36 +0200 Subject: [PATCH 49/54] build: bump version to 0.20.1 --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 3252ed4..6691136 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.20.1-dev", + .version = "0.20.1", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From e61187fd86daeb41e4d249bc651d8a46c68fbc14 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 25 Apr 2026 13:59:35 +0200 Subject: [PATCH 50/54] build: bump version to 0.20.2-dev --- build.zig.zon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.zon b/build.zig.zon index 6691136..df02ac4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,6 @@ .{ .name = .wlroots, - .version = "0.20.1", + .version = "0.20.2-dev", .minimum_zig_version = "0.14.0", .paths = .{ "build.zig", From e4ba7a31c412a2c929319bdad07583d531827bc2 Mon Sep 17 00:00:00 2001 From: Ahmed Hamza Aydin Date: Tue, 28 Apr 2026 18:17:55 +0200 Subject: [PATCH 51/54] ext-workspace: add bindings --- build.zig | 2 + src/types/ext_workspace_v1.zig | 157 +++++++++++++++++++++++++++++++++ src/wlroots.zig | 5 ++ 3 files changed, 164 insertions(+) create mode 100644 src/types/ext_workspace_v1.zig diff --git a/build.zig b/build.zig index 9320330..3ce856d 100644 --- a/build.zig +++ b/build.zig @@ -32,6 +32,7 @@ pub fn build(b: *std.Build) void { scanner.addSystemProtocol("staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml"); scanner.addSystemProtocol("staging/color-management/color-management-v1.xml"); scanner.addSystemProtocol("staging/color-representation/color-representation-v1.xml"); + scanner.addSystemProtocol("staging/ext-workspace/ext-workspace-v1.xml"); scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); @@ -50,6 +51,7 @@ pub fn build(b: *std.Build) void { scanner.generate("ext_session_lock_manager_v1", 1); scanner.generate("ext_image_copy_capture_manager_v1", 1); + scanner.generate("ext_workspace_manager_v1", 1); scanner.generate("zwp_pointer_gestures_v1", 3); scanner.generate("zwp_pointer_constraints_v1", 1); diff --git a/src/types/ext_workspace_v1.zig b/src/types/ext_workspace_v1.zig new file mode 100644 index 0000000..56abb12 --- /dev/null +++ b/src/types/ext_workspace_v1.zig @@ -0,0 +1,157 @@ +const wlr = @import("../wlroots.zig"); + +const wayland = @import("wayland"); +const wl = wayland.server.wl; +const ext = wayland.server.ext; + +pub const ExtWorkspaceManagerV1 = extern struct { + pub const event = struct { + pub const Commit = extern struct { + requests: *wl.list.Head(ExtWorkspaceV1Request, .link), + }; + }; + + global: *wl.Global, + groups: wl.list.Head(ExtWorkspaceGroupHandleV1, .link), + workspaces: wl.list.Head(ExtWorkspaceHandleV1, .link), + events: extern struct { + commit: wl.Signal(*event.Commit), + destroy: wl.Signal(void), + }, + + data: ?*anyopaque, + + private: extern struct { + resources: wl.list.Link, + idle_source: ?*wl.EventSource, + event_loop: *wl.EventLoop, + server_destroy: wl.Listener(void), + }, + + extern fn wlr_ext_workspace_manager_v1_create(server: *wl.Server, version: u32) ?*ExtWorkspaceManagerV1; + pub fn create(server: *wl.Server, version: u32) !*ExtWorkspaceManagerV1 { + return wlr_ext_workspace_manager_v1_create(server, version) orelse error.OutOfMemory; + } + + extern fn wlr_ext_workspace_group_handle_v1_create(manager: *ExtWorkspaceManagerV1, caps: ext.WorkspaceGroupHandleV1.GroupCapabilities) ?*ExtWorkspaceGroupHandleV1; + pub fn createGroup(manager: *ExtWorkspaceManagerV1, caps: ext.WorkspaceGroupHandleV1.GroupCapabilities) !*ExtWorkspaceGroupHandleV1 { + return wlr_ext_workspace_group_handle_v1_create(manager, caps) orelse error.OutOfMemory; + } + + extern fn wlr_ext_workspace_handle_v1_create(manager: *ExtWorkspaceManagerV1, id: [*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) ?*ExtWorkspaceHandleV1; + pub fn createWorkspace(manager: *ExtWorkspaceManagerV1, id: [*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) !*ExtWorkspaceHandleV1 { + return wlr_ext_workspace_handle_v1_create(manager, id, caps) orelse error.OutOfMemory; + } +}; + +pub const ExtWorkspaceV1Request = extern struct { + pub const Type = enum(c_int) { + create_workspace = 0, + activate = 1, + deactivate = 2, + assign = 3, + remove = 4, + }; + + pub const Data = extern union { + create_workspace: extern struct { + name: [*:0]const u8, + /// `null` if destroyed + group: ?*ExtWorkspaceGroupHandleV1, + }, + activate: extern struct { + /// `null` if destroyed + workspace: ?*ExtWorkspaceHandleV1, + }, + deactivate: extern struct { + /// `null` if destroyed + workspace: ?*ExtWorkspaceHandleV1, + }, + assign: extern struct { + /// `null` if destroyed + workspace: ?*ExtWorkspaceHandleV1, + /// `null` if destroyed + group: ?*ExtWorkspaceGroupHandleV1, + }, + remove: extern struct { + /// `null` if destroyed + workspace: ?*ExtWorkspaceHandleV1, + }, + }; + + type: Type, + link: wl.list.Link, + data: Data, +}; + +pub const ExtWorkspaceGroupHandleV1 = extern struct { + manager: *ExtWorkspaceManagerV1, + caps: ext.WorkspaceGroupHandleV1.GroupCapabilities, + events: extern struct { + destroy: wl.Signal(void), + }, + /// Manager.groups + link: wl.list.Link, + + data: ?*anyopaque, + + private: extern struct { + outputs: wl.list.Link, + resources: wl.list.Link, + }, + + extern fn wlr_ext_workspace_group_handle_v1_destroy(group: *ExtWorkspaceGroupHandleV1) void; + pub const destroy = wlr_ext_workspace_group_handle_v1_destroy; + + extern fn wlr_ext_workspace_group_handle_v1_output_enter(group: *ExtWorkspaceGroupHandleV1, output: *wlr.Output) void; + pub const outputEnter = wlr_ext_workspace_group_handle_v1_output_enter; + + extern fn wlr_ext_workspace_group_handle_v1_output_leave(group: *ExtWorkspaceGroupHandleV1, output: *wlr.Output) void; + pub const outputLeave = wlr_ext_workspace_group_handle_v1_output_leave; +}; + +pub const ExtWorkspaceHandleV1 = extern struct { + manager: *ExtWorkspaceManagerV1, + group: ?*ExtWorkspaceGroupHandleV1, + id: ?[*:0]u8, + name: ?[*:0]u8, + coordinates: wl.Array, + caps: ext.WorkspaceHandleV1.WorkspaceCapabilities, + state: ext.WorkspaceHandleV1.State, + + events: extern struct { + destroy: wl.Signal(void), + }, + + /// Manager.workspaces + link: wl.list.Link, + + data: ?*anyopaque, + + private: extern struct { + resources: wl.list.Link, + }, + + extern fn wlr_ext_workspace_handle_v1_destroy(workspace: *ExtWorkspaceHandleV1) void; + pub const destroy = wlr_ext_workspace_handle_v1_destroy; + + extern fn wlr_ext_workspace_handle_v1_set_group(workspace: *ExtWorkspaceHandleV1, group: ?*ExtWorkspaceGroupHandleV1) void; + pub const setGroup = wlr_ext_workspace_handle_v1_set_group; + + extern fn wlr_ext_workspace_handle_v1_set_name(workspace: *ExtWorkspaceHandleV1, name: [*:0]const u8) void; + pub const setName = wlr_ext_workspace_handle_v1_set_name; + + extern fn wlr_ext_workspace_handle_v1_set_coordinates(workspace: *ExtWorkspaceHandleV1, coords: [*]u32, coords_len: usize) void; + pub fn setCoordinates(workspace: *ExtWorkspaceHandleV1, coords: []u32) void { + wlr_ext_workspace_handle_v1_set_coordinates(workspace, coords.ptr, coords.len); + } + + extern fn wlr_ext_workspace_handle_v1_set_active(workspace: *ExtWorkspaceHandleV1, enabled: bool) void; + pub const setActive = wlr_ext_workspace_handle_v1_set_active; + + extern fn wlr_ext_workspace_handle_v1_set_urgent(workspace: *ExtWorkspaceHandleV1, enabled: bool) void; + pub const setUrgent = wlr_ext_workspace_handle_v1_set_urgent; + + extern fn wlr_ext_workspace_handle_v1_set_hidden(workspace: *ExtWorkspaceHandleV1, enabled: bool) void; + pub const setHidden = wlr_ext_workspace_handle_v1_set_hidden; +}; diff --git a/src/wlroots.zig b/src/wlroots.zig index a7c8548..aa1bf93 100644 --- a/src/wlroots.zig +++ b/src/wlroots.zig @@ -228,6 +228,11 @@ pub const ExtImageCopyCaptureManagerV1 = @import("types/ext_image_copy_capture_v pub const ExtImageCopyCaptureFrameV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureFrameV1; pub const ExtImageCopyCaptureSessionV1 = @import("types/ext_image_copy_capture_v1.zig").ExtImageCopyCaptureSessionV1; +pub const ExtWorkspaceManagerV1 = @import("types/ext_workspace_v1.zig").ExtWorkspaceManagerV1; +pub const ExtWorkspaceV1Request = @import("types/ext_workspace_v1.zig").ExtWorkspaceV1Request; +pub const ExtWorkspaceGroupHandleV1 = @import("types/ext_workspace_v1.zig").ExtWorkspaceGroupHandleV1; +pub const ExtWorkspaceHandleV1 = @import("types/ext_workspace_v1.zig").ExtWorkspaceHandleV1; + pub const SecurityContextManagerV1 = @import("types/security_context_v1.zig").SecurityContextManagerV1; pub const SecurityContextV1State = @import("types/security_context_v1.zig").SecurityContextV1State; From f30e7f72965a3ced88fb9c6786e256a60eb486fc Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Sat, 9 May 2026 21:37:13 +0300 Subject: [PATCH 52/54] ext-workspace: fix id nullability in workspace handle constructor --- src/types/ext_workspace_v1.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/ext_workspace_v1.zig b/src/types/ext_workspace_v1.zig index 56abb12..b9d0c03 100644 --- a/src/types/ext_workspace_v1.zig +++ b/src/types/ext_workspace_v1.zig @@ -38,8 +38,8 @@ pub const ExtWorkspaceManagerV1 = extern struct { return wlr_ext_workspace_group_handle_v1_create(manager, caps) orelse error.OutOfMemory; } - extern fn wlr_ext_workspace_handle_v1_create(manager: *ExtWorkspaceManagerV1, id: [*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) ?*ExtWorkspaceHandleV1; - pub fn createWorkspace(manager: *ExtWorkspaceManagerV1, id: [*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) !*ExtWorkspaceHandleV1 { + extern fn wlr_ext_workspace_handle_v1_create(manager: *ExtWorkspaceManagerV1, id: ?[*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) ?*ExtWorkspaceHandleV1; + pub fn createWorkspace(manager: *ExtWorkspaceManagerV1, id: ?[*:0]const u8, caps: ext.WorkspaceHandleV1.WorkspaceCapabilities) !*ExtWorkspaceHandleV1 { return wlr_ext_workspace_handle_v1_create(manager, id, caps) orelse error.OutOfMemory; } }; From 4abde3848ccf77b001fca8434038411c2aa1c8ba Mon Sep 17 00:00:00 2001 From: Peter Kaplan Date: Fri, 4 Sep 2026 16:33:35 +0200 Subject: [PATCH 53/54] switch: add keypad_slide --- src/types/switch.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/switch.zig b/src/types/switch.zig index 0f8b6d9..90d861c 100644 --- a/src/types/switch.zig +++ b/src/types/switch.zig @@ -6,6 +6,7 @@ const wl = wayland.server.wl; pub const SwitchType = enum(c_int) { lid, tablet_mode, + keypad_slide, }; pub const SwitchState = enum(c_int) { From c183af18ae35dd5fb3dde709697c8f84bb1dc7f3 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 8 Sep 2026 11:11:06 +0200 Subject: [PATCH 54/54] Seat: use wl.Seat.Capability enum --- src/types/seat.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/seat.zig b/src/types/seat.zig index 21cb7e7..58d9d38 100644 --- a/src/types/seat.zig +++ b/src/types/seat.zig @@ -263,8 +263,8 @@ pub const Seat = extern struct { name: [*:0]u8, - capabilities: u32, - accumulated_capabilities: u32, + capabilities: wl.Seat.Capability, + accumulated_capabilities: wl.Seat.Capability, selection_source: ?*wlr.DataSource, selection_serial: u32,