feat: add Console Session mode

This commit is contained in:
daniel committed 2026-06-17 18:00:47 +02:00
1 parent 36b03f070d
commit 75411e953f
5 files changed
+332 -46

No files matched your search

+26
View File
@@ -51,6 +51,20 @@ LoginLayout layout_login_screen(LoginState* ls) {
y = lo.password_field.y + FIELD_H + FIELD_GAP;
}
// Session selector (login mode only): a "Session" label above two radio
// options that pick the desktop or the full-screen console.
if (ls->mode == MODE_LOGIN) {
lo.session_label_y = y;
int ry = y + sfh + LABEL_GAP;
int radio_h = 22;
int half = lo.content_w / 2;
lo.desktop_radio = {lo.content_x, ry, half, radio_h};
lo.console_radio = {lo.content_x + half, ry, half, radio_h};
y = ry + radio_h + FIELD_GAP;
} else {
lo.session_label_y = -1;
}
if (ls->show_error) {
lo.error_y = y;
y += sfh + 12;
@@ -81,11 +95,14 @@ LoginLayout layout_login_screen(LoginState* ls) {
lo.shutdown_button = offset_rect(lo.shutdown_button, card_x, card_y);
lo.reboot_button = offset_rect(lo.reboot_button, card_x, card_y);
lo.submit_button = offset_rect(lo.submit_button, card_x, card_y);
lo.desktop_radio = offset_rect(lo.desktop_radio, card_x, card_y);
lo.console_radio = offset_rect(lo.console_radio, card_x, card_y);
lo.content_x += card_x;
lo.heading_y += card_y;
lo.subtitle_y += card_y;
if (lo.error_y >= 0) lo.error_y += card_y;
if (lo.session_label_y >= 0) lo.session_label_y += card_y;
return lo;
}
@@ -155,6 +172,15 @@ void draw_login_screen(LoginState* ls) {
ls->password_input, true, ls->active_field == 1);
}
// ==== Session selector ====
if (ls->mode == MODE_LOGIN && lo.session_label_y >= 0) {
c.text(lo.content_x, lo.session_label_y, "Session", th.text_muted);
mtk::draw_radio(c, lo.desktop_radio, "Desktop",
ls->session_mode == SESSION_DESKTOP, th);
mtk::draw_radio(c, lo.console_radio, "Console",
ls->session_mode == SESSION_CONSOLE, th);
}
if (ls->show_error && lo.error_y >= 0)
c.text(lo.content_x, lo.error_y, ls->error_msg, th.danger);