control: implement set-repeat

This commit is contained in:
Bonicgamer
2020-11-18 09:28:33 -05:00
committed by GitHub
parent 1626203c44
commit cbd4a2807b
4 changed files with 50 additions and 0 deletions

View File

@ -67,6 +67,7 @@ const str_to_impl_fn = [_]struct {
.{ .name = "resize", .impl = @import("command/move.zig").resize },
.{ .name = "send-to-output", .impl = @import("command/send_to_output.zig").sendToOutput },
.{ .name = "set-focused-tags", .impl = @import("command/tags.zig").setFocusedTags },
.{ .name = "set-repeat", .impl = @import("command/set_repeat.zig").setRepeat },
.{ .name = "set-view-tags", .impl = @import("command/tags.zig").setViewTags },
.{ .name = "snap", .impl = @import("command/move.zig").snap },
.{ .name = "spawn", .impl = @import("command/spawn.zig").spawn },

View File

@ -0,0 +1,42 @@
// This file is part of river, a dynamic tiling wayland compositor.
//
// Copyright 2020 The River Developers
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
const c = @import("../c.zig");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
/// Set the repeat rate and delay for all keyboards.
pub fn setRepeat(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
out: *?[]const u8,
) Error!void {
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);
var it = seat.keyboards.first;
while (it) |node| : (it = node.next) {
c.wlr_keyboard_set_repeat_info(node.data.wlr_keyboard, rate, delay);
}
}