Make all things const

The quest for idiomatic zig continues
This commit is contained in:
Isaac Freund
2020-03-24 20:35:45 +01:00
parent 4872a68378
commit b3bad0ca93
7 changed files with 51 additions and 49 deletions

View File

@ -144,11 +144,11 @@ pub const Server = struct {
}
fn handle_new_output(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
var server = @fieldParentPtr(Server, "listen_new_output", listener.?);
var wlr_output = @ptrCast(*c.wlr_output, @alignCast(@alignOf(*c.wlr_output), data));
const server = @fieldParentPtr(Server, "listen_new_output", listener.?);
const wlr_output = @ptrCast(*c.wlr_output, @alignCast(@alignOf(*c.wlr_output), data));
// TODO: Handle failure
var node = server.outputs.allocateNode(server.allocator) catch unreachable;
const node = server.outputs.allocateNode(server.allocator) catch unreachable;
node.data.init(server, wlr_output) catch unreachable;
server.outputs.append(node);
}
@ -156,15 +156,15 @@ pub const Server = struct {
fn handle_new_xdg_surface(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
// This event is raised when wlr_xdg_shell receives a new xdg surface from a
// client, either a toplevel (application window) or popup.
var server = @fieldParentPtr(Server, "listen_new_xdg_surface", listener.?);
var wlr_xdg_surface = @ptrCast(*c.wlr_xdg_surface, @alignCast(@alignOf(*c.wlr_xdg_surface), data));
const server = @fieldParentPtr(Server, "listen_new_xdg_surface", listener.?);
const wlr_xdg_surface = @ptrCast(*c.wlr_xdg_surface, @alignCast(@alignOf(*c.wlr_xdg_surface), data));
if (wlr_xdg_surface.role != c.enum_wlr_xdg_surface_role.WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
return;
}
// Create a View to handle this toplevel surface
var node = server.views.allocateNode(server.allocator) catch unreachable;
const node = server.views.allocateNode(server.allocator) catch unreachable;
node.data.init(server, wlr_xdg_surface);
server.views.append(node);
}