cursor: add option to warp on output change

On output change, if the cursor is not already on the newly focused
output, it will now be warped to its center. The check is necessary,
since focusing outputs with the pointer will be implemented in
the future.
This commit is contained in:
Leon Henrik Plickat
2021-05-07 03:46:26 +02:00
committed by Isaac Freund
parent 505639432e
commit 085cca0d5e
5 changed files with 48 additions and 2 deletions

View File

@ -21,6 +21,7 @@ const server = &@import("../main.zig").server;
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
const Config = @import("../Config.zig");
pub fn borderWidth(
allocator: *std.mem.Allocator,
@ -81,6 +82,18 @@ pub fn borderColorUnfocused(
while (it) |node| : (it = node.next) node.data.damage.addWhole();
}
pub fn setCursorWarp(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
out: *?[]const u8,
) Error!void {
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments;
server.config.warp_cursor = std.meta.stringToEnum(Config.WarpCursorMode, args[1]) orelse
return Error.UnknownOption;
}
/// Parse a color in the format #RRGGBB or #RRGGBBAA
fn parseRgba(string: []const u8) ![4]f32 {
if (string[0] != '#' or (string.len != 7 and string.len != 9)) return error.InvalidRgba;