fix: kernel and desktop bug fixes

This commit is contained in:
2026-05-14 11:31:14 +02:00
parent a7ff1f0a72
commit bb12aeb9b9
11 changed files with 507 additions and 106 deletions
+14 -3
View File
@@ -58,10 +58,21 @@ inline int menu_row_height(const MenuRow& row) {
}
inline int menu_total_height() {
// Single-pass walk to avoid O(N^2) from menu_row_visible repeatedly
// counting categories from the start.
int h = 10; // top + bottom padding
for (int i = 0; i < menu_row_count; i++)
if (menu_row_visible(i))
h += menu_row_height(menu_rows[i]);
int cur_cat = -1;
for (int i = 0; i < menu_row_count; i++) {
const MenuRow& row = menu_rows[i];
if (row.is_category) cur_cat++;
bool visible = true;
if (!row.is_category) {
if (cur_cat >= 0 && cur_cat < MENU_NUM_CATS) {
visible = menu_cat_expanded[cur_cat];
}
}
if (visible) h += menu_row_height(row);
}
return h;
}