code: update to zig master in prep for 0.7.0
This commit makes the minimal necessary changes to get things working, there are further changes which can be made to take advantage of new features.
This commit is contained in:
parent
0bd8274bd4
commit
27b666dbba
@ -139,7 +139,7 @@ const ScanProtocolsStep = struct {
|
||||
fn init(builder: *std.build.Builder) ScanProtocolsStep {
|
||||
return ScanProtocolsStep{
|
||||
.builder = builder,
|
||||
.step = std.build.Step.init("Scan Protocols", builder.allocator, make),
|
||||
.step = std.build.Step.init(.Custom, "Scan Protocols", builder.allocator, make),
|
||||
};
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ const ScdocStep = struct {
|
||||
fn init(builder: *std.build.Builder) ScdocStep {
|
||||
return ScdocStep{
|
||||
.builder = builder,
|
||||
.step = std.build.Step.init("Generate man pages", builder.allocator, make),
|
||||
.step = std.build.Step.init(.Custom, "Generate man pages", builder.allocator, make),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ pub fn init() !Self {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn deinit(self: Self) void {
|
||||
pub fn deinit(self: *Self) void {
|
||||
var it = self.mode_to_id.iterator();
|
||||
while (it.next()) |kv| util.gpa.free(kv.key);
|
||||
while (it.next()) |e| util.gpa.free(e.key);
|
||||
self.mode_to_id.deinit();
|
||||
|
||||
for (self.modes.items) |mode| mode.deinit();
|
||||
|
@ -104,7 +104,7 @@ fn addArgument(wl_client: ?*c.wl_client, wl_resource: ?*c.wl_resource, arg: ?[*:
|
||||
return;
|
||||
};
|
||||
|
||||
self.args_map.get(id).?.value.append(owned_slice) catch {
|
||||
self.args_map.getEntry(id).?.value.append(owned_slice) catch {
|
||||
c.wl_client_post_no_memory(wl_client);
|
||||
util.gpa.free(owned_slice);
|
||||
return;
|
||||
@ -133,7 +133,7 @@ fn runCommand(
|
||||
};
|
||||
c.wl_resource_set_implementation(callback_resource, null, null, null);
|
||||
|
||||
const args = self.args_map.get(c.wl_resource_get_id(wl_resource)).?.value.items;
|
||||
const args = self.args_map.get(c.wl_resource_get_id(wl_resource)).?.items;
|
||||
|
||||
var out: ?[]const u8 = null;
|
||||
defer if (out) |s| util.gpa.free(s);
|
||||
|
@ -35,7 +35,7 @@ server: *Server,
|
||||
wlr_idle: *c.wlr_idle,
|
||||
wlr_input_inhibit_manager: *c.wlr_input_inhibit_manager,
|
||||
|
||||
seats: std.TailQueue(Seat) = std.TailQueue(Seat).init(),
|
||||
seats: std.TailQueue(Seat) = .{},
|
||||
|
||||
exclusive_client: ?*c.wl_client = null,
|
||||
|
||||
|
@ -42,7 +42,7 @@ root: *Root,
|
||||
wlr_output: *c.wlr_output,
|
||||
|
||||
/// All layer surfaces on the output, indexed by the layer enum.
|
||||
layers: [4]std.TailQueue(LayerSurface) = [1]std.TailQueue(LayerSurface){std.TailQueue(LayerSurface).init()} ** 4,
|
||||
layers: [4]std.TailQueue(LayerSurface) = [1]std.TailQueue(LayerSurface){.{}} ** 4,
|
||||
|
||||
/// The area left for views and other layer surfaces after applying the
|
||||
/// exclusive zones of exclusive layer surfaces.
|
||||
@ -50,7 +50,7 @@ layers: [4]std.TailQueue(LayerSurface) = [1]std.TailQueue(LayerSurface){std.Tail
|
||||
usable_box: Box,
|
||||
|
||||
/// The top of the stack is the "most important" view.
|
||||
views: ViewStack(View) = ViewStack(View){},
|
||||
views: ViewStack(View) = .{},
|
||||
|
||||
/// The double-buffered state of the output.
|
||||
current: State = State{ .tags = 1 << 0 },
|
||||
@ -71,7 +71,7 @@ layout: []const u8,
|
||||
attach_mode: AttachMode = .top,
|
||||
|
||||
/// List of status tracking objects relaying changes to this output to clients.
|
||||
status_trackers: std.SinglyLinkedList(OutputStatus) = std.SinglyLinkedList(OutputStatus).init(),
|
||||
status_trackers: std.SinglyLinkedList(OutputStatus) = .{},
|
||||
|
||||
// All listeners for this output, in alphabetical order
|
||||
listen_destroy: c.wl_listener = undefined,
|
||||
@ -240,7 +240,7 @@ fn layoutExternal(self: *Self, visible_count: u32) !void {
|
||||
std.os.execveZ("/bin/sh", &cmd, std.c.environ) catch c._exit(1);
|
||||
}
|
||||
std.os.close(stdout_pipe[1]);
|
||||
const stdout = std.fs.File{ .handle = stdout_pipe[0], .io_mode = std.io.mode };
|
||||
const stdout = std.fs.File{ .handle = stdout_pipe[0] };
|
||||
defer stdout.close();
|
||||
|
||||
// TODO abort after a timeout
|
||||
|
@ -35,20 +35,20 @@ const DragIcon = @import("DragIcon.zig");
|
||||
server: *Server,
|
||||
|
||||
wlr_output_layout: *c.wlr_output_layout,
|
||||
outputs: std.TailQueue(Output) = std.TailQueue(Output).init(),
|
||||
outputs: std.TailQueue(Output) = .{},
|
||||
|
||||
/// This output is used internally when no real outputs are available.
|
||||
/// It is not advertised to clients.
|
||||
noop_output: Output = undefined,
|
||||
|
||||
drag_icons: std.SinglyLinkedList(DragIcon) = std.SinglyLinkedList(DragIcon).init(),
|
||||
drag_icons: std.SinglyLinkedList(DragIcon) = .{},
|
||||
|
||||
/// This list stores all unmanaged Xwayland windows. This needs to be in root
|
||||
/// since X is like the wild west and who knows where these things will go.
|
||||
xwayland_unmanaged_views: if (build_options.xwayland)
|
||||
std.TailQueue(XwaylandUnmanaged)
|
||||
else
|
||||
void = if (build_options.xwayland) std.TailQueue(XwaylandUnmanaged).init(),
|
||||
void = if (build_options.xwayland) .{},
|
||||
|
||||
/// Number of pending configures sent in the current transaction.
|
||||
/// A value of 0 means there is no current transaction.
|
||||
@ -92,7 +92,7 @@ pub fn deinit(self: *Self) void {
|
||||
}
|
||||
|
||||
pub fn addOutput(self: *Self, wlr_output: *c.wlr_output) void {
|
||||
const node = self.outputs.allocateNode(util.gpa) catch {
|
||||
const node = util.gpa.create(std.TailQueue(Output).Node) catch {
|
||||
c.wlr_output_destroy(wlr_output);
|
||||
return;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ wlr_seat: *c.wlr_seat,
|
||||
cursor: Cursor = undefined,
|
||||
|
||||
/// Mulitple keyboards are handled separately
|
||||
keyboards: std.TailQueue(Keyboard) = std.TailQueue(Keyboard).init(),
|
||||
keyboards: std.TailQueue(Keyboard) = .{},
|
||||
|
||||
/// ID of the current keymap mode
|
||||
mode_id: usize = 0,
|
||||
@ -61,10 +61,10 @@ focused: FocusTarget = .none,
|
||||
|
||||
/// Stack of views in most recently focused order
|
||||
/// If there is a currently focused view, it is on top.
|
||||
focus_stack: ViewStack(*View) = ViewStack(*View){},
|
||||
focus_stack: ViewStack(*View) = .{},
|
||||
|
||||
/// List of status tracking objects relaying changes to this seat to clients.
|
||||
status_trackers: std.SinglyLinkedList(SeatStatus) = std.SinglyLinkedList(SeatStatus).init(),
|
||||
status_trackers: std.SinglyLinkedList(SeatStatus) = .{},
|
||||
|
||||
listen_request_set_selection: c.wl_listener = undefined,
|
||||
listen_request_start_drag: c.wl_listener = undefined,
|
||||
@ -307,7 +307,7 @@ pub fn addDevice(self: *Self, device: *c.wlr_input_device) void {
|
||||
}
|
||||
|
||||
fn addKeyboard(self: *Self, device: *c.wlr_input_device) !void {
|
||||
const node = try self.keyboards.allocateNode(util.gpa);
|
||||
const node = try util.gpa.create(std.TailQueue(Keyboard).Node);
|
||||
node.data.init(self, device) catch |err| {
|
||||
switch (err) {
|
||||
error.XkbContextFailed => log.err(.keyboard, "Failed to create XKB context", .{}),
|
||||
|
@ -111,7 +111,7 @@ float_box: Box = undefined,
|
||||
|
||||
draw_borders: bool = true,
|
||||
|
||||
pub fn init(self: *Self, output: *Output, tags: u32, surface: var) void {
|
||||
pub fn init(self: *Self, output: *Output, tags: u32, surface: anytype) void {
|
||||
self.* = .{
|
||||
.output = output,
|
||||
.current = .{ .tags = tags },
|
||||
|
@ -32,7 +32,7 @@ pub fn enterMode(
|
||||
|
||||
const config = seat.input_manager.server.config;
|
||||
const target_mode = args[1];
|
||||
seat.mode_id = config.mode_to_id.getValue(target_mode) orelse {
|
||||
seat.mode_id = config.mode_to_id.get(target_mode) orelse {
|
||||
out.* = try std.fmt.allocPrint(
|
||||
allocator,
|
||||
"cannot enter non-existant mode '{}'",
|
||||
|
@ -149,7 +149,7 @@ pub fn mapPointer(
|
||||
|
||||
fn modeNameToId(allocator: *std.mem.Allocator, seat: *Seat, mode_name: []const u8, out: *?[]const u8) !usize {
|
||||
const config = seat.input_manager.server.config;
|
||||
return config.mode_to_id.getValue(mode_name) orelse {
|
||||
return config.mode_to_id.get(mode_name) orelse {
|
||||
out.* = try std.fmt.allocPrint(
|
||||
allocator,
|
||||
"cannot add mapping to non-existant mode '{}p'",
|
||||
|
@ -55,12 +55,12 @@ fn log(
|
||||
comptime message_level: Level,
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
if (@enumToInt(message_level) <= @enumToInt(level)) {
|
||||
// Don't store/log messages in release small mode to save space
|
||||
if (std.builtin.mode != .ReleaseSmall) {
|
||||
const stderr = std.debug.getStderrStream();
|
||||
const stderr = std.io.getStdErr().writer();
|
||||
stderr.print(@tagName(message_level) ++ ": (" ++ @tagName(scope) ++ ") " ++
|
||||
format ++ "\n", args) catch return;
|
||||
}
|
||||
@ -72,7 +72,7 @@ fn log(
|
||||
pub fn emerg(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
@setCold(true);
|
||||
log(.emerg, scope, format, args);
|
||||
@ -83,7 +83,7 @@ pub fn emerg(
|
||||
pub fn alert(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
@setCold(true);
|
||||
log(.alert, scope, format, args);
|
||||
@ -95,7 +95,7 @@ pub fn alert(
|
||||
pub fn crit(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
@setCold(true);
|
||||
log(.crit, scope, format, args);
|
||||
@ -106,7 +106,7 @@ pub fn crit(
|
||||
pub fn err(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
@setCold(true);
|
||||
log(.err, scope, format, args);
|
||||
@ -118,7 +118,7 @@ pub fn err(
|
||||
pub fn warn(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
log(.warn, scope, format, args);
|
||||
}
|
||||
@ -128,7 +128,7 @@ pub fn warn(
|
||||
pub fn notice(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
log(.notice, scope, format, args);
|
||||
}
|
||||
@ -138,7 +138,7 @@ pub fn notice(
|
||||
pub fn info(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
log(.info, scope, format, args);
|
||||
}
|
||||
@ -148,7 +148,7 @@ pub fn info(
|
||||
pub fn debug(
|
||||
comptime scope: @TypeOf(.foobar),
|
||||
comptime format: []const u8,
|
||||
args: var,
|
||||
args: anytype,
|
||||
) void {
|
||||
log(.debug, scope, format, args);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ pub fn main() anyerror!void {
|
||||
log.info(.server, "shutting down", .{});
|
||||
}
|
||||
|
||||
fn printErrorExit(comptime format: []const u8, args: var) noreturn {
|
||||
fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
||||
const stderr = std.io.getStdErr().outStream();
|
||||
stderr.print(format ++ "\n", args) catch std.os.exit(1);
|
||||
std.os.exit(1);
|
||||
|
@ -23,7 +23,7 @@ pub const gpa = std.heap.c_allocator;
|
||||
/// Take a pointer to c_void and cast it to a pointer to T. This function
|
||||
/// exists to avoid having the verbosity of the required alignment casts all
|
||||
/// over the code.
|
||||
pub fn voidCast(comptime T: type, ptr: var) *T {
|
||||
pub fn voidCast(comptime T: type, ptr: anytype) *T {
|
||||
// See https://github.com/ziglang/zig/issues/5618
|
||||
if (@TypeOf(ptr) != *c_void)
|
||||
@compileError("voidCast takes *c_void but " ++ @typeName(@TypeOf(ptr)) ++ " was provided");
|
||||
|
@ -140,7 +140,7 @@ pub fn ViewStack(comptime T: type) type {
|
||||
pub fn iter(
|
||||
start: ?*Node,
|
||||
dir: Direction,
|
||||
context: var,
|
||||
context: anytype,
|
||||
filter: fn (*View, @TypeOf(context)) bool,
|
||||
) Iter(@TypeOf(context)) {
|
||||
return .{ .it = start, .dir = dir, .context = context, .filter = filter };
|
||||
|
Loading…
Reference in New Issue
Block a user