Skip to content

Commit

Permalink
Update for wlroots 0.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund committed Dec 21, 2021
1 parent 2d53b02 commit 0ed3d62
Show file tree
Hide file tree
Showing 39 changed files with 384 additions and 383 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ as stable as wlroots*

## Dependencies

- [zig](https://ziglang.org/) 0.8.0
- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.14.0
- [zig](https://ziglang.org/) 0.8
- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.15
- [zig-wayland](https://github.com/ifreund/zig-wayland)
- [zig-xkbcommon](https://github.com/ifreund/zig-xkbcommon)
- [zig-pixman](https://github.com/ifreund/zig-pixman)
Expand Down
1 change: 0 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub fn build(b: *Builder) void {

const scanner = ScanProtocolsStep.create(b);
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
scanner.addProtocolPath("protocol/wayland-drm.xml");
scanner.addProtocolPath("protocol/wlr-layer-shell-unstable-v1.xml");
scanner.addProtocolPath("protocol/wlr-output-power-management-unstable-v1.xml");
scanner.addSystemProtocol("unstable/pointer-constraints/pointer-constraints-unstable-v1.xml");
Expand Down
189 changes: 0 additions & 189 deletions protocol/wayland-drm.xml

This file was deleted.

22 changes: 0 additions & 22 deletions src/backend.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ pub const Backend = extern struct {
new_output: wl.Signal(*wlr.Output),
},

// Private state
renderer: ?*wlr.Renderer,
allocator: ?*wlr.Allocator,

// backend.h

extern fn wlr_backend_autocreate(server: *wl.Server) ?*Backend;
Expand All @@ -34,9 +30,6 @@ pub const Backend = extern struct {
extern fn wlr_backend_destroy(backend: *Backend) void;
pub const destroy = wlr_backend_destroy;

extern fn wlr_backend_get_renderer(backend: *Backend) ?*wlr.Renderer;
pub const getRenderer = wlr_backend_get_renderer;

extern fn wlr_backend_get_session(backend: *Backend) ?*wlr.Session;
pub const getSession = wlr_backend_get_session;

Expand Down Expand Up @@ -64,19 +57,4 @@ pub const Backend = extern struct {

extern fn wlr_multi_for_each_backend(backend: *Backend, callback: fn (backend: *Backend, data: ?*c_void) callconv(.C) void, data: ?*c_void) void;
pub const multiForEachBackend = wlr_multi_for_each_backend;

// backend/noop.h

extern fn wlr_noop_backend_create(server: *wl.Server) ?*Backend;
pub fn createNoop(server: *wl.Server) !*Backend {
return wlr_noop_backend_create(server) orelse error.BackendCreateFailed;
}

extern fn wlr_noop_add_output(noop: *Backend) ?*wlr.Output;
pub fn noopAddOutput(noop: *Backend) !*wlr.Output {
return wlr_noop_add_output(noop) orelse error.OutOfMemory;
}

extern fn wlr_backend_is_noop(backend: *Backend) bool;
pub const isNoop = wlr_backend_is_noop;
};
21 changes: 20 additions & 1 deletion src/backend/session.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@ const wayland = @import("wayland");
const wl = wayland.server.wl;

pub const Device = extern struct {
pub const event = struct {
pub const Change = extern struct {
pub const Type = extern enum {
hotplug = 1,
lease,
};

type: Type,
event: extern union {
hotplug: Hotplug,
},
};

pub const Hotplug = extern struct {
connector_id: u32,
prop_id: u32,
};
};

fd: c_int,
device_id: c_int,
dev: os.dev_t,
/// Session.devices
link: wl.list.Link,

events: extern struct {
change: wl.Signal(void),
change: wl.Signal(*event.Change),
remove: wl.Signal(void),
},
};
Expand Down
4 changes: 4 additions & 0 deletions src/config.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const c = @cImport(@cInclude("wlr/config.h"));

pub const has_drm_backend = c.WLR_HAS_DRM_BACKEND != 0;
pub const has_libinput_backend = c.WLR_HAS_LIBINPUT_BACKEND != 0;
pub const has_x11_backend = c.WLR_HAS_X11_BACKEND != 0;

pub const has_gles2_renderer = c.WLR_HAS_GLES2_RENDERER != 0;

pub const has_vulkan_renderer = c.WLR_HAS_VULKAN_RENDERER != 0;

pub const has_xwayland = c.WLR_HAS_XWAYLAND != 0;
33 changes: 33 additions & 0 deletions src/render/allocator.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const wlr = @import("../wlroots.zig");

const wayland = @import("wayland");
const wl = wayland.server.wl;

pub const Allocator = extern struct {
pub const Interface = extern struct {
create_buffer: fn (alloc: *wlr.Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) callconv(.C) ?*wlr.Buffer,
destroy: fn (alloc: *wlr.Allocator) callconv(.C) void,
};

impl: *const Interface,

buffer_caps: u32,

events: extern struct {
destroy: wl.Signal(void),
},

extern fn wlr_allocator_init(alloc: *Allocator, impl: *const Interface, buffer_caps: u32) void;
pub const init = wlr_allocator_init;

extern fn wlr_allocator_autocreate(backend: *wlr.Backend, renderer: *wlr.Renderer) ?*Allocator;
pub fn autocreate(backend: *wlr.Backend, renderer: *wlr.Renderer) !*Allocator {
return wlr_allocator_autocreate(backend, renderer) orelse error.AllocatorCreateFailed;
}

extern fn wlr_allocator_destroy(alloc: *Allocator) void;
pub const destroy = wlr_allocator_destroy;

extern fn wlr_allocator_create_buffer(alloc: *Allocator, width: c_int, height: c_int, format: *const wlr.DrmFormat) ?*wlr.Buffer;
pub const createBuffer = wlr_allocator_create_buffer;
};
7 changes: 0 additions & 7 deletions src/render/dmabuf.zig
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
pub const DmabufAttributes = extern struct {
pub const Flags = extern enum {
y_invert = 1,
interlaced = 2,
bottom_first = 4,
};

width: i32,
height: i32,
format: u32,
flags: u32,
modifier: u64,

n_planes: c_int,
Expand Down
16 changes: 0 additions & 16 deletions src/render/renderer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,12 @@ pub const Renderer = extern struct {
}
}

extern fn wlr_resource_get_buffer_size(resource: *wl.Buffer, renderer: *wlr.Renderer, width: *c_int, height: *c_int) bool;
pub inline fn getBufferSize(renderer: *wlr.Renderer, resource: *wl.Buffer, width: *c_int, height: *c_int) bool {
return wlr_resource_get_buffer_size(resource, renderer, width, height);
}

extern fn wlr_renderer_scissor(renderer: *Renderer, box: ?*wlr.Box) void;
pub const scissor = wlr_renderer_scissor;

extern fn wlr_renderer_get_shm_texture_formats(renderer: *Renderer, len: *usize) [*]const u32;
pub const getShmTextureFormats = wlr_renderer_get_shm_texture_formats;

extern fn wlr_renderer_resource_is_wl_drm_buffer(renderer: *Renderer, buffer: *wl.Buffer) bool;
pub const resourceIsWlDrmBuffer = wlr_renderer_resource_is_wl_drm_buffer;

extern fn wlr_renderer_wl_drm_buffer_get_size(
renderer: *Renderer,
buffer: *wl.Buffer,
width: *c_int,
height: *c_int,
) void;
pub const wlDrmBufferGetSize = wlr_renderer_wl_drm_buffer_get_size;

// TODO:
//extern fn wlr_renderer_get_dmabuf_texture_formats(renderer: *Renderer) [*c]const struct_wlr_drm_format_set;
//pub const getDmabufFormats = wlr_renderer_get_dmabuf_formats;
Expand Down
6 changes: 3 additions & 3 deletions src/render/texture.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ pub const Texture = extern struct {
extern fn wlr_texture_from_pixels(renderer: *wlr.Renderer, wl_fmt: wl.Shm.Format, stride: u32, width: u32, height: u32, data: *const c_void) ?*Texture;
pub const fromPixels = wlr_texture_from_pixels;

extern fn wlr_texture_from_wl_drm(renderer: *wlr.Renderer, data: *wl.Drm) ?*Texture;
pub const fromWlDrm = wlr_texture_from_wl_drm;

extern fn wlr_texture_from_dmabuf(renderer: *wlr.Renderer, attribs: *wlr.DmabufAttributes) ?*Texture;
pub const fromDmabuf = wlr_texture_from_dmabuf;

Expand All @@ -27,4 +24,7 @@ pub const Texture = extern struct {

extern fn wlr_texture_destroy(texture: *Texture) void;
pub const destroy = wlr_texture_destroy;

extern fn wlr_texture_from_buffer(renderer: *wlr.Renderer, buffer: *wlr.Buffer) ?*Texture;
pub const fromBuffer = wlr_texture_from_buffer;
};
Loading

0 comments on commit 0ed3d62

Please sign in to comment.