Dock: pinned and running apps with real icons, window dots, hover names and a per-app menu
CI / test (push) Failing after 17s
CI / test (push) Failing after 17s
The dock showed the first eight catalog apps as letter tiles, and that list reshuffled after every launch (the catalog puts recent apps first). Now: - Pinned apps first, in the order you set, then the other running apps after a thin divider (like macOS). Windows find their app by desktop id, case, the last dotted part, or the app's name (xterm -> debian-xterm.desktop "XTerm"); windows without an app id stay out. - Real icons from the icon theme (the `icons` capability, as in the task manager), with the letter tile as fallback. The shell publishes icons for pinned apps that aren't running too. - A dot under an icon per open window (up to three), a longer accent bar when the app has focus. - Click: start the app if it isn't running, otherwise bring its newest window forward (restoring it if minimized); click a focused app again to step through its windows. - Hover: the icon grows (neighbours a little) on a light highlight, and the shell draws the app's name in a label above it. - Right-click an icon (drawn by the shell, like the task manager's window menu): Open / New window, Pin to dock / Unpin from dock, Move left / Move right, Quit or Close N windows, and Dock settings. - Dock settings (module-config): Icon size (Small/Medium/Large), Magnify icons under the pointer, Show running apps that aren't pinned. The pinned list is a hidden setting (empty label: the shell's settings menu skips it), saved in state.edn's :module-config. Until it is set the dock pins the catalog's first five, and the shell saves that once so launches don't move them. - The panel sizes the dock from its current items (a module's preferred width is read once). Plumbing: new WIT world dock-widget (app-catalog, app-launch, windows, icons, exports module-config); no new interfaces, so both hosts load it as is. lib/dock holds the items, layout, hit-testing, drawing and pin edits, shared by the module and compositor/shell/dock.mbt. The shell's Launch handling moved into launch_catalog_app so the menu can use it. Also: DesktopShell::pointer_move delivered every hover move twice (a duplicated block). Tests: lib/dock (settings round trip, app matching, item order, hit-testing with the divider, clicks and window cycling, drawing, pin edits), compositor/host input_test (the dock in a real compositor: saved default pins, growing for running apps, hover label, the menu's rows and actions, settings menu without the pinned row, focusing by click), dock_test (screenshots in _build/dock_hover.png and dock_menu.png). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hkmB8pJF5ckPeecFxL
This commit is contained in:
29 files changed
+1497
-176
No files matched your search
@@ -0,0 +1,5 @@
|
||||
Optional: a module's own settings. A module that exports this gets a "Module settings" entry in
|
||||
its right-click menu, listing the items below; the shell draws the menu (the same for every
|
||||
module), remembers each choice per module in state.edn (`:module-config`), and hands the saved
|
||||
values back through `set-config` right after the module is loaded. A module without it simply
|
||||
has no settings: the export is looked up by name, so older modules keep loading.
|
||||
@@ -0,0 +1,114 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportConfigItems() -> Int {
|
||||
|
||||
let (result) : (Array[ConfigItem]) = config_items();
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
|
||||
let address3 = mbt_ffi_malloc((result).length() * 32);
|
||||
for index4 = 0; index4 < (result).length(); index4 = index4 + 1 {
|
||||
let iter_elem : ConfigItem = (result)[(index4)]
|
||||
let iter_base = address3 + (index4 * 32);
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((iter_elem).key)
|
||||
mbt_ffi_store32((iter_base) + 4, (iter_elem).key.length())
|
||||
mbt_ffi_store32((iter_base) + 0, ptr)
|
||||
|
||||
let ptr0 = mbt_ffi_str2ptr((iter_elem).label)
|
||||
mbt_ffi_store32((iter_base) + 12, (iter_elem).label.length())
|
||||
mbt_ffi_store32((iter_base) + 8, ptr0)
|
||||
|
||||
let address = mbt_ffi_malloc(((iter_elem).choices).length() * 8);
|
||||
for index = 0; index < ((iter_elem).choices).length(); index = index + 1 {
|
||||
let iter_elem : String = ((iter_elem).choices)[(index)]
|
||||
let iter_base = address + (index * 8);
|
||||
|
||||
let ptr1 = mbt_ffi_str2ptr(iter_elem)
|
||||
mbt_ffi_store32((iter_base) + 4, iter_elem.length())
|
||||
mbt_ffi_store32((iter_base) + 0, ptr1)
|
||||
|
||||
}
|
||||
mbt_ffi_store32((iter_base) + 20, ((iter_elem).choices).length())
|
||||
mbt_ffi_store32((iter_base) + 16, address)
|
||||
|
||||
let ptr2 = mbt_ffi_str2ptr((iter_elem).value)
|
||||
mbt_ffi_store32((iter_base) + 28, (iter_elem).value.length())
|
||||
mbt_ffi_store32((iter_base) + 24, ptr2)
|
||||
|
||||
}
|
||||
mbt_ffi_store32((return_area) + 4, (result).length())
|
||||
mbt_ffi_store32((return_area) + 0, address3)
|
||||
let ret = return_area
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportConfigItemsPostReturn(p0 : Int) -> Unit {
|
||||
|
||||
for index0 = 0; index0 < (mbt_ffi_load32((p0) + 4)); index0 = index0 + 1 {
|
||||
let iter_base = (mbt_ffi_load32((p0) + 0)) + (index0 * 32)
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 0))
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 8))
|
||||
|
||||
for index = 0; index < (mbt_ffi_load32((iter_base) + 20)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((iter_base) + 16)) + (index * 8)
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 0))
|
||||
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 16))
|
||||
mbt_ffi_free(mbt_ffi_load32((iter_base) + 24))
|
||||
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((p0) + 0))
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportSetConfig(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
|
||||
let result = mbt_ffi_ptr2str(p0, p1)
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(p2, p3)
|
||||
|
||||
let (result1) : (Bool) = set_config(result, result0);
|
||||
let ret = (if result1 { 1 } else { 0 })
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
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_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)
|
||||
|
||||
///|
|
||||
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_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import {
|
||||
"chandra/desktop/lib/dock" @logic,
|
||||
}
|
||||
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,21 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "chandra/desktop/components/dock/gen/interface/chandra/desktop/module-config"
|
||||
|
||||
// Values
|
||||
pub fn config_items() -> Array[ConfigItem]
|
||||
|
||||
pub fn set_config(String, String) -> Bool
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub(all) struct ConfigItem {
|
||||
key : String
|
||||
label : String
|
||||
choices : Array[String]
|
||||
value : String
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -0,0 +1,12 @@
|
||||
///| The dock's right-click settings (icon size, magnification, running apps) and its pinned apps
|
||||
/// (a hidden setting the shell's per-app menu changes); the logic is in lib/dock.
|
||||
|
||||
///|
|
||||
pub fn config_items() -> Array[ConfigItem] {
|
||||
@logic.config.items().map(e => { key: e.key, label: e.label, choices: e.choices, value: e.value })
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn set_config(key : String, value : String) -> Bool {
|
||||
@logic.config.set(key, value)
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct ConfigItem {
|
||||
key : String; label : String; choices : Array[String]; value : String
|
||||
}
|
||||
///|
|
||||
declare pub fn config_items() -> Array[ConfigItem]
|
||||
///|
|
||||
/// Set `key` to `value` (unknown keys and values are ignored). True when the widget should redraw.
|
||||
declare pub fn set_config(key : String, value : String) -> Bool
|
||||
|
||||
@@ -390,23 +390,6 @@ pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
|
||||
}
|
||||
|
||||
///|
|
||||
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_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
@@ -418,6 +401,23 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
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_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
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_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
@@ -3,6 +3,8 @@ import {
|
||||
"chandra/desktop/interface/chandra/desktop/theme" @theme,
|
||||
"chandra/desktop/interface/chandra/desktop/app-catalog" @app_catalog,
|
||||
"chandra/desktop/interface/chandra/desktop/app-launch" @app_launch,
|
||||
"chandra/desktop/interface/chandra/desktop/windows" @windows,
|
||||
"chandra/desktop/interface/chandra/desktop/icons" @icons,
|
||||
"chandra/desktop/lib/dock" @logic,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the dock: a row of app tiles
|
||||
/// that magnify under the pointer and start the app on click. The tile layout and
|
||||
/// hit-testing live in lib/dock; this adapts host capabilities.
|
||||
///| 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
|
||||
/// 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.
|
||||
|
||||
///| Tile under the pointer, or -1.
|
||||
///| Item under the pointer, or -1.
|
||||
let hover : Ref[Int] = Ref::new(-1)
|
||||
|
||||
///| Height of the widget at its last render (events carry no size).
|
||||
///| Size of the widget at its last render (events carry no size).
|
||||
let width : Ref[Int] = Ref::new(200)
|
||||
|
||||
///|
|
||||
let height : Ref[Int] = Ref::new(34)
|
||||
|
||||
///| The windows as the dock sees them.
|
||||
fn dock_windows() -> Array[@logic.DockWindow] {
|
||||
@windows.all().map(d => { id: d.id, app_id: d.app_id, focused: d.focused })
|
||||
}
|
||||
|
||||
///| The window with keyboard focus, if any.
|
||||
fn focused_window() -> UInt64? {
|
||||
for d in @windows.all() {
|
||||
if d.focused {
|
||||
return Some(d.id)
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
///|
|
||||
fn current_items() -> Array[@logic.DockItem] {
|
||||
@logic.items(@logic.config, @app_catalog.list_apps(), dock_windows())
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn info() -> PlasmoidInfo {
|
||||
{
|
||||
id: "org.chandra.dock",
|
||||
name: "Dock",
|
||||
preferred: { w: @logic.preferred_width(@app_catalog.list_apps().length()).reinterpret_as_uint(), h: 34U },
|
||||
// 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,
|
||||
}
|
||||
@@ -21,22 +46,32 @@ pub fn info() -> PlasmoidInfo {
|
||||
|
||||
///|
|
||||
pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
|
||||
width.val = size.w.reinterpret_as_int()
|
||||
height.val = size.h.reinterpret_as_int()
|
||||
@logic.render(size, @theme.get_tokens(), @app_catalog.list_apps(), hover.val)
|
||||
@logic.render(size, @theme.get_tokens(), @logic.config, current_items(), hover.val, @icons.app_icon)
|
||||
}
|
||||
|
||||
///| Dock tiles have no popup.
|
||||
///| The dock has no popup: the shell draws its hover label and right-click menu.
|
||||
pub fn popup() -> PopupSurface? {
|
||||
None
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn on_event(_target : Surface, event : @types.InputEvent) -> Bool {
|
||||
let (h, redraw, launch) = @logic.handle(@app_catalog.list_apps(), hover.val, height.val, event)
|
||||
let (h, redraw, action) = @logic.handle(
|
||||
current_items(),
|
||||
@logic.config,
|
||||
hover.val,
|
||||
width.val,
|
||||
height.val,
|
||||
focused_window(),
|
||||
event,
|
||||
)
|
||||
hover.val = h
|
||||
match launch {
|
||||
Some(id) => ignore(@app_launch.launch(id))
|
||||
None => ()
|
||||
match action {
|
||||
Launch(id) => ignore(@app_launch.launch(id))
|
||||
Focus(win) => @windows.focus(win)
|
||||
Nothing => ()
|
||||
}
|
||||
redraw
|
||||
}
|
||||
Reference in new issue
Block a user