build: update to Zig 0.11.0
This commit is contained in:
@ -108,12 +108,12 @@ fn parseRgba(string: []const u8) ![4]f32 {
|
||||
const b = try fmt.parseInt(u8, string[6..8], 16);
|
||||
const a = if (string.len == 10) try fmt.parseInt(u8, string[8..10], 16) else 255;
|
||||
|
||||
const alpha = @intToFloat(f32, a) / 255.0;
|
||||
const alpha = @as(f32, @floatFromInt(a)) / 255.0;
|
||||
|
||||
return [4]f32{
|
||||
@intToFloat(f32, r) / 255.0 * alpha,
|
||||
@intToFloat(f32, g) / 255.0 * alpha,
|
||||
@intToFloat(f32, b) / 255.0 * alpha,
|
||||
@as(f32, @floatFromInt(r)) / 255.0 * alpha,
|
||||
@as(f32, @floatFromInt(g)) / 255.0 * alpha,
|
||||
@as(f32, @floatFromInt(b)) / 255.0 * alpha,
|
||||
alpha,
|
||||
};
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ pub fn declareMode(
|
||||
|
||||
const owned_name = try util.gpa.dupeZ(u8, new_mode_name);
|
||||
|
||||
const id = @intCast(u32, config.modes.items.len);
|
||||
const id: u32 = @intCast(config.modes.items.len);
|
||||
config.mode_to_id.putAssumeCapacityNoClobber(owned_name, id);
|
||||
config.modes.appendAssumeCapacity(.{ .name = owned_name });
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ pub fn listInputs(
|
||||
});
|
||||
}
|
||||
|
||||
out.* = input_list.toOwnedSlice();
|
||||
out.* = try input_list.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn listInputConfigs(
|
||||
@ -68,7 +68,7 @@ pub fn listInputConfigs(
|
||||
var input_list = std.ArrayList(u8).init(util.gpa);
|
||||
const writer = input_list.writer();
|
||||
|
||||
for (server.input_manager.configs.items) |*input_config, i| {
|
||||
for (server.input_manager.configs.items, 0..) |*input_config, i| {
|
||||
if (i > 0) try input_list.appendSlice("\n");
|
||||
|
||||
try writer.print("{s}\n", .{input_config.identifier});
|
||||
@ -119,7 +119,7 @@ pub fn listInputConfigs(
|
||||
}
|
||||
}
|
||||
|
||||
out.* = input_list.toOwnedSlice();
|
||||
out.* = try input_list.toOwnedSlice();
|
||||
}
|
||||
|
||||
pub fn input(
|
||||
@ -197,7 +197,7 @@ pub fn input(
|
||||
} else if (mem.eql(u8, "scroll-button", args[2])) {
|
||||
const ret = c.libevdev_event_code_from_name(c.EV_KEY, args[3].ptr);
|
||||
if (ret < 1) return Error.InvalidButton;
|
||||
input_config.scroll_button = InputConfig.ScrollButton{ .button = @intCast(u32, ret) };
|
||||
input_config.scroll_button = InputConfig.ScrollButton{ .button = @intCast(ret) };
|
||||
} else {
|
||||
return Error.UnknownCommand;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ fn mappingExists(
|
||||
keysym: xkb.Keysym,
|
||||
release: bool,
|
||||
) ?usize {
|
||||
for (mappings.items) |mapping, i| {
|
||||
for (mappings.items, 0..) |mapping, i| {
|
||||
if (meta.eql(mapping.modifiers, modifiers) and
|
||||
mapping.keysym == keysym and mapping.options.release == release)
|
||||
{
|
||||
@ -217,7 +217,7 @@ fn switchMappingExists(
|
||||
switch_type: Switch.Type,
|
||||
switch_state: Switch.State,
|
||||
) ?usize {
|
||||
for (switch_mappings.items) |mapping, i| {
|
||||
for (switch_mappings.items, 0..) |mapping, i| {
|
||||
if (mapping.switch_type == switch_type and meta.eql(mapping.switch_state, switch_state)) {
|
||||
return i;
|
||||
}
|
||||
@ -232,7 +232,7 @@ fn pointerMappingExists(
|
||||
modifiers: wlr.Keyboard.ModifierMask,
|
||||
event_code: u32,
|
||||
) ?usize {
|
||||
for (pointer_mappings.items) |mapping, i| {
|
||||
for (pointer_mappings.items, 0..) |mapping, i| {
|
||||
if (meta.eql(mapping.modifiers, modifiers) and mapping.event_code == event_code) {
|
||||
return i;
|
||||
}
|
||||
@ -248,7 +248,7 @@ fn parseEventCode(name: [:0]const u8, out: *?[]const u8) !u32 {
|
||||
return Error.Other;
|
||||
}
|
||||
|
||||
return @intCast(u32, event_code);
|
||||
return @intCast(event_code);
|
||||
}
|
||||
|
||||
fn parseKeysym(name: [:0]const u8, out: *?[]const u8) !xkb.Keysym {
|
||||
|
@ -104,7 +104,7 @@ pub fn resize(
|
||||
// up against an output edge.
|
||||
const diff_width = prev_width - view.pending.box.width;
|
||||
// Do not grow bigger than the output
|
||||
view.pending.box.width = math.min(
|
||||
view.pending.box.width = @min(
|
||||
view.pending.box.width,
|
||||
output_width - 2 * server.config.border_width,
|
||||
);
|
||||
@ -116,7 +116,7 @@ pub fn resize(
|
||||
view.applyConstraints(&view.pending.box);
|
||||
const diff_height = prev_height - view.pending.box.height;
|
||||
// Do not grow bigger than the output
|
||||
view.pending.box.height = math.min(
|
||||
view.pending.box.height = @min(
|
||||
view.pending.box.height,
|
||||
output_height - 2 * server.config.border_width,
|
||||
);
|
||||
|
@ -109,15 +109,15 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
|
||||
const wlr_output = server.root.output_layout.adjacentOutput(
|
||||
direction,
|
||||
seat.focused_output.?.wlr_output,
|
||||
@intToFloat(f64, focus_box.x + @divTrunc(focus_box.width, 2)),
|
||||
@intToFloat(f64, focus_box.y + @divTrunc(focus_box.height, 2)),
|
||||
@floatFromInt(focus_box.x + @divTrunc(focus_box.width, 2)),
|
||||
@floatFromInt(focus_box.y + @divTrunc(focus_box.height, 2)),
|
||||
) orelse return null;
|
||||
return @intToPtr(*Output, wlr_output.data);
|
||||
return @as(*Output, @ptrFromInt(wlr_output.data));
|
||||
} else {
|
||||
// Check if an output matches by name
|
||||
var it = server.root.active_outputs.iterator(.forward);
|
||||
while (it.next()) |output| {
|
||||
if (mem.eql(u8, mem.span(output.wlr_output.name), str)) {
|
||||
if (mem.eql(u8, mem.sliceTo(output.wlr_output.name, 0), str)) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ pub fn listRules(_: *Seat, args: []const [:0]const u8, out: *?[]const u8) Error!
|
||||
var buffer = std.ArrayList(u8).init(util.gpa);
|
||||
const writer = buffer.writer();
|
||||
|
||||
try fmt.formatBuf("title", .{ .width = title_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf("app-id", .{ .width = app_id_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf("title", .{ .width = title_column_max, .alignment = .left }, writer);
|
||||
try fmt.formatBuf("app-id", .{ .width = app_id_column_max, .alignment = .left }, writer);
|
||||
try writer.writeAll("action\n");
|
||||
|
||||
switch (list) {
|
||||
@ -169,8 +169,8 @@ pub fn listRules(_: *Seat, args: []const [:0]const u8, out: *?[]const u8) Error!
|
||||
else => unreachable,
|
||||
};
|
||||
for (rules) |rule| {
|
||||
try fmt.formatBuf(rule.title_glob, .{ .width = title_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf(rule.app_id_glob, .{ .width = app_id_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf(rule.title_glob, .{ .width = title_column_max, .alignment = .left }, writer);
|
||||
try fmt.formatBuf(rule.app_id_glob, .{ .width = app_id_column_max, .alignment = .left }, writer);
|
||||
try writer.print("{s}\n", .{switch (list) {
|
||||
.float => if (rule.value) "float" else "no-float",
|
||||
.ssd => if (rule.value) "ssd" else "csd",
|
||||
@ -181,12 +181,12 @@ pub fn listRules(_: *Seat, args: []const [:0]const u8, out: *?[]const u8) Error!
|
||||
.tag => {
|
||||
const rules = server.config.tag_rules.rules.items;
|
||||
for (rules) |rule| {
|
||||
try fmt.formatBuf(rule.title_glob, .{ .width = title_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf(rule.app_id_glob, .{ .width = app_id_column_max, .alignment = .Left }, writer);
|
||||
try fmt.formatBuf(rule.title_glob, .{ .width = title_column_max, .alignment = .left }, writer);
|
||||
try fmt.formatBuf(rule.app_id_glob, .{ .width = app_id_column_max, .alignment = .left }, writer);
|
||||
try writer.print("{b}\n", .{rule.value});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
out.* = buffer.toOwnedSlice();
|
||||
out.* = try buffer.toOwnedSlice();
|
||||
}
|
||||
|
Reference in New Issue
Block a user