From 67d07e84b01191a5c48d3f2e797a831e75895ce2 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 20 Jun 2022 19:51:34 +0200 Subject: [PATCH] InputDevice: use "switch" in input device names Currently we use "switch_device" because that's what the enum variant happens to be named in zig-wlroots so that it doesn't conflict with the switch keyword. This however wasn't really thought through and "switch" makes more sense to expose to the user. --- river/InputDevice.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/river/InputDevice.zig b/river/InputDevice.zig index 5781a14..413e8f8 100644 --- a/river/InputDevice.zig +++ b/river/InputDevice.zig @@ -36,18 +36,23 @@ destroy: wl.Listener(*wlr.InputDevice) = wl.Listener(*wlr.InputDevice).init(hand identifier: []const u8, pub fn init(self: *InputDevice, device: *wlr.InputDevice) !void { + const device_type: []const u8 = switch (device.type) { + .switch_device => "switch", + else => @tagName(device.type), + }; + const identifier = try std.fmt.allocPrint( util.gpa, "{s}-{}-{}-{s}", .{ - @tagName(device.type), + device_type, device.vendor, device.product, mem.trim(u8, mem.span(device.name), &ascii.spaces), }, ); for (identifier) |*char| { - if (char.* == ' ' or !ascii.isPrint(char.*)) { + if (!ascii.isGraph(char.*)) { char.* = '_'; } }