Handle termbox2 outside of authentication

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2024-08-04 20:42:00 +02:00
parent ef86ea19ac
commit c7f70ac78f
No known key found for this signature in database
GPG Key ID: 3E85EB44F610AD7F
2 changed files with 11 additions and 11 deletions

View File

@ -117,10 +117,6 @@ pub fn authenticate(config: Config, current_environment: Session.Environment, lo
removeUtmpEntry(&entry);
// Take back control of the TTY
_ = interop.termbox.tb_init();
_ = interop.termbox.tb_set_output_mode(interop.termbox.TB_OUTPUT_NORMAL);
if (shared_err.readError()) |err| return err;
}
@ -159,9 +155,6 @@ fn startSession(
// Execute what the user requested
std.posix.chdirZ(pwd.pw_dir.?) catch return error.ChangeDirectoryFailed;
// Give up control on the TTY
_ = interop.termbox.tb_shutdown();
switch (current_environment.display_server) {
.wayland => try executeWaylandCmd(pwd.pw_shell.?, config.wayland_cmd, current_environment.cmd),
.shell => try executeShellCmd(pwd.pw_shell.?),

View File

@ -648,6 +648,11 @@ pub fn main() !void {
update = true;
},
termbox.TB_KEY_ENTER => {
try info_line.addMessage(lang.authenticating, config.bg, config.fg);
InfoLine.clearRendered(allocator, buffer) catch {};
info_line.label.draw();
_ = termbox.tb_present();
if (config.save) save_last_settings: {
var file = std.fs.cwd().createFile(save_path, .{}) catch break :save_last_settings;
defer file.close();
@ -671,10 +676,8 @@ pub fn main() !void {
const password_text = try allocator.dupeZ(u8, password.text.items);
defer allocator.free(password_text);
try info_line.addMessage(lang.authenticating, config.bg, config.fg);
InfoLine.clearRendered(allocator, buffer) catch {};
info_line.label.draw();
_ = termbox.tb_present();
// Give up control on the TTY
_ = termbox.tb_shutdown();
session_pid = try std.posix.fork();
if (session_pid == 0) {
@ -690,6 +693,10 @@ pub fn main() !void {
session_pid = -1;
}
// Take back control of the TTY
_ = termbox.tb_init();
_ = termbox.tb_set_output_mode(termbox.TB_OUTPUT_NORMAL);
const auth_err = shared_err.readError();
if (auth_err) |err| {
auth_fails += 1;