code: Remove most of the hack around @cImport and flexible arrays

This commit is contained in:
Marten Ringwelski
2020-10-30 13:36:34 +01:00
committed by Isaac Freund
parent 9a2e11620c
commit 1bd6f6bed1
7 changed files with 12 additions and 62 deletions

View File

@ -164,8 +164,8 @@ fn handleBuiltinMapping(self: Self, keysym: c.xkb_keysym_t) bool {
if (keysym >= c.XKB_KEY_XF86Switch_VT_1 and keysym <= c.XKB_KEY_XF86Switch_VT_12) {
log.debug(.keyboard, "switch VT keysym received", .{});
const wlr_backend = self.seat.input_manager.server.wlr_backend;
if (c.river_wlr_backend_is_multi(wlr_backend)) {
if (c.river_wlr_backend_get_session(wlr_backend)) |session| {
if (c.wlr_backend_is_multi(wlr_backend)) {
if (c.wlr_backend_get_session(wlr_backend)) |session| {
const vt = keysym - c.XKB_KEY_XF86Switch_VT_1 + 1;
log.notice(.server, "switching to VT {}", .{vt});
_ = c.wlr_session_change_vt(session, vt);

View File

@ -111,7 +111,7 @@ pub fn init(self: *Self, root: *Root, wlr_output: *c.wlr_output) !void {
self.listen_mode.notify = handleMode;
c.wl_signal_add(&wlr_output.events.mode, &self.listen_mode);
if (c.river_wlr_output_is_noop(wlr_output)) {
if (c.wlr_output_is_noop(wlr_output)) {
// A noop output is always 0 x 0
self.usable_box = .{
.x = 0,
@ -146,7 +146,7 @@ pub fn init(self: *Self, root: *Root, wlr_output: *c.wlr_output) !void {
}
pub fn getRenderer(self: Self) *c.wlr_renderer {
return c.river_wlr_backend_get_renderer(self.wlr_output.backend);
return c.wlr_backend_get_renderer(self.wlr_output.backend);
}
pub fn sendViewTags(self: Self) void {

View File

@ -72,7 +72,7 @@ pub fn init(self: *Self, server: *Server) !void {
.noop_output = undefined,
};
const noop_wlr_output = c.river_wlr_noop_add_output(server.noop_backend) orelse return error.OutOfMemory;
const noop_wlr_output = c.wlr_noop_add_output(server.noop_backend) orelse return error.OutOfMemory;
try self.noop_output.init(self, noop_wlr_output);
}

View File

@ -85,13 +85,13 @@ pub fn init(self: *Self) !void {
// This backend is used to create a noop output for use when no actual
// outputs are available. This frees itself when the wl_display is destroyed.
self.noop_backend = c.river_wlr_noop_backend_create(self.wl_display) orelse
self.noop_backend = c.wlr_noop_backend_create(self.wl_display) orelse
return error.OutOfMemory;
// If we don't provide a renderer, autocreate makes a GLES2 renderer for us.
// The renderer is responsible for defining the various pixel formats it
// supports for shared memory, this configures that for clients.
const wlr_renderer = c.river_wlr_backend_get_renderer(self.wlr_backend).?;
const wlr_renderer = c.wlr_backend_get_renderer(self.wlr_backend).?;
if (!c.wlr_renderer_init_wl_display(wlr_renderer, self.wl_display)) return error.DisplayInitFailed;
self.listen_new_output.notify = handleNewOutput;
@ -154,7 +154,7 @@ pub fn deinit(self: *Self) void {
self.root.deinit();
c.wl_display_destroy(self.wl_display);
c.river_wlr_backend_destory(self.noop_backend);
c.wlr_backend_destroy(self.noop_backend);
self.input_manager.deinit();
self.config.deinit();
@ -163,7 +163,7 @@ pub fn deinit(self: *Self) void {
/// Create the socket, start the backend, and setup the environment
pub fn start(self: Self) !void {
const socket = c.wl_display_add_socket_auto(self.wl_display) orelse return error.AddSocketError;
if (!c.river_wlr_backend_start(self.wlr_backend)) return error.StartBackendError;
if (!c.wlr_backend_start(self.wlr_backend)) return error.StartBackendError;
if (c.setenv("WAYLAND_DISPLAY", socket, 1) < 0) return error.SetenvError;
if (build_options.xwayland) {
if (c.setenv("DISPLAY", self.wlr_xwayland.display_name, 1) < 0) return error.SetenvError;

View File

@ -27,7 +27,9 @@ pub usingnamespace @cImport({
@cInclude("libevdev/libevdev.h");
@cInclude("wayland-server-core.h");
//@cInclude("wlr/backend.h");
@cInclude("wlr/backend.h");
@cInclude("wlr/backend/multi.h");
@cInclude("wlr/backend/noop.h");
//@cInclude("wlr/render/wlr_renderer.h");
@cInclude("wlr/types/wlr_buffer.h");
@cInclude("wlr/types/wlr_compositor.h");