feat: use MTK toolkit widgets in login.elf, improve login.elf draw performance
This commit is contained in:
@@ -41,8 +41,8 @@ static void initialize_login_mode(LoginState* ls) {
|
||||
ls->active_field = 0;
|
||||
montauk::strcpy(ls->username, "admin");
|
||||
ls->username_len = 5;
|
||||
ls->username_edit.cursor = ls->username_len;
|
||||
clear_field_selection(&ls->username_edit);
|
||||
gui::mtk::text_input_set_cursor(ls->username_input, ls->username_len,
|
||||
ls->username_len, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,10 +63,20 @@ extern "C" void _start() {
|
||||
montauk::set_mouse_bounds(ls->screen_w - 1, ls->screen_h - 1);
|
||||
load_login_wallpaper(ls);
|
||||
|
||||
// MTK theme (picks up the system accent). The compose buffer is only
|
||||
// needed when the framebuffer pitch is not tightly packed; otherwise the
|
||||
// renderer draws straight into the framebuffer back buffer.
|
||||
ls->theme = gui::mtk::make_theme();
|
||||
if (ls->fb.pitch() != ls->screen_w * (int)sizeof(uint32_t)) {
|
||||
ls->compose = (uint32_t*)montauk::alloc(
|
||||
(uint64_t)ls->screen_w * ls->screen_h * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
maybe_run_setup_session();
|
||||
initialize_login_mode(ls);
|
||||
|
||||
bool first_frame = true;
|
||||
uint64_t input_serial = montauk::input_wait(0, 0);
|
||||
for (;;) {
|
||||
bool mouse_changed = false;
|
||||
bool key_changed = false;
|
||||
@@ -95,9 +105,20 @@ extern "C" void _start() {
|
||||
if (first_frame || mouse_changed || key_changed) {
|
||||
draw_login_screen(ls);
|
||||
first_frame = false;
|
||||
montauk::sleep_ms(fast_mouse_path ? 1 : 4);
|
||||
} else {
|
||||
montauk::sleep_ms(16);
|
||||
}
|
||||
|
||||
// Event-driven wait: input_wait returns the instant the mouse or
|
||||
// keyboard ISR reports activity, so the cursor tracks the device with
|
||||
// no fixed-timer latency. timeoutMs is only an upper bound. Matches
|
||||
// the desktop's run loop; a plain sleep_ms() here cannot wake early
|
||||
// and makes every gesture start ~16 ms late.
|
||||
//
|
||||
// The login screen has no periodic UI (no clock, no caret blink, no
|
||||
// animation), so when idle it never needs to wake without input: pass
|
||||
// UINT64_MAX to block indefinitely and consume 0% CPU until the next
|
||||
// mouse/keyboard event, instead of waking ~62x/sec for nothing.
|
||||
uint64_t wait_ms = fast_mouse_path ? 1
|
||||
: ((mouse_changed || key_changed) ? 4 : UINT64_MAX);
|
||||
input_serial = montauk::input_wait(input_serial, wait_ms);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user