Introduce mode "locked"

This mode is automatically entered when the screen is locked.
This commit is contained in:
Leon Henrik Plickat
2020-10-19 12:39:52 +02:00
committed by Isaac Freund
parent 744e6b3052
commit 03a2da9690
5 changed files with 48 additions and 9 deletions

View File

@ -30,9 +30,18 @@ pub fn enterMode(
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 2) return Error.TooManyArguments;
if (seat.mode_id == 1) {
out.* = try std.fmt.allocPrint(
allocator,
"manually exiting mode 'locked' is not allowed",
.{},
);
return Error.Other;
}
const config = seat.input_manager.server.config;
const target_mode = args[1];
seat.mode_id = config.mode_to_id.get(target_mode) orelse {
const mode_id = config.mode_to_id.get(target_mode) orelse {
out.* = try std.fmt.allocPrint(
allocator,
"cannot enter non-existant mode '{}'",
@ -40,4 +49,15 @@ pub fn enterMode(
);
return Error.Other;
};
if (mode_id == 1) {
out.* = try std.fmt.allocPrint(
allocator,
"manually entering mode 'locked' is not allowed",
.{},
);
return Error.Other;
}
seat.mode_id = mode_id;
}