Wasm panel modules, widget host, merged plasmoid host design, and shell/UI work

Panel and wasm host
- The panel is built from wasm plasmoid modules (compositor/wasm: wasmer-backed host).
  Modules get capabilities by importing host interfaces; the host publishes data tables
  and serves a request queue (launch, focus window, set layout, inspector, load/unload
  modules). New WIT: windows, layout-control, inspector, modules, system.
- Merged two competing host designs: generic tables + requests are the base; the
  `system` snapshot and the id-stable `windows.all/focus` (Desktop Pulse) run on top of it.
- Panel widgets: load a .wasm from a path or file chooser, reorder by dragging,
  right-click replace/remove/add, saved to panel.edn.
- Desktop widget, system sampler (sysinfo), app catalog/humanised names, Interface
  Explorer (inspector), real font rendering (compositor/font, assets/fonts).

Compositor
- Drag the divider between tiled windows; lower tiled rows leave room for the title bar.
- Title-bar buttons, 12-hour clock, truncated titles, task-list/layout menus.
- DRM/KMS session, tcc debug builds (vendored tinycc incl. conftest.c), justfile
  recipes (modules, run, test), pixi.toml.

Known gaps
- The sources for the pulse, tasks, layout, inspector, module-manager, moon-* and
  clock-digital12 modules are not in the tree yet, so `just modules` stops at pulse and
  the host tests that load those modules fail until they land.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Sonnet 5.5 committed 2026-11-24 23:38:05 -08:00
1 parent 080377fd79
commit 0145981c6a
57 files changed
+11461 -221

No files matched your search

+52
View File
@@ -194,3 +194,55 @@ pub fn has_exe(name : String) -> Bool {
pub fn spawn(cmd : String, display : String) -> Bool {
c_spawn(str_to_utf8_bytes(cmd), str_to_utf8_bytes(display)) == 0
}
///|
extern "C" fn c_list_desktop(dir : Bytes) -> Bytes = "mp_list_desktop"
///|
extern "C" fn c_getenv(name : Bytes) -> Bytes = "mp_getenv"
///| Newline-separated names of the `*.desktop` files directly in `dir`.
pub fn list_desktop_files(dir : String) -> Array[String] {
let raw = c_list_desktop(str_to_utf8_bytes(dir))
let out : Array[String] = []
let sb = StringBuilder::new()
let mut i = 0
while i < raw.length() {
if raw[i] == b'\n' {
out.push(sb.to_string())
sb.reset()
} else {
sb.write_char(Int::unsafe_to_char(raw[i].to_int()))
}
i = i + 1
}
out
}
///| Environment variable, or "" when unset.
pub fn getenv(name : String) -> String {
let raw = c_getenv(str_to_utf8_bytes(name))
let sb = StringBuilder::new()
for i = 0; i < raw.length(); i = i + 1 {
sb.write_char(Int::unsafe_to_char(raw[i].to_int()))
}
sb.to_string()
}
///|
extern "C" fn c_mkdir_p(path : Bytes) -> Int = "mp_mkdir_p"
///| Create `path` and any missing parents; true when it exists afterwards.
pub fn mkdir_p(path : String) -> Bool {
c_mkdir_p(str_to_utf8_bytes(path)) == 0
}
///|
#borrow(path)
extern "C" fn c_read_proc(path : Bytes) -> Bytes = "mp_read_proc"
///| Contents of a small /proc or /sys file ("" when unreadable). Unlike `read_file_bytes`
/// this works on files that report size 0.
pub fn read_proc_bytes(path : String) -> Bytes {
c_read_proc(str_to_utf8_bytes(path))
}
+116 -2
View File
@@ -12,7 +12,10 @@
#include <sys/un.h>
#include <time.h>
#include <signal.h>
#include <sys/prctl.h>
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
#include "moonbit.h"
@@ -332,22 +335,133 @@ int32_t mp_has_exe(moonbit_bytes_t name_bytes) {
return found;
}
/* Private session bus for launched apps, so single-instance apps (Firefox, Kate,
* Dolphin...) don't forward the launch to an instance on the host session.
* Started lazily; dies with the compositor. */
static char private_bus[256];
static int private_bus_tried = 0;
static void start_private_bus(void) {
if (private_bus_tried) return;
private_bus_tried = 1;
int fds[2];
if (pipe(fds) != 0) return;
pid_t pid = fork();
if (pid < 0) { close(fds[0]); close(fds[1]); return; }
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGTERM);
close(fds[0]);
char arg[64];
snprintf(arg, sizeof(arg), "--print-address=%d", fds[1]);
execlp("dbus-daemon", "dbus-daemon", "--session", "--nofork", arg, (char *)NULL);
_exit(127);
}
close(fds[1]);
ssize_t n = read(fds[0], private_bus, sizeof(private_bus) - 1);
close(fds[0]);
if (n > 0) {
private_bus[n] = 0;
char *nl = strchr(private_bus, '\n');
if (nl) *nl = 0;
} else {
private_bus[0] = 0;
}
}
/* Launch `cmd` detached, with WAYLAND_DISPLAY pointing at our socket. Returns 0 on fork success. */
MOONBIT_FFI_EXPORT
int32_t mp_spawn(moonbit_bytes_t cmd_bytes, moonbit_bytes_t display_bytes) {
char cmd[256];
char cmd[2048];
char display[512];
bytes_to_cstr(cmd_bytes, cmd, sizeof(cmd));
bytes_to_cstr(display_bytes, display, sizeof(display));
signal(SIGCHLD, SIG_IGN); /* no zombies */
start_private_bus();
pid_t pid = fork();
if (pid < 0) return -1;
if (pid == 0) {
setsid();
if (private_bus[0]) setenv("DBUS_SESSION_BUS_ADDRESS", private_bus, 1);
setenv("WAYLAND_DISPLAY", display, 1);
unsetenv("DISPLAY");
execlp(cmd, cmd, (char *)NULL);
/* Make toolkits pick our Wayland socket, not X11 or the host session. */
setenv("XDG_SESSION_TYPE", "wayland", 1);
setenv("QT_QPA_PLATFORM", "wayland", 1);
setenv("GDK_BACKEND", "wayland", 1);
setenv("SDL_VIDEODRIVER", "wayland", 1);
setenv("MOZ_ENABLE_WAYLAND", "1", 1);
setenv("ELECTRON_OZONE_PLATFORM_HINT", "wayland", 1);
setenv("CLUTTER_BACKEND", "wayland", 1);
execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
_exit(127);
}
return 0;
}
/* Names of "*.desktop" files in `dir`, newline-separated. */
MOONBIT_FFI_EXPORT
moonbit_bytes_t mp_list_desktop(moonbit_bytes_t dir_bytes) {
char dir[512];
bytes_to_cstr(dir_bytes, dir, sizeof(dir));
DIR *d = opendir(dir);
if (!d) return moonbit_make_bytes_raw(0);
size_t cap = 4096, len = 0;
char *buf = malloc(cap);
struct dirent *e;
while ((e = readdir(d)) != NULL) {
size_t n = strlen(e->d_name);
if (n < 9 || strcmp(e->d_name + n - 8, ".desktop") != 0) continue;
if (len + n + 2 > cap) { cap = (len + n + 2) * 2; buf = realloc(buf, cap); }
memcpy(buf + len, e->d_name, n);
len += n;
buf[len++] = '\n';
}
closedir(d);
moonbit_bytes_t out = moonbit_make_bytes_raw((int32_t)len);
memcpy(out, buf, len);
free(buf);
return out;
}
MOONBIT_FFI_EXPORT
moonbit_bytes_t mp_getenv(moonbit_bytes_t name_bytes) {
char name[128];
bytes_to_cstr(name_bytes, name, sizeof(name));
const char *v = getenv(name);
if (!v) return moonbit_make_bytes_raw(0);
size_t n = strlen(v);
moonbit_bytes_t out = moonbit_make_bytes_raw((int32_t)n);
memcpy(out, v, n);
return out;
}
/* mkdir -p; returns 0 when the directory exists afterwards. */
MOONBIT_FFI_EXPORT
int32_t mp_mkdir_p(moonbit_bytes_t path_bytes) {
char path[512];
bytes_to_cstr(path_bytes, path, sizeof(path));
for (char *p = path + 1; *p; p++) {
if (*p == '/') {
*p = 0;
mkdir(path, 0755);
*p = '/';
}
}
if (mkdir(path, 0755) != 0 && errno != EEXIST) return -1;
return 0;
}
/* Read a small /proc or /sys file (they report size 0, so read until EOF; capped at 64 KiB). */
MOONBIT_FFI_EXPORT
moonbit_bytes_t mp_read_proc(moonbit_bytes_t path_bytes) {
char path[512];
bytes_to_cstr(path_bytes, path, sizeof(path));
FILE *f = fopen(path, "rb");
if (!f) return moonbit_make_bytes_raw(0);
static char buf[65536];
size_t n = fread(buf, 1, sizeof(buf), f);
fclose(f);
moonbit_bytes_t out = moonbit_make_bytes_raw((int32_t)n);
memcpy(out, buf, n);
return out;
}