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

+272 -25
View File
@@ -10,6 +10,8 @@ pub(all) struct HostWindow {
mut maximized : Bool
mut fullscreen : Bool
mut surface : @scene.ShmBufferSnapshot?
/// A size change still to be sent to the client (coalesced while dragging a divider).
mut cfg_dirty : Bool
}
///|
@@ -32,6 +34,8 @@ pub(all) struct MoonPlasmaCompositor {
mut press_fwd : Bool
mut kbd_win : UInt64?
mut mods : UInt
/// A Super key is down and nothing else was pressed since: releasing it opens the launcher.
mut super_solo : Bool
mut layout_mode : @wm.LayoutMode
}
@@ -42,6 +46,7 @@ pub fn MoonPlasmaCompositor::new(
output_w : Int,
output_h : Int,
) -> MoonPlasmaCompositor? {
ignore(@font.install()) // Adwaita Mono; keeps the bitmap font if it's missing
let server = match @wayland.WaylandServer::listen(socket_path, output_w, output_h) {
Some(s) => s
None => return None
@@ -58,6 +63,8 @@ pub fn MoonPlasmaCompositor::new(
excl_top=32, // room for the server-side title bar drawn above each client
excl_bottom=theme.panel_height,
)
let shell = @shell.DesktopShell::new(socket_path)
shell.set_output(theme, output_w, output_h)
Some({
server,
wm,
@@ -67,7 +74,7 @@ pub fn MoonPlasmaCompositor::new(
work_area,
windows: {},
damage: @scene.DamageTracker::new(),
shell: @shell.DesktopShell::new(socket_path),
shell,
ptr_x: 0.0,
ptr_y: 0.0,
ptr_win: None,
@@ -75,12 +82,14 @@ pub fn MoonPlasmaCompositor::new(
press_fwd: false,
kbd_win: None,
mods: 0U,
super_solo: false,
layout_mode: @wm.LayoutMode::Tiling,
})
}
///|
pub fn MoonPlasmaCompositor::close(self : MoonPlasmaCompositor) -> Unit {
self.shell.shutdown()
self.server.close()
}
@@ -95,14 +104,20 @@ fn MoonPlasmaCompositor::apply_actions(
match self.windows.get(wid) {
Some(win) => {
win.geometry = @scene.Rect::new(r.x, r.y, r.w, r.h)
self.server.send_toplevel_configure(
wid,
r.w,
r.h,
win.focused,
win.maximized,
win.fullscreen,
)
if self.split_drag is Some(_) {
// Dragging: send one configure per frame, not one per mouse event.
win.cfg_dirty = true
} else {
win.cfg_dirty = false
self.server.send_toplevel_configure(
wid,
r.w,
r.h,
win.focused,
win.maximized,
win.fullscreen,
)
}
self.damage.mark_full()
}
None => ()
@@ -130,8 +145,26 @@ fn MoonPlasmaCompositor::apply_actions(
}
}
///| Send the size changes coalesced during a divider drag.
fn MoonPlasmaCompositor::flush_configures(self : MoonPlasmaCompositor) -> Unit {
for wid, win in self.windows {
if win.cfg_dirty {
win.cfg_dirty = false
self.server.send_toplevel_configure(
wid,
win.geometry.w,
win.geometry.h,
win.focused,
win.maximized,
win.fullscreen,
)
}
}
}
///|
pub fn MoonPlasmaCompositor::step(self : MoonPlasmaCompositor) -> Unit {
self.flush_configures()
let events = self.server.poll_events()
for ev in events {
match ev {
@@ -145,6 +178,7 @@ pub fn MoonPlasmaCompositor::step(self : MoonPlasmaCompositor) -> Unit {
maximized: false,
fullscreen: false,
surface: None,
cfg_dirty: false,
}
self.windows.set(wid, win)
let rec : @wm.WindowRecord = {
@@ -250,15 +284,13 @@ pub fn MoonPlasmaCompositor::set_layout_mode(
pub fn MoonPlasmaCompositor::compose_frame(
self : MoonPlasmaCompositor,
) -> @renderer.Pixmap {
self.flush_configures()
let scene = @scene.SceneGraph::new(self.output_w, self.output_h)
let order = self.wm.stacking_order()
let titles : Array[String] = []
for wid in order {
match self.windows.get(wid) {
Some(win) => {
let label = if win.title.length() > 0 { win.title } else { win.app_id }
titles.push(label)
let (insets, deco_ops) = @scene.build_breeze_decoration(
win.title,
win.app_id,
@@ -284,18 +316,51 @@ pub fn MoonPlasmaCompositor::compose_frame(
}
}
let layout_label = match self.layout_mode {
@wm.LayoutMode::Tiling => "BSP Tiling"
@wm.LayoutMode::Floating => "Floating"
@wm.LayoutMode::Monocle => "Monocle"
self.shell.layout_sel = match self.layout_mode {
@wm.LayoutMode::Tiling => 0
@wm.LayoutMode::Monocle => 1
@wm.LayoutMode::Floating => 2
}
let (bg_ops, panel_ops) = self.shell.render(
self.output_w,
self.output_h,
self.theme,
layout_label,
titles,
)
// The task list shows every window, minimized ones too (so they can be restored).
let wins : Array[@shell.WinInfo] = []
for wid in order {
match self.windows.get(wid) {
Some(win) =>
wins.push({
id: win.id,
title: if win.title.length() > 0 { win.title } else { win.app_id },
focused: win.focused,
minimized: false,
})
None => ()
}
}
for id, r in self.wm.windows {
if r.minimized {
match self.windows.get(id) {
Some(win) =>
wins.push({
id,
title: if win.title.length() > 0 { win.title } else { win.app_id },
focused: false,
minimized: true,
})
None => ()
}
}
}
self.shell.windows = wins
// The window list the `windows` interface serves to wasm widgets (task-bar order).
let entries : Array[@wasm.WindowEntry] = []
for w in wins {
match self.windows.get(w.id) {
Some(win) => entries.push({ id: w.id, title: w.title, app_id: win.app_id, focused: w.focused })
None => ()
}
}
self.shell.win_list = entries
let (bg_ops, panel_ops) = self.shell.render(self.output_w, self.output_h, self.theme)
self.run_shell_actions()
scene.background_ops = bg_ops
scene.panel_ops = panel_ops
ignore(self.damage.take_damage(self.output_w, self.output_h))
@@ -390,6 +455,104 @@ fn MoonPlasmaCompositor::window_at(self : MoonPlasmaCompositor, x : Int, y : Int
None
}
///| Title-bar button under (x, y) for window `wid`: 1 minimize, 2 maximize, 3 close, 0 none.
/// Mirrors the layout in `build_breeze_decoration` (18px buttons, 8px apart, 10px from the right edge).
fn MoonPlasmaCompositor::title_button_at(
self : MoonPlasmaCompositor,
wid : UInt64,
x : Int,
y : Int,
) -> Int {
match self.windows.get(wid) {
None => 0
Some(win) => {
let g = win.geometry
let outer_w = g.w + 4
let lx = x - (g.x - 2)
let ly = y - (g.y - 32)
let size = 18
let by = (32 - size) / 2
if ly < by - 3 || ly >= by + size + 3 {
return 0
}
let close_x = outer_w - 10 - size
let max_x = close_x - 8 - size
let min_x = max_x - 8 - size
if lx >= close_x - 3 && lx < close_x + size + 3 {
3
} else if lx >= max_x - 3 && lx < max_x + size + 3 {
2
} else if lx >= min_x - 3 && lx < min_x + size + 3 {
1
} else {
0
}
}
}
}
///| Activate the title-bar button `btn` of window `wid`.
fn MoonPlasmaCompositor::press_title_button(
self : MoonPlasmaCompositor,
wid : UInt64,
btn : Int,
) -> Unit {
self.leave_pointer()
let req = match btn {
1 => @wm.WindowRequest::Minimize(true)
2 => {
let maxed = match self.wm.windows.get(wid) {
Some(r) => r.maximized
None => false
}
@wm.WindowRequest::Maximize(!maxed)
}
_ => @wm.WindowRequest::Close
}
self.apply_actions(self.wm.handle_request(wid, req, self.work_area))
if btn == 1 {
// Hand focus to the top-most remaining window.
let order = self.wm.stacking_order()
if order.length() > 0 {
let top = order[order.length() - 1]
self.apply_actions([@wm.WmAction::Focus(top), @wm.WmAction::Raise(top)])
} else {
self.set_kbd_focus(None)
}
}
self.damage.mark_full()
}
///| Restore a minimized window (or focus a visible one) from its task-bar pill.
fn MoonPlasmaCompositor::activate_task(self : MoonPlasmaCompositor, wid : UInt64) -> Unit {
let minimized = match self.wm.windows.get(wid) {
Some(r) => r.minimized
None => return
}
if minimized {
self.apply_actions(
self.wm.handle_request(wid, @wm.WindowRequest::Minimize(false), self.work_area),
)
}
self.apply_actions([@wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid)])
}
///| Carry out what panel modules asked for: focus a window, switch layout.
fn MoonPlasmaCompositor::run_shell_actions(self : MoonPlasmaCompositor) -> Unit {
for a in self.shell.take_actions() {
match a {
@shell.ShellAction::FocusWindow(wid) => self.activate_task(wid)
@shell.ShellAction::SetLayout(m) =>
match m {
0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
1 => self.set_layout_mode(@wm.LayoutMode::Monocle)
2 => self.set_layout_mode(@wm.LayoutMode::Floating)
_ => ()
}
}
}
}
///| Tiling divider under (x, y), with a few pixels of slack either side.
fn MoonPlasmaCompositor::handle_at(
self : MoonPlasmaCompositor,
@@ -467,6 +630,20 @@ pub fn MoonPlasmaCompositor::handle_input(
self.ptr_y = y
let xi = x.to_int()
let yi = y.to_int()
if self.shell.inspecting() {
self.leave_pointer()
let id = match self.shell.component_at(xi, yi) {
"" =>
match self.window_at(xi, yi) {
Some((_, true)) => "window-surface"
Some((_, false)) => "window-decoration"
None => "desktop"
}
sid => sid
}
self.shell.set_hover(id, xi, yi)
return
}
if self.shell.pointer_move(xi, yi) || self.shell.hit(xi, yi) {
self.leave_pointer()
return
@@ -482,6 +659,17 @@ pub fn MoonPlasmaCompositor::handle_input(
self.leave_pointer()
return
}
match self.split_drag {
Some(h) => {
self.apply_actions(self.wm.drag_split(h, xi, yi, self.work_area))
return
}
None => ()
}
if self.handle_at(xi, yi) is Some(_) {
self.leave_pointer()
return
}
match self.window_at(xi, yi) {
Some((wid, true)) =>
match self.windows.get(wid) {
@@ -500,17 +688,50 @@ pub fn MoonPlasmaCompositor::handle_input(
_ => self.leave_pointer()
}
}
Scroll(v) => {
// ~10 units per wheel notch -> 3 lines.
let lines = if v > 0.0 { (v / 10.0).to_int() + 1 } else { (v / 10.0).to_int() - 1 }
ignore(self.shell.scroll_inspector(lines))
}
PointerButton(button, pressed) => {
let xi = self.ptr_x.to_int()
let yi = self.ptr_y.to_int()
if !pressed && self.shell.pointer_up() {
self.run_shell_actions()
return
}
if !pressed && self.split_drag is Some(_) {
self.split_drag = None
return
}
// Right button over a swappable panel widget opens its alternatives menu.
if button == 273U && pressed && self.shell.right_click(xi, yi) {
return
}
if pressed {
if self.shell.pointer_down(xi, yi) {
self.super_solo = false
if button != 273U && self.shell.pointer_down(xi, yi) {
self.run_shell_actions()
return
}
match self.window_at(xi, yi) {
Some((wid, false)) => {
let btn = self.title_button_at(wid, xi, yi)
if btn != 0 {
self.press_title_button(wid, btn)
return
}
}
_ => ()
}
match self.handle_at(xi, yi) {
Some(h) => {
self.split_drag = Some(h)
self.leave_pointer()
return
}
None => ()
}
match self.handle_at(xi, yi) {
Some(h) => {
self.split_drag = Some(h)
@@ -542,7 +763,24 @@ pub fn MoonPlasmaCompositor::handle_input(
}
}
Key(code, pressed) =>
if self.shell.popup_open() {
if code == 125U || code == 126U {
// Super (left/right): a bare tap toggles the launcher search; never reaches clients.
if pressed {
self.super_solo = true
} else if self.super_solo {
self.super_solo = false
if !self.shell.inspecting() {
self.shell.toggle_launcher()
}
}
} else if self.shell.inspecting() {
self.super_solo = false
// Escape leaves inspect mode; other keys are not forwarded while inspecting.
if code == 1U && pressed {
self.shell.set_inspecting(false)
}
} else if self.shell.popup_open() {
self.super_solo = false
if pressed {
let name = key_name(code, (self.mods & 1U) != 0U)
if name.length() > 0 {
@@ -550,6 +788,7 @@ pub fn MoonPlasmaCompositor::handle_input(
}
}
} else {
self.super_solo = false
match self.kbd_win {
Some(w) => self.server.keyboard_key(w, time_ms, code, pressed)
None => ()
@@ -580,6 +819,14 @@ pub fn MoonPlasmaCompositor::desired_cursor(self : MoonPlasmaCompositor) -> UInt
Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize
None => ()
}
let handle = match self.split_drag {
Some(h) => Some(h)
None => self.handle_at(self.ptr_x.to_int(), self.ptr_y.to_int())
}
match handle {
Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize
None => ()
}
match self.ptr_win {
Some(w) => self.server.client_cursor_shape(w)
None => 1U