Dock and task manager are one module: titled window pills, pins, Super+1..9
CI / test (push) Failing after 30s
CI / test (push) Failing after 30s
The panel had a task list and, beside it, a dock showing the same running
apps again. They are now one module, the dock, in the task list's place:
- Pinned apps, then running ones; an app with windows is a pill with its
window's title (or name and window count) while there is room, an icon
when the panel is crowded ("Show window titles" in Dock settings).
- Its right-click menu has the task list's window commands (Minimize /
Restore, Maximize) for a single window, or the app's windows by title.
- It stretches like the task list did; new panels get it instead of
tasks. A saved panel's "tasks" becomes the dock (one dock, where the
task list was); pins are the dock's own setting, so they carry over.
- An empty dock shows a "+ Add apps" tile that opens the Applications
menu, where right-clicking an app offers Open and Pin to dock (adding a
dock to the panel if there is none).
- Super+1 .. Super+9 open the dock's first nine apps like a click
(shortcut "dock-apps", rebindable in Settings > Shortcuts).
- "New window" / "Open" only for apps the catalog can start.
The tasks component, lib/panel's pill geometry and the taskbar-widget
world are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiPCFHRxaJQvwex6ry
This commit is contained in:
28 files changed
+801
-1131
No files matched your search
@@ -1,5 +1,6 @@
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the dock: pinned apps, then running ones,
|
||||
/// with their theme icons and a dot per open window. A click starts the app or brings its windows
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the dock, the panel's task manager: pinned
|
||||
/// apps, then running ones, with their theme icons, a dot per open window and (room allowing)
|
||||
/// their window titles. A click starts the app or brings its windows
|
||||
/// forward. Layout, hit-testing and drawing live in lib/dock (the shell uses the same code for the
|
||||
/// hover label and the per-app right-click menu); this adapts host capabilities.
|
||||
|
||||
@@ -12,9 +13,22 @@ let width : Ref[Int] = Ref::new(200)
|
||||
///|
|
||||
let height : Ref[Int] = Ref::new(34)
|
||||
|
||||
///| The windows as the dock sees them.
|
||||
///| The windows as the dock sees them: `all` has the app ids, `list-windows` (by the low 32 bits
|
||||
/// of the id) which are minimized.
|
||||
fn dock_windows() -> Array[@logic.DockWindow] {
|
||||
@windows.all().map(d => { id: d.id, app_id: d.app_id, focused: d.focused })
|
||||
let mini : Map[UInt, Bool] = Map([])
|
||||
for w in @windows.list_windows() {
|
||||
if w.minimized != 0U {
|
||||
mini.set(w.id, true)
|
||||
}
|
||||
}
|
||||
@windows.all().map(d => {
|
||||
id: d.id,
|
||||
app_id: d.app_id,
|
||||
focused: d.focused,
|
||||
title: d.title,
|
||||
minimized: mini.contains((d.id & 0xFFFFFFFFUL).to_uint()),
|
||||
})
|
||||
}
|
||||
|
||||
///| The window with keyboard focus, if any.
|
||||
@@ -40,7 +54,8 @@ pub fn info() -> PlasmoidInfo {
|
||||
// The shell works out the real width from the items as they change.
|
||||
preferred: { w: @logic.preferred_width(current_items(), @logic.config, 34).reinterpret_as_uint(), h: 34U },
|
||||
min_width: 60,
|
||||
stretch: false,
|
||||
// The panel's task list: it takes the free room, and what follows packs right.
|
||||
stretch: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ let categories : Array[String] = ["Apps and windows", "System", "Clocks", "Other
|
||||
///| Which group a module (by id, its file stem) belongs to; modules we don't know go in "Other".
|
||||
fn category_of(id : String) -> String {
|
||||
match id {
|
||||
"launcher" | "dock" | "tasks" | "layout" => "Apps and windows"
|
||||
"launcher" | "dock" | "layout" => "Apps and windows"
|
||||
"session-settings" | "network" | "battery" | "screenshot" => "System"
|
||||
"clock-digital" | "clock-binary" | "moon-disc" => "Clocks"
|
||||
_ => "Other"
|
||||
@@ -159,8 +159,7 @@ fn category_of(id : String) -> String {
|
||||
fn description_of(id : String) -> String {
|
||||
match id {
|
||||
"launcher" => "Start apps; reload, log out or power off"
|
||||
"dock" => "Pinned apps, one click away"
|
||||
"tasks" => "Your open windows"
|
||||
"dock" => "Pinned apps and your open windows"
|
||||
"layout" => "Switch tiling and floating"
|
||||
"session-settings" => "This settings window"
|
||||
"network" => "Wi-Fi and wired network"
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
pub fn mbt_ffi_cabi_realloc(
|
||||
src_offset : Int,
|
||||
src_size : Int,
|
||||
_dst_alignment : Int,
|
||||
dst_size : Int,
|
||||
) -> Int {
|
||||
// malloc
|
||||
if src_offset == 0 && src_size == 0 {
|
||||
return mbt_ffi_malloc(dst_size)
|
||||
}
|
||||
// free
|
||||
if dst_size == 0 {
|
||||
mbt_ffi_free(src_offset)
|
||||
return 0
|
||||
}
|
||||
// realloc
|
||||
let dst = mbt_ffi_malloc(dst_size)
|
||||
mbt_ffi_copy(dst, src_offset, if src_size < dst_size { src_size } else { dst_size })
|
||||
mbt_ffi_free(src_offset)
|
||||
dst
|
||||
}
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_copy(dest : Int, src : Int, len : Int) =
|
||||
#|(func (param i32) (param i32) (param i32) local.get 0 local.get 1 local.get 2 memory.copy)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportInfoPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportInfoPostReturn(p0)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportRenderPostReturn(p0)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportPopupPostReturn(p0)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
@plasmoid.wasmExportOnEvent(p0, p1, p2, p3)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportInfo() -> Int {
|
||||
@plasmoid.wasmExportInfo()
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
|
||||
@plasmoid.wasmExportRender(p0, p1)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportPopup() -> Int {
|
||||
@plasmoid.wasmExportPopup()
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
The widget (plasmoid) contract.
|
||||
@@ -1,431 +0,0 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportInfo() -> Int {
|
||||
|
||||
let (result) : (PlasmoidInfo) = info();
|
||||
let return_area = mbt_ffi_malloc(32)
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((result).id)
|
||||
mbt_ffi_store32((return_area) + 4, (result).id.length())
|
||||
mbt_ffi_store32((return_area) + 0, ptr)
|
||||
|
||||
let ptr0 = mbt_ffi_str2ptr((result).name)
|
||||
mbt_ffi_store32((return_area) + 12, (result).name.length())
|
||||
mbt_ffi_store32((return_area) + 8, ptr0)
|
||||
mbt_ffi_store32((return_area) + 16, (((result).preferred).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 20, (((result).preferred).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 24, ((result).min_width).reinterpret_as_int())
|
||||
mbt_ffi_store8((return_area) + 28, (if (result).stretch { 1 } else { 0 }))
|
||||
let ret = return_area
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportInfoPostReturn(p0 : Int) -> Unit {
|
||||
mbt_ffi_free(mbt_ffi_load32((p0) + 0))
|
||||
mbt_ffi_free(mbt_ffi_load32((p0) + 8))
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
|
||||
|
||||
let (result) : (Array[@types.DrawOp]) = render(@types.Size::{w : (p0).reinterpret_as_uint(), h : (p1).reinterpret_as_uint()});
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
|
||||
let address = mbt_ffi_malloc((result).length() * 32);
|
||||
for index = 0; index < (result).length(); index = index + 1 {
|
||||
let iter_elem : @types.DrawOp = (result)[(index)]
|
||||
let iter_base = address + (index * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload).radius).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload0) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload0).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload0).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload0).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload0).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload0).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload0).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload0).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload0).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload0).width).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 28, ((payload0).radius).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
Line(payload1) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload1).start).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload1).start).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload1).end).x)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload1).end).y)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload1).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload1).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload1).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload1).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload1).width).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
Circle(payload2) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload2).center).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload2).center).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload2).radius).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload2).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload2).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload2).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload2).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload2).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
Text(payload3) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload3).origin).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload3).origin).y)
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((payload3).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload3).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr)
|
||||
mbt_ffi_store32((iter_base) + 20, (((payload3).style).size).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 24, ((((payload3).style).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, ((((payload3).style).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, ((((payload3).style).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, ((((payload3).style).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload3).style).align.ordinal())
|
||||
mbt_ffi_store8((iter_base) + 29, (if ((payload3).style).bold { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload4) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload4).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload4).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload4).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload4).h).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
Image(payload6) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (7))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload6).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload6).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload6).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload6).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 20, ((payload6).image).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mbt_ffi_store32((return_area) + 4, (result).length())
|
||||
mbt_ffi_store32((return_area) + 0, address)
|
||||
let ret = return_area
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
|
||||
|
||||
for index = 0; index < (mbt_ffi_load32((p0) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((p0) + 0)) + (index * 32)
|
||||
|
||||
match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => ()
|
||||
1 => ()
|
||||
2 => ()
|
||||
3 => ()
|
||||
4 => {
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
}
|
||||
5 => ()
|
||||
6 => ()
|
||||
7 => ()
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((p0) + 0))
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportPopup() -> Int {
|
||||
|
||||
let (result) : (PopupSurface?) = popup();
|
||||
let return_area = mbt_ffi_malloc(20)
|
||||
|
||||
match (result) {
|
||||
None => {
|
||||
mbt_ffi_store8((return_area) + 0, (0))
|
||||
|
||||
()
|
||||
}
|
||||
Some(payload0) => {
|
||||
mbt_ffi_store8((return_area) + 0, (1))
|
||||
mbt_ffi_store32((return_area) + 4, (((payload0).size).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 8, (((payload0).size).h).reinterpret_as_int())
|
||||
|
||||
let address = mbt_ffi_malloc(((payload0).ops).length() * 32);
|
||||
for index = 0; index < ((payload0).ops).length(); index = index + 1 {
|
||||
let iter_elem : @types.DrawOp = ((payload0).ops)[(index)]
|
||||
let iter_base = address + (index * 32);
|
||||
|
||||
match iter_elem {
|
||||
FillRect(payload1) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (0))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload1).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload1).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload1).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload1).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload1).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload1).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload1).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload1).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload1).radius).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
StrokeRect(payload2) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (1))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload2).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload2).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload2).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload2).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload2).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload2).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload2).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload2).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload2).width).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 28, ((payload2).radius).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
Line(payload3) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (2))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload3).start).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload3).start).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload3).end).x)
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload3).end).y)
|
||||
mbt_ffi_store8((iter_base) + 20, (((payload3).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 21, (((payload3).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 22, (((payload3).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 23, (((payload3).color).a).to_int())
|
||||
mbt_ffi_store32((iter_base) + 24, ((payload3).width).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
Circle(payload4) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (3))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload4).center).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload4).center).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload4).radius).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 16, (((payload4).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 17, (((payload4).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 18, (((payload4).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 19, (((payload4).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 20, (if (payload4).filled { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
Text(payload5) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (4))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload5).origin).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload5).origin).y)
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((payload5).text)
|
||||
mbt_ffi_store32((iter_base) + 16, (payload5).text.length())
|
||||
mbt_ffi_store32((iter_base) + 12, ptr)
|
||||
mbt_ffi_store32((iter_base) + 20, (((payload5).style).size).reinterpret_as_int())
|
||||
mbt_ffi_store8((iter_base) + 24, ((((payload5).style).color).r).to_int())
|
||||
mbt_ffi_store8((iter_base) + 25, ((((payload5).style).color).g).to_int())
|
||||
mbt_ffi_store8((iter_base) + 26, ((((payload5).style).color).b).to_int())
|
||||
mbt_ffi_store8((iter_base) + 27, ((((payload5).style).color).a).to_int())
|
||||
mbt_ffi_store8((iter_base) + 28, ((payload5).style).align.ordinal())
|
||||
mbt_ffi_store8((iter_base) + 29, (if ((payload5).style).bold { 1 } else { 0 }))
|
||||
|
||||
()
|
||||
}
|
||||
PushClip(payload6) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (5))
|
||||
mbt_ffi_store32((iter_base) + 4, (payload6).x)
|
||||
mbt_ffi_store32((iter_base) + 8, (payload6).y)
|
||||
mbt_ffi_store32((iter_base) + 12, ((payload6).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, ((payload6).h).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
PopClip => {
|
||||
mbt_ffi_store8((iter_base) + 0, (6))
|
||||
|
||||
()
|
||||
}
|
||||
Image(payload8) => {
|
||||
mbt_ffi_store8((iter_base) + 0, (7))
|
||||
mbt_ffi_store32((iter_base) + 4, ((payload8).rect).x)
|
||||
mbt_ffi_store32((iter_base) + 8, ((payload8).rect).y)
|
||||
mbt_ffi_store32((iter_base) + 12, (((payload8).rect).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 16, (((payload8).rect).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 20, ((payload8).image).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
mbt_ffi_store32((return_area) + 16, ((payload0).ops).length())
|
||||
mbt_ffi_store32((return_area) + 12, address)
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
let ret = return_area
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
|
||||
|
||||
match (mbt_ffi_load8_u((p0) + 0)) {
|
||||
0 => ()
|
||||
1 => {
|
||||
|
||||
for index = 0; index < (mbt_ffi_load32((p0) + 16)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((p0) + 12)) + (index * 32)
|
||||
|
||||
match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => ()
|
||||
1 => ()
|
||||
2 => ()
|
||||
3 => ()
|
||||
4 => {
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
}
|
||||
5 => ()
|
||||
6 => ()
|
||||
7 => ()
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((p0) + 12))
|
||||
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
|
||||
let lifted = match (p1) {
|
||||
0 => {
|
||||
|
||||
@types.InputEvent::PointerMove(@types.Point::{x : p2, y : p3})
|
||||
}
|
||||
1 => {
|
||||
|
||||
@types.InputEvent::PointerDown(@types.Point::{x : p2, y : p3})
|
||||
}
|
||||
2 => {
|
||||
|
||||
@types.InputEvent::PointerUp(@types.Point::{x : p2, y : p3})
|
||||
}
|
||||
3 => {
|
||||
|
||||
@types.InputEvent::PointerLeave
|
||||
}
|
||||
4 => {
|
||||
|
||||
@types.InputEvent::FocusLost
|
||||
}
|
||||
5 => {
|
||||
|
||||
let result = mbt_ffi_ptr2str(p2, p3)
|
||||
|
||||
@types.InputEvent::KeyDown(result)
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
let (result0) : (Bool) = on_event(Surface::from(p0), lifted);
|
||||
let ret = (if result0 { 1 } else { 0 })
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import {
|
||||
"chandra/desktop/interface/chandra/desktop/types" @types,
|
||||
"chandra/desktop/interface/chandra/desktop/theme" @theme,
|
||||
"chandra/desktop/interface/chandra/desktop/windows" @windows,
|
||||
"chandra/desktop/interface/chandra/desktop/icons" @icons,
|
||||
"chandra/desktop/lib/ui" @ui,
|
||||
"chandra/desktop/lib/dock" @dock,
|
||||
"chandra/desktop/lib/panel" @panel,
|
||||
}
|
||||
|
||||
warnings = "-44"
|
||||
@@ -1,184 +0,0 @@
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the task manager: one pill per open
|
||||
/// window, in the order the windows were opened (so the bar doesn't reshuffle when focus changes).
|
||||
/// Each pill starts with the app's icon: the one its .desktop file names, from the icon theme (the
|
||||
/// `icons` capability), else the coloured letter tile the dock shows for that app id.
|
||||
/// The focused window's pill is lit, a minimized window's is dimmed; a click focuses the window and
|
||||
/// restores it if it was minimized; a right-click opens the window's menu (drawn by the shell). When the bar is too narrow the pills shrink to fit, and below
|
||||
/// `icon_only_w` they show just the icon.
|
||||
|
||||
///| Pill geometry is shared with the shell (lib/panel/tasks.mbt): it hit-tests right-clicks
|
||||
/// on pills to show the window's menu (Quit, Minimize, Maximize).
|
||||
let gap : Int = @panel.task_pill_gap
|
||||
|
||||
///| Pills narrower than this drop the title and show only the centred icon.
|
||||
let icon_only_w : Int = 72
|
||||
|
||||
///| Edge of the icon tile in a bar `h` pixels tall.
|
||||
fn icon_size(h : Int) -> Int {
|
||||
let s = h - 12
|
||||
if s < 14 { 14 } else if s > 22 { 22 } else { s }
|
||||
}
|
||||
|
||||
///| App id of every window, by window id, from the richer `windows.all` view (the task-bar
|
||||
/// rows carry only titles).
|
||||
fn app_ids() -> Map[UInt, String] {
|
||||
let m : Map[UInt, String] = Map([])
|
||||
for d in @windows.all() {
|
||||
m.set((d.id & 0xFFFFFFFFUL).to_uint(), d.app_id)
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
///| The app's icon `s` pixels square centred on (cx, cy): its theme icon when the host has one,
|
||||
/// else the letter tile (keyed by the app id, or the title for windows without one).
|
||||
fn pill_icon(cx : Int, cy : Int, s : Int, app : String, title : String) -> Array[@types.DrawOp] {
|
||||
let handle = if app.length() > 0 { @icons.app_icon(app) } else { 0U }
|
||||
if handle != 0U {
|
||||
return [Image({ rect: @ui.rect(cx - s / 2, cy - s / 2, s, s), image: handle })]
|
||||
}
|
||||
let key = if app.length() > 0 { app } else { title }
|
||||
@dock.app_icon(cx, cy, s, key, @dock.app_glyph(app, title))
|
||||
}
|
||||
|
||||
///| The width the module was last drawn at, and the pill the pointer is over (-1: none).
|
||||
let last_w : Ref[Int] = { val: 300 }
|
||||
|
||||
///|
|
||||
let hover : Ref[Int] = { val: -1 }
|
||||
|
||||
///| Windows in opening order (ids grow as windows open), whatever the host's stacking order says.
|
||||
fn windows_sorted() -> Array[@windows.WindowInfo] {
|
||||
let ws = @windows.list_windows()
|
||||
let n = ws.length()
|
||||
for i = 1; i < n; i = i + 1 {
|
||||
let cur = ws[i]
|
||||
let mut j = i - 1
|
||||
while j >= 0 && ws[j].id > cur.id {
|
||||
ws[j + 1] = ws[j]
|
||||
j = j - 1
|
||||
}
|
||||
ws[j + 1] = cur
|
||||
}
|
||||
ws
|
||||
}
|
||||
|
||||
///| Pill width for `n` windows in a bar `w` wide.
|
||||
fn pill_w(n : Int, w : Int) -> Int {
|
||||
@panel.task_pill_w(n, w)
|
||||
}
|
||||
|
||||
///| The pill under a widget-local x, or -1.
|
||||
fn pill_at(x : Int, n : Int) -> Int {
|
||||
@panel.task_pill_at(x, n, last_w.val)
|
||||
}
|
||||
|
||||
///| `s` shortened with an ellipsis until it fits `max_w` pixels.
|
||||
fn fit_text(s : String, size : Int, max_w : Int) -> String {
|
||||
if (s.length() * ((size * 11 + 19) / 20)) <= max_w {
|
||||
return s
|
||||
}
|
||||
let mut n = s.length()
|
||||
while n > 1 && ((n + 1) * ((size * 11 + 19) / 20)) > max_w {
|
||||
n = n - 1
|
||||
}
|
||||
s[:n].to_string() + "…"
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn info() -> PlasmoidInfo {
|
||||
{
|
||||
id: "org.chandra.tasks",
|
||||
name: "Task Manager",
|
||||
preferred: { w: 300, h: 34 },
|
||||
min_width: 120,
|
||||
stretch: true,
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
|
||||
let t = @theme.get_tokens()
|
||||
let w = size.w.reinterpret_as_int()
|
||||
let h = size.h.reinterpret_as_int()
|
||||
last_w.val = w
|
||||
let r = t.radius.reinterpret_as_int()
|
||||
let fs = t.font_size.reinterpret_as_int()
|
||||
let ws = windows_sorted()
|
||||
let pw = pill_w(ws.length(), w)
|
||||
let ids = app_ids()
|
||||
let ops : Array[@types.DrawOp] = []
|
||||
for i = 0; i < ws.length(); i = i + 1 {
|
||||
let x = i * (pw + gap)
|
||||
if x >= w {
|
||||
break
|
||||
}
|
||||
let win = ws[i]
|
||||
let focused = win.focused == 1U
|
||||
let minimized = win.minimized == 1U
|
||||
let bg = if focused {
|
||||
t.palette.accent
|
||||
} else if i == hover.val {
|
||||
t.palette.surface_popup
|
||||
} else {
|
||||
t.palette.surface_hover
|
||||
}
|
||||
let fg = if focused {
|
||||
t.palette.accent_foreground
|
||||
} else if minimized {
|
||||
@ui.with_alpha(t.palette.foreground, 140)
|
||||
} else {
|
||||
t.palette.foreground
|
||||
}
|
||||
ops.push(@ui.fill_rect(@ui.rect(x, 0, pw, h), bg, radius=r))
|
||||
if minimized && !focused {
|
||||
ops.push(@ui.stroke_rect(@ui.rect(x, 0, pw, h), t.palette.border, width=1, radius=r))
|
||||
}
|
||||
let title = if win.title.length() > 0 { win.title } else { "(untitled)" }
|
||||
let app = ids.get(win.id).unwrap_or("")
|
||||
let isz = icon_size(h)
|
||||
if pw < icon_only_w {
|
||||
ops.append(pill_icon(x + pw / 2, h / 2, isz, app, title))
|
||||
} else {
|
||||
ops.append(pill_icon(x + 6 + isz / 2, h / 2, isz, app, title))
|
||||
let tx = x + 6 + isz + 6
|
||||
ops.push(@ui.text(tx, h / 2, fit_text(title, fs, x + pw - 8 - tx), fs, fg, bold=focused))
|
||||
}
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn popup() -> PopupSurface? {
|
||||
None
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
|
||||
match (target, event) {
|
||||
(WIDGET, PointerMove(p)) => {
|
||||
let i = pill_at(p.x, windows_sorted().length())
|
||||
if i != hover.val {
|
||||
hover.val = i
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
(WIDGET, PointerLeave) =>
|
||||
if hover.val != -1 {
|
||||
hover.val = -1
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
(WIDGET, PointerDown(p)) => {
|
||||
let ws = windows_sorted()
|
||||
let i = pill_at(p.x, ws.length())
|
||||
if i >= 0 {
|
||||
@windows.focus_window(ws[i].id)
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct PlasmoidInfo {
|
||||
id : String; name : String; preferred : @types.Size; min_width : UInt; stretch : Bool
|
||||
}
|
||||
///|
|
||||
pub(all) struct PopupSurface {
|
||||
size : @types.Size; ops : Array[@types.DrawOp]
|
||||
}
|
||||
///|
|
||||
pub(all) enum Surface {
|
||||
WIDGET; POPUP
|
||||
} derive()
|
||||
|
||||
///|
|
||||
pub fn Surface::ordinal(self : Surface) -> Int {
|
||||
match self {
|
||||
WIDGET => 0
|
||||
POPUP => 1
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn Surface::from(self : Int) -> Surface {
|
||||
match self {
|
||||
0 => WIDGET
|
||||
1 => POPUP
|
||||
_ => panic()
|
||||
}
|
||||
}
|
||||
///|
|
||||
declare pub fn info() -> PlasmoidInfo
|
||||
///|
|
||||
/// Draw the widget into a `size` box (local coordinates).
|
||||
declare pub fn render(size : @types.Size) -> Array[@types.DrawOp]
|
||||
///|
|
||||
/// Present when the widget wants a popup surface (e.g. a launcher menu).
|
||||
declare pub fn popup() -> PopupSurface?
|
||||
///|
|
||||
/// Returns true when the widget's visuals changed and a redraw is needed.
|
||||
declare pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import {
|
||||
"chandra/desktop/components/tasks/gen/interface/chandra/desktop/plasmoid" @plasmoid,
|
||||
}
|
||||
|
||||
warnings = "-44"
|
||||
|
||||
pkgtype(kind: "foreign_library")
|
||||
|
||||
options(
|
||||
link: {
|
||||
"wasm": {
|
||||
"export-memory-name": "memory",
|
||||
"heap-start-address": 16,
|
||||
"exports": [
|
||||
"mbt_ffi_cabi_realloc:cabi_realloc",
|
||||
"wasmExportInfo:chandra:desktop/plasmoid@0.1.0#info",
|
||||
"wasmExportInfoPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#info",
|
||||
"wasmExportOnEvent:chandra:desktop/plasmoid@0.1.0#on-event",
|
||||
"wasmExportPopup:chandra:desktop/plasmoid@0.1.0#popup",
|
||||
"wasmExportPopupPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#popup",
|
||||
"wasmExportRender:chandra:desktop/plasmoid@0.1.0#render",
|
||||
"wasmExportRenderPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#render"
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user