CI / test (push) Failing after 16s
moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the MoonBit module (chandra/desktop) and generated bindings, the Rust host, identifiers (ChandraCompositor), the session script (chandra-session) and desktop entry (chandra.desktop), config and data paths ($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*), UI strings, docs and tests. The test fixture components are rebuilt against the renamed WIT. Saved panel.edn and state.edn are still read from the old $XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy. The remote repository keeps its experiments/moon-plasma name for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
155 lines
3.8 KiB
MoonBit
155 lines
3.8 KiB
MoonBit
///| `chandra:wm/policy` hybrid WM component backed by `lib/wm`.
|
|
|
|
///|
|
|
let state : @wm.WmState = @wm.WmState::new()
|
|
|
|
///|
|
|
let last_work_area : Ref[@wm.Rect] = { val: { x: 0, y: 0, w: 1280, h: 672 } }
|
|
|
|
///|
|
|
fn to_wm_rect(r : @types.Rect) -> @wm.Rect {
|
|
{ x: r.x, y: r.y, w: r.w.reinterpret_as_int(), h: r.h.reinterpret_as_int() }
|
|
}
|
|
|
|
///|
|
|
fn to_wit_rect(r : @wm.Rect) -> @types.Rect {
|
|
{ x: r.x, y: r.y, w: r.w.reinterpret_as_uint(), h: r.h.reinterpret_as_uint() }
|
|
}
|
|
|
|
///|
|
|
fn to_wm_record(w : WindowState) -> @wm.WindowRecord {
|
|
let g = to_wm_rect(w.geometry)
|
|
{
|
|
id: w.id,
|
|
app_id: w.app_id,
|
|
title: w.title,
|
|
geometry: g,
|
|
floating_geometry: g,
|
|
min_size: { w: w.min_size.w.reinterpret_as_int(), h: w.min_size.h.reinterpret_as_int() },
|
|
max_size: match w.max_size {
|
|
Some(ms) => Some({ w: ms.w.reinterpret_as_int(), h: ms.h.reinterpret_as_int() })
|
|
None => None
|
|
},
|
|
focused: w.focused,
|
|
maximized: w.maximized,
|
|
fullscreen: w.fullscreen,
|
|
minimized: false,
|
|
is_floating: false,
|
|
workspace: w.workspace,
|
|
can_move: w.caps.is_set(CAN_MOVE),
|
|
can_resize: w.caps.is_set(CAN_RESIZE),
|
|
can_maximize: w.caps.is_set(CAN_MAXIMIZE),
|
|
can_minimize: w.caps.is_set(CAN_MINIMIZE),
|
|
can_fullscreen: w.caps.is_set(CAN_FULLSCREEN),
|
|
}
|
|
}
|
|
|
|
///|
|
|
fn to_wit_actions(actions : Array[@wm.WmAction]) -> Array[WmAction] {
|
|
actions.map(a => match a {
|
|
SetGeometry(id, r) => SetGeometry((id, to_wit_rect(r)))
|
|
Focus(id) => Focus(id)
|
|
Raise(id) => Raise(id)
|
|
Close(id) => Close(id)
|
|
SetMaximized(id, b) => SetMaximized((id, b))
|
|
SetFullscreen(id, b) => SetFullscreen((id, b))
|
|
})
|
|
}
|
|
|
|
///|
|
|
fn sync_theme() -> Unit {
|
|
let t = @theme.get_tokens()
|
|
let gap = t.spacing.reinterpret_as_int()
|
|
state.inner_gap = gap
|
|
state.outer_gap = gap
|
|
}
|
|
|
|
///|
|
|
pub fn sync_windows(
|
|
outputs : Array[@types.Rect],
|
|
windows : Array[WindowState],
|
|
) -> Array[WmAction] {
|
|
sync_theme()
|
|
let wa = if outputs.length() > 0 {
|
|
to_wm_rect(outputs[0])
|
|
} else {
|
|
last_work_area.val
|
|
}
|
|
last_work_area.val = wa
|
|
let recs = windows.map(to_wm_record)
|
|
to_wit_actions(state.sync_windows(wa, recs))
|
|
}
|
|
|
|
///|
|
|
pub fn on_window_open(
|
|
win : WindowState,
|
|
work_area : @types.Rect,
|
|
) -> Array[WmAction] {
|
|
sync_theme()
|
|
let wa = to_wm_rect(work_area)
|
|
last_work_area.val = wa
|
|
to_wit_actions(state.open_window(to_wm_record(win), wa))
|
|
}
|
|
|
|
///|
|
|
pub fn on_window_close(id : UInt64) -> Array[WmAction] {
|
|
sync_theme()
|
|
to_wit_actions(state.close_window(id, last_work_area.val))
|
|
}
|
|
|
|
///|
|
|
pub fn on_window_request(
|
|
id : UInt64,
|
|
req : WindowRequest,
|
|
work_area : @types.Rect,
|
|
) -> Array[WmAction] {
|
|
sync_theme()
|
|
let wa = to_wm_rect(work_area)
|
|
last_work_area.val = wa
|
|
let wm_req : @wm.WindowRequest = match req {
|
|
Maximize(b) => Maximize(b)
|
|
Fullscreen(b) => Fullscreen(b)
|
|
Minimize(b) => Minimize(b)
|
|
Close => Close
|
|
Activate => Activate
|
|
MoveTo(p) => MoveTo(p.x, p.y)
|
|
ResizeTo(s) => ResizeTo(s.w.reinterpret_as_int(), s.h.reinterpret_as_int())
|
|
}
|
|
to_wit_actions(state.handle_request(id, wm_req, wa))
|
|
}
|
|
|
|
///|
|
|
pub fn on_pointer(
|
|
pos : @types.Point,
|
|
_button : UInt?,
|
|
_pressed : Bool,
|
|
) -> InputTarget {
|
|
match state.hit_test(pos.x, pos.y, None) {
|
|
Client(id, lx, ly) => Client((id, { x: lx, y: ly }))
|
|
Decoration(id, lx, ly) => Decoration((id, { x: lx, y: ly }))
|
|
ShellPanel(lx, ly) => ShellPanel({ x: lx, y: ly })
|
|
HitNone => None
|
|
}
|
|
}
|
|
|
|
///|
|
|
pub fn set_layout_mode(
|
|
mode : LayoutMode,
|
|
work_area : @types.Rect,
|
|
) -> Array[WmAction] {
|
|
sync_theme()
|
|
let wa = to_wm_rect(work_area)
|
|
last_work_area.val = wa
|
|
let wm_mode : @wm.LayoutMode = match mode {
|
|
FLOATING => Floating
|
|
TILING => Tiling
|
|
MONOCLE => Monocle
|
|
}
|
|
to_wit_actions(state.set_layout_mode(wm_mode, wa))
|
|
}
|
|
|
|
///|
|
|
pub fn stacking_order() -> Array[UInt64] {
|
|
state.stacking_order()
|
|
}
|