feat: add SYS_FUTEX_WAIT and SYS_FUTEX_WAKE syscalls; revamp desktop application categories
This commit is contained in:
1 parent
60ca9c78c7
commit
abfd9de8f6
35 files changed
+545
-70
No files matched your search
@@ -121,7 +121,11 @@ void desktop_scan_apps(DesktopState* ds) {
|
||||
const char* name = doc.get_string("app.name", "Unknown");
|
||||
const char* binary = doc.get_string("app.binary", "");
|
||||
const char* icon_file = doc.get_string("app.icon", "");
|
||||
const char* category = doc.get_string("menu.category", "Applications");
|
||||
const char* category = doc.get_string("menu.category", "Productivity");
|
||||
// "Applications" was the old catch-all; keep older manifests out of
|
||||
// a stray custom category.
|
||||
if (!category[0] || montauk::streq(category, "Applications"))
|
||||
category = "Productivity";
|
||||
bool visible = doc.get_bool("menu.visible", true);
|
||||
bool launch_with_home = doc.get_bool("launch.pass_home_dir", true);
|
||||
const char* section_name = doc.get_string("desktop.section", "apps");
|
||||
@@ -197,18 +201,55 @@ void desktop_scan_apps(DesktopState* ds) {
|
||||
// Menu Builder
|
||||
// ============================================================================
|
||||
|
||||
// Category definitions and their ordering
|
||||
static const char* CATEGORY_NAMES[] = { "Applications", "Internet", "System", "Games" };
|
||||
static constexpr int NUM_CATEGORIES = 4;
|
||||
// Predefined categories and their ordering. Manifests may name any other
|
||||
// category; those are appended after these, sorted by name.
|
||||
// Builtins reference these by index (DesktopBuiltinEntry::launcher_category).
|
||||
static const char* CATEGORY_NAMES[] = {
|
||||
"Productivity", "Media", "Internet",
|
||||
"Utilities", "Games", "Hardware", "System",
|
||||
};
|
||||
static constexpr int NUM_CATEGORIES = sizeof(CATEGORY_NAMES) / sizeof(CATEGORY_NAMES[0]);
|
||||
|
||||
static bool category_eq(const char* a, const char* b) {
|
||||
for (;; a++, b++) {
|
||||
char ca = (*a >= 'A' && *a <= 'Z') ? *a + 32 : *a;
|
||||
char cb = (*b >= 'A' && *b <= 'Z') ? *b + 32 : *b;
|
||||
if (ca != cb) return false;
|
||||
if (!ca) return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int category_cmp(const char* a, const char* b) {
|
||||
for (;; a++, b++) {
|
||||
char ca = (*a >= 'A' && *a <= 'Z') ? *a + 32 : *a;
|
||||
char cb = (*b >= 'A' && *b <= 'Z') ? *b + 32 : *b;
|
||||
if (ca != cb || !ca) return (int)(unsigned char)ca - (int)(unsigned char)cb;
|
||||
}
|
||||
}
|
||||
|
||||
static bool menu_item_shown(DesktopState* ds, const DesktopItem* item) {
|
||||
return item->menu_visible && !(item->admin_only && !ds->is_admin);
|
||||
}
|
||||
|
||||
static void menu_add_manifest_items(DesktopState* ds, const char* category) {
|
||||
for (int x = 0; x < ds->desktop_item_count; x++) {
|
||||
DesktopItem* item = &ds->desktop_items[x];
|
||||
if (!menu_item_shown(ds, item)) continue;
|
||||
if (category_eq(item->category, category)) {
|
||||
menu_add_external(item->name, item->binary_path,
|
||||
&item->icon, item->launch_with_home);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void desktop_build_menu(DesktopState* ds) {
|
||||
menu_row_count = 0;
|
||||
int builtin_count = 0;
|
||||
const DesktopBuiltinEntry* builtins = desktop_builtin_registry(&builtin_count);
|
||||
|
||||
// Build each category
|
||||
// Build each predefined category
|
||||
for (int cat = 0; cat < NUM_CATEGORIES; cat++) {
|
||||
menu_add_category(CATEGORY_NAMES[cat]);
|
||||
int header = menu_add_category(CATEGORY_NAMES[cat]);
|
||||
|
||||
// Add desktop builtins in this category
|
||||
for (int b = 0; b < builtin_count; b++) {
|
||||
@@ -218,19 +259,48 @@ void desktop_build_menu(DesktopState* ds) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add manifest-backed items in this category.
|
||||
menu_add_manifest_items(ds, CATEGORY_NAMES[cat]);
|
||||
|
||||
// Drop the header again if nothing landed under it.
|
||||
if (header >= 0 && menu_row_count == header + 1) menu_row_count = header;
|
||||
}
|
||||
|
||||
// Custom categories: the first item of each distinct, non-predefined
|
||||
// category (case-insensitive) represents it; emit them in name order.
|
||||
const DesktopItem** custom = ds->desktop_item_count > 0
|
||||
? (const DesktopItem**)montauk::malloc(
|
||||
(uint64_t)ds->desktop_item_count * sizeof(DesktopItem*))
|
||||
: nullptr;
|
||||
int custom_count = 0;
|
||||
if (custom) {
|
||||
for (int x = 0; x < ds->desktop_item_count; x++) {
|
||||
DesktopItem* item = &ds->desktop_items[x];
|
||||
if (!item->menu_visible || (item->admin_only && !ds->is_admin)) continue;
|
||||
if (montauk::streq(item->category, CATEGORY_NAMES[cat])) {
|
||||
menu_add_external(item->name, item->binary_path,
|
||||
&item->icon, item->launch_with_home);
|
||||
const DesktopItem* item = &ds->desktop_items[x];
|
||||
if (!menu_item_shown(ds, item)) continue;
|
||||
|
||||
bool known = false;
|
||||
for (int c = 0; c < NUM_CATEGORIES && !known; c++)
|
||||
known = category_eq(item->category, CATEGORY_NAMES[c]);
|
||||
for (int c = 0; c < custom_count && !known; c++)
|
||||
known = category_eq(item->category, custom[c]->category);
|
||||
if (known) continue;
|
||||
|
||||
int pos = custom_count;
|
||||
while (pos > 0 && category_cmp(custom[pos - 1]->category, item->category) > 0) {
|
||||
custom[pos] = custom[pos - 1];
|
||||
pos--;
|
||||
}
|
||||
custom[pos] = item;
|
||||
custom_count++;
|
||||
}
|
||||
for (int c = 0; c < custom_count; c++) {
|
||||
menu_add_category(custom[c]->category);
|
||||
menu_add_manifest_items(ds, custom[c]->category);
|
||||
}
|
||||
montauk::mfree(custom);
|
||||
}
|
||||
|
||||
// Divider + always-visible entries
|
||||
menu_add_category(""); // divider (cat 4, always expanded)
|
||||
menu_add_category(""); // divider (always expanded)
|
||||
for (int b = 0; b < builtin_count; b++) {
|
||||
if (builtins[b].launcher_footer) {
|
||||
menu_add_embedded(builtins[b].label, builtins[b].id,
|
||||
|
||||
Reference in new issue
Block a user