From 1732c694428e274280cbdbf1032a6bfed2586b5d Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Sat, 26 Dec 2020 19:17:24 +0100 Subject: [PATCH] keyboard: set repeat_info to config values on creation --- river/Config.zig | 6 ++++++ river/Keyboard.zig | 4 +++- river/command/set_repeat.zig | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/river/Config.zig b/river/Config.zig index d5f9041..40f8cfd 100644 --- a/river/Config.zig +++ b/river/Config.zig @@ -81,6 +81,12 @@ view_opacity_delta: f32 = 1.0, /// Time between view opacity transition steps in msec view_opacity_delta_t: u31 = 20, +/// Keyboard repeat rate in characters per second +repeat_rate: u31 = 25, + +/// Keyboard repeat delay in milliseconds +repeat_delay: u31 = 600, + pub fn init() !Self { var self = Self{ .mode_to_id = std.StringHashMap(usize).init(util.gpa), diff --git a/river/Keyboard.zig b/river/Keyboard.zig index 2c3c4d5..42a59c4 100644 --- a/river/Keyboard.zig +++ b/river/Keyboard.zig @@ -58,7 +58,9 @@ pub fn init(self: *Self, seat: *Seat, input_device: *wlr.InputDevice) !void { const wlr_keyboard = self.input_device.device.keyboard; if (!wlr_keyboard.setKeymap(keymap)) return error.SetKeymapFailed; - wlr_keyboard.setRepeatInfo(25, 600); + + const config = &seat.input_manager.server.config; + wlr_keyboard.setRepeatInfo(config.repeat_rate, config.repeat_delay); self.key.setNotify(handleKey); wlr_keyboard.events.key.add(&self.key); diff --git a/river/command/set_repeat.zig b/river/command/set_repeat.zig index 8dec594..0c43ed0 100644 --- a/river/command/set_repeat.zig +++ b/river/command/set_repeat.zig @@ -30,8 +30,12 @@ pub fn setRepeat( if (args.len < 3) return Error.NotEnoughArguments; if (args.len > 3) return Error.TooManyArguments; - const rate = try std.fmt.parseInt(i32, args[1], 10); - const delay = try std.fmt.parseInt(i32, args[2], 10); + const rate = try std.fmt.parseInt(u31, args[1], 10); + const delay = try std.fmt.parseInt(u31, args[2], 10); + + const config = &seat.input_manager.server.config; + config.repeat_rate = rate; + config.repeat_delay = delay; var it = seat.keyboards.first; while (it) |node| : (it = node.next) {