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
+1491
-170
No files matched your search
@@ -131,10 +131,15 @@ a recording shortcut again to stop.
|
||||
|
||||
**Panel modules** (each one a separate `.wasm` component in `components/`)
|
||||
|
||||
* **Launcher** (application menu with search) and **Dock**. The launcher's menu ends in a
|
||||
session row: **Reload** (reload every panel module from disk, keeping the panel and module
|
||||
settings; windows and apps keep running), **Log out**, **Suspend**, **Restart** and **Power
|
||||
off**. Log out, Restart and Power off ask for a second click.
|
||||
* **Launcher** (application menu with search). Its menu ends in a session row: **Reload**
|
||||
(reload every panel module from disk, keeping the panel and module settings; windows and apps
|
||||
keep running), **Log out**, **Suspend**, **Restart** and **Power off**. Log out, Restart and
|
||||
Power off ask for a second click.
|
||||
* **Dock**: pinned apps, then the other running apps after a divider, with their theme icons and a
|
||||
dot per open window (lit when the app has focus). Click to start an app or bring its newest
|
||||
window forward; click a focused app again to step through its windows. Hover for the app's
|
||||
name; right-click an icon for Open / New window, Pin or Unpin, Move left / right, Quit, and
|
||||
Dock settings (icon size, magnification, whether running apps show). Pins live in state.edn.
|
||||
* **Task manager**: a pill per window with the app's real icon from its `.desktop` file;
|
||||
right-click a pill for Minimize, Maximize and Quit.
|
||||
* **Network**: Wi-Fi and wired status, connect to Wi-Fi networks (with passwords), Wi-Fi and
|
||||
|
||||
+28
-10
@@ -40,20 +40,20 @@ extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportInfo() -> Int {
|
||||
@plasmoid.wasmExportInfo()
|
||||
pub fn wasmExportConfigItems() -> Int {
|
||||
@module-config.wasmExportConfigItems()
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
@plasmoid.wasmExportOnEvent(p0, p1, p2, p3)
|
||||
pub fn wasmExportConfigItemsPostReturn(p0 : Int) -> Unit {
|
||||
@module-config.wasmExportConfigItemsPostReturn(p0)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportRenderPostReturn(p0)
|
||||
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportPopupPostReturn(p0)
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -64,8 +64,8 @@ pub fn wasmExportInfoPostReturn(p0 : Int) -> Unit {
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
|
||||
@plasmoid.wasmExportRender(p0, p1)
|
||||
pub fn wasmExportInfo() -> Int {
|
||||
@plasmoid.wasmExportInfo()
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -76,7 +76,25 @@ pub fn wasmExportPopup() -> Int {
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportPopupPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportPopupPostReturn(p0)
|
||||
pub fn wasmExportSetConfig(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
@module-config.wasmExportSetConfig(p0, p1, p2, p3)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportOnEvent(p0 : Int, p1 : Int, p2 : Int, p3 : Int) -> Int {
|
||||
@plasmoid.wasmExportOnEvent(p0, p1, p2, p3)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRender(p0 : Int, p1 : Int) -> Int {
|
||||
@plasmoid.wasmExportRender(p0, p1)
|
||||
}
|
||||
|
||||
///|
|
||||
#doc(hidden)
|
||||
pub fn wasmExportRenderPostReturn(p0 : Int) -> Unit {
|
||||
@plasmoid.wasmExportRenderPostReturn(p0)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
"chandra/desktop/components/dock/gen/interface/chandra/desktop/module-config" @module-config,
|
||||
"chandra/desktop/components/dock/gen/interface/chandra/desktop/plasmoid" @plasmoid,
|
||||
}
|
||||
|
||||
@@ -13,13 +14,16 @@ options(
|
||||
"heap-start-address": 16,
|
||||
"exports": [
|
||||
"mbt_ffi_cabi_realloc:cabi_realloc",
|
||||
"wasmExportConfigItems:chandra:desktop/module-config@0.1.0#config-items",
|
||||
"wasmExportConfigItemsPostReturn:cabi_post_chandra:desktop/module-config@0.1.0#config-items",
|
||||
"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"
|
||||
"wasmExportRenderPostReturn:cabi_post_chandra:desktop/plasmoid@0.1.0#render",
|
||||
"wasmExportSetConfig:chandra:desktop/module-config@0.1.0#set-config"
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
///| The dock drawn in a real frame, for a look at it: writes _build/dock_hover.png (an icon under
|
||||
/// the pointer, magnified, with its name above) and _build/dock_menu.png (an app's right-click
|
||||
/// menu). Uses the machine's own .desktop files and icon theme, so what it shows varies.
|
||||
|
||||
///|
|
||||
test "dock screenshots: hover label and an app's menu" {
|
||||
let socket_path = "/tmp/wayland-moon-dockshot-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
assert_true(comp.shell.load_path("build/components/dock.wasm") is Some(_))
|
||||
ignore(comp.compose_frame())
|
||||
let slot = comp.shell.slots().filter(s => comp.shell.slot_module(s).contains("dock"))[0]
|
||||
// Room for the dock's running apps on a 1280-wide screen.
|
||||
for s in comp.shell.slots() {
|
||||
let m = comp.shell.slot_module(s)
|
||||
if m == "inspector" || m == "layout" || m == "screenshot" {
|
||||
ignore(comp.shell.unload_slot(s))
|
||||
}
|
||||
}
|
||||
comp.shell.set_module_setting(
|
||||
slot, "pinned", "libreoffice-writer;libreoffice-calc;libreoffice-impress;debian-xterm;vim",
|
||||
)
|
||||
let _a = open_and_configure_client(comp, socket_path, "Report.odt", "libreoffice-writer")
|
||||
let _b = open_and_configure_client(comp, socket_path, "Notes.odt", "libreoffice-writer")
|
||||
let _c = open_and_configure_client(comp, socket_path, "Terminal", "xterm")
|
||||
let _e = open_and_configure_client(comp, socket_path, "Notes 2", "org.example.Notes")
|
||||
let _d = open_and_configure_client(comp, socket_path, "Notes", "org.example.Notes")
|
||||
ignore(comp.compose_frame())
|
||||
ignore(comp.compose_frame())
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
let cy = r.y + r.h / 2
|
||||
// Hover the second icon (Calc).
|
||||
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 6 + 30 + 12).to_double(), cy.to_double()), 1U)
|
||||
let frame = comp.compose_frame()
|
||||
assert_true(comp.shell.dock_hover_name().length() > 0)
|
||||
ignore(@sys.write_file_bytes("_build/dock_hover.png", @renderer.encode_png(frame)))
|
||||
// Right-click the first (Writer, two windows).
|
||||
click_at(comp, r.x + 6 + 12, cy, 10U, btn=273U)
|
||||
assert_true(comp.shell.menu_open)
|
||||
assert_true(comp.shell.menu_rows.map(m => m.label).contains("Close 2 windows"))
|
||||
ignore(@sys.write_file_bytes("_build/dock_menu.png", @renderer.encode_png(comp.compose_frame())))
|
||||
}
|
||||
@@ -907,7 +907,7 @@ test "the dock module magnifies the tile under the pointer and shows nothing whe
|
||||
let comp = new_comp("dock")
|
||||
assert_true(comp.shell.load_path("build/components/dock.wasm") is Some(_))
|
||||
ignore(comp.compose_frame())
|
||||
let slot = comp.shell.slots()[comp.shell.slots().length() - 1]
|
||||
let slot = comp.shell.slots().filter(s => comp.shell.slot_module(s).contains("dock"))[0]
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
assert_true(r.w > 0)
|
||||
let frame = fn() {
|
||||
@@ -922,6 +922,102 @@ test "the dock module magnifies the tile under the pointer and shows nothing whe
|
||||
assert_eq(comp.shell.hover_slot, "")
|
||||
}
|
||||
|
||||
///|
|
||||
test "the dock: pinned and running apps, window dots, the hover label and the per-app menu" {
|
||||
let socket_path = "/tmp/wayland-moon-dock2-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
// A known catalog instead of whatever this machine has installed.
|
||||
comp.shell.apps.clear()
|
||||
for id in ["foot", "firefox", "gimp"] {
|
||||
comp.shell.apps.push({ id, name: id.to_upper(), comment: "", category: "", glyph: "x" })
|
||||
}
|
||||
comp.shell.apps_dirty = true
|
||||
assert_true(comp.shell.load_path("build/components/dock.wasm") is Some(_))
|
||||
ignore(comp.compose_frame())
|
||||
let slot = comp.shell.slots().filter(s => comp.shell.slot_module(s).contains("dock"))[0]
|
||||
let pinned = fn() {
|
||||
comp.shell.slot_config(slot).filter(it => it.key == "pinned")[0].value
|
||||
}
|
||||
// Nothing chosen yet: the catalog's first apps, saved so launches don't reorder them.
|
||||
assert_eq(pinned(), "foot;firefox;gimp")
|
||||
// The pinned list isn't a row of the dock's settings menu.
|
||||
let w0 = comp.shell.slot_rect(slot).w
|
||||
// A foot window joins foot's icon; an unknown app gets its own icon after the pinned ones.
|
||||
let _a = open_and_configure_client(comp, socket_path, "Term", "foot")
|
||||
let _b = open_and_configure_client(comp, socket_path, "Other", "zzz")
|
||||
ignore(comp.compose_frame())
|
||||
ignore(comp.compose_frame())
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
assert_true(r.w > w0) // the dock grew for the running app
|
||||
let cy = r.y + r.h / 2
|
||||
let pitch = 24 + 6 // medium icons
|
||||
let x_of = fn(i : Int) { r.x + 6 + i * pitch + 12 + (if i >= 3 { 11 } else { 0 }) }
|
||||
// Hovering an icon shows its name above it.
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x_of(1).to_double(), cy.to_double()), 1U)
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.shell.dock_hover_name(), "FIREFOX")
|
||||
comp.handle_input(@nested.InputEvent::PointerMove(x_of(3).to_double(), cy.to_double()), 2U)
|
||||
assert_eq(comp.shell.dock_hover_name(), "zzz")
|
||||
let labels = fn() { comp.shell.menu_rows.map(r => r.label) }
|
||||
let pick = fn(label : String, t : UInt) raise {
|
||||
let i = labels().search(label).unwrap()
|
||||
let m = comp.shell.menu_rect
|
||||
click_at(comp, m.x + m.w / 2, m.y + 26 + 28 * i + 14, t)
|
||||
}
|
||||
// Right-click foot: it runs, it's pinned first.
|
||||
click_at(comp, x_of(0), cy, 10U, btn=273U)
|
||||
assert_true(comp.shell.menu_open)
|
||||
assert_eq(comp.shell.menu_title, "FOOT")
|
||||
assert_eq(labels(), ["New window", "Unpin from dock", "Move right", "Quit", "Dock settings..."])
|
||||
assert_eq(comp.shell.dock_hover_name(), "") // no label over the menu
|
||||
pick("Move right", 20U)
|
||||
assert_eq(pinned(), "firefox;foot;gimp")
|
||||
// Firefox (now first) isn't running.
|
||||
click_at(comp, x_of(0), cy, 30U, btn=273U)
|
||||
assert_eq(labels(), ["Open", "Unpin from dock", "Move right", "Dock settings..."])
|
||||
pick("Unpin from dock", 40U)
|
||||
assert_eq(pinned(), "foot;gimp")
|
||||
// The running app: pin it.
|
||||
ignore(comp.compose_frame())
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
let x2 = r.x + 6 + 2 * pitch + 11 + 12
|
||||
click_at(comp, x2, cy, 50U, btn=273U)
|
||||
assert_eq(comp.shell.menu_title, "zzz")
|
||||
assert_eq(labels(), ["New window", "Pin to dock", "Quit", "Dock settings..."])
|
||||
pick("Pin to dock", 60U)
|
||||
assert_eq(pinned(), "foot;gimp;zzz")
|
||||
// Dock settings: the visible settings only.
|
||||
ignore(comp.compose_frame())
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
click_at(comp, r.x + 6 + 12, cy, 70U, btn=273U)
|
||||
pick("Dock settings...", 80U)
|
||||
assert_eq(comp.shell.menu_title, "Dock settings")
|
||||
assert_true(labels().contains("Icon size"))
|
||||
assert_true(labels().contains("Large"))
|
||||
assert_false(labels().contains(""))
|
||||
pick("Large", 90U)
|
||||
comp.handle_input(@nested.InputEvent::Key(1U, true), 95U) // Escape
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(comp.shell.slot_rect(slot).w > r.w) // bigger icons, wider dock
|
||||
// A left click on a running app's icon focuses its window.
|
||||
let focused = fn() {
|
||||
let mut f = 0UL
|
||||
for id, w in comp.windows {
|
||||
if w.focused {
|
||||
f = id
|
||||
}
|
||||
}
|
||||
f
|
||||
}
|
||||
let r = comp.shell.slot_rect(slot)
|
||||
click_at(comp, r.x + 6 + 2 * 34 + 14, cy, 100U) // zzz, the third icon
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(focused(), 2UL)
|
||||
click_at(comp, r.x + 6 + 14, cy, 110U) // foot, the first
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(focused(), 1UL) // foot's window, opened first
|
||||
}
|
||||
|
||||
///| Bind wl_data_device_manager and get a data device; returns (manager, device).
|
||||
fn data_device_for(c : TestWaylandClient) -> (UInt, UInt) {
|
||||
let mgr = bind_global(c, 2U, "wl_data_device_manager", 3U)
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
///| The shell's half of the dock (components/dock, logic in lib/dock). The module draws the icons
|
||||
/// and handles clicks; the shell, which sees right-clicks and can draw outside the panel, adds:
|
||||
/// - the per-app right-click menu: Open / New window, Pin to dock / Unpin, Move left / right,
|
||||
/// Quit (every window of the app) and Dock settings;
|
||||
/// - the app's name in a label above the icon under the pointer;
|
||||
/// - the dock's width as its apps come and go (a module's preferred width is read once);
|
||||
/// - the icons of pinned apps that aren't running (the icons table otherwise has windows' apps);
|
||||
/// - the first pinned list: until one is saved the dock pins the catalog's first apps, and the
|
||||
/// shell saves that choice once so later launches (which reorder the catalog) don't move them.
|
||||
/// The pinned list is the dock's hidden `pinned` setting, kept in state.edn's :module-config
|
||||
/// like any module setting. Both sides call lib/dock's `items` / `item_at`, so they agree on
|
||||
/// which app is where.
|
||||
|
||||
///| The dock module's id.
|
||||
let dock_module_id : String = "org.chandra.dock"
|
||||
|
||||
///|
|
||||
fn Widget::is_dock(self : Widget) -> Bool {
|
||||
self.pl.id == dock_module_id
|
||||
}
|
||||
|
||||
///| The dock's settings as the module holds them now.
|
||||
fn dock_config(w : Widget) -> @dock.DockConfig {
|
||||
@dock.DockConfig::from_pairs(w.pl.config_items().map(it => (it.key, it.value)))
|
||||
}
|
||||
|
||||
///| The windows as the dock sees them.
|
||||
fn DesktopShell::dock_windows(self : DesktopShell) -> Array[@dock.DockWindow] {
|
||||
self.win_list.map(e => { id: e.id, app_id: e.app_id, focused: e.focused })
|
||||
}
|
||||
|
||||
///| The dock in `w`'s settings and icons, as the module computes them.
|
||||
fn DesktopShell::dock_state(self : DesktopShell, w : Widget) -> (@dock.DockConfig, Array[@dock.DockItem]) {
|
||||
let cfg = dock_config(w)
|
||||
(cfg, @dock.items(cfg, self.apps, self.dock_windows()))
|
||||
}
|
||||
|
||||
///| Height the dock is drawn at (before its first layout, the height it asked for).
|
||||
fn dock_height(w : Widget) -> Int {
|
||||
if w.rect.h > 0 {
|
||||
w.rect.h
|
||||
} else {
|
||||
w.pl.pref_h
|
||||
}
|
||||
}
|
||||
|
||||
///| The width the dock in `w` needs for its icons now, or None when `w` isn't the dock.
|
||||
fn DesktopShell::dock_width(self : DesktopShell, w : Widget) -> Int? {
|
||||
if !w.is_dock() {
|
||||
return None
|
||||
}
|
||||
let (cfg, items) = self.dock_state(w)
|
||||
Some(@dock.preferred_width(items, cfg, dock_height(w)))
|
||||
}
|
||||
|
||||
///| The dock's icons and the index of the one under (x, y), when `w` is the dock and one is.
|
||||
fn DesktopShell::dock_item_at(
|
||||
self : DesktopShell,
|
||||
w : Widget,
|
||||
x : Int,
|
||||
y : Int,
|
||||
) -> (Array[@dock.DockItem], Int)? {
|
||||
if !w.is_dock() || !inside(w.rect, x, y) {
|
||||
return None
|
||||
}
|
||||
let (cfg, items) = self.dock_state(w)
|
||||
let i = @dock.item_at(items, cfg, w.rect.w, w.rect.h, x - w.rect.x, y - w.rect.y)
|
||||
if i >= 0 {
|
||||
Some((items, i))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
///| App ids of every dock's icons (for the icons table).
|
||||
fn DesktopShell::dock_app_ids(self : DesktopShell) -> Array[String] {
|
||||
let out : Array[String] = []
|
||||
for w in self.widgets {
|
||||
if w.is_dock() {
|
||||
let (_, items) = self.dock_state(w)
|
||||
for it in items {
|
||||
out.push(it.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
///| Save the dock's first pinned list the first time it is seen without one (see the top).
|
||||
fn DesktopShell::settle_dock_pins(self : DesktopShell) -> Unit {
|
||||
if self.apps.length() == 0 {
|
||||
return
|
||||
}
|
||||
for w in self.widgets.copy() {
|
||||
if w.is_dock() {
|
||||
let cfg = dock_config(w)
|
||||
if cfg.pinned is None {
|
||||
self.set_module_setting(w.slot, "pinned", @dock.encode_pins(cfg.pins(self.apps)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| A dock menu row: `kind` 7 starts the app, 8 pins or unpins it, 9 moves its pin by `value`
|
||||
/// places, 10 closes its windows. `arg` is the app id.
|
||||
fn dock_row(label : String, kind : Int, id : String, value? : String = "") -> MenuRow {
|
||||
{ ..menu_row(label, kind, arg=id), value, }
|
||||
}
|
||||
|
||||
///| The right-click menu of dock icon `i`, titled with the app's name.
|
||||
fn DesktopShell::open_dock_menu(
|
||||
self : DesktopShell,
|
||||
w : Widget,
|
||||
items : Array[@dock.DockItem],
|
||||
i : Int,
|
||||
x : Int,
|
||||
) -> Unit {
|
||||
let it = items[i]
|
||||
let rows : Array[MenuRow] = []
|
||||
let n = it.windows.length()
|
||||
rows.push(dock_row(if n == 0 { "Open" } else { "New window" }, 7, it.id))
|
||||
if it.pinned {
|
||||
rows.push(dock_row("Unpin from dock", 8, it.id))
|
||||
let pinned = items.filter(x => x.pinned).length()
|
||||
if i > 0 {
|
||||
rows.push(dock_row("Move left", 9, it.id, value="-1"))
|
||||
}
|
||||
if i < pinned - 1 {
|
||||
rows.push(dock_row("Move right", 9, it.id, value="1"))
|
||||
}
|
||||
} else {
|
||||
rows.push(dock_row("Pin to dock", 8, it.id))
|
||||
}
|
||||
if n == 1 {
|
||||
rows.push(dock_row("Quit", 10, it.id))
|
||||
} else if n > 1 {
|
||||
rows.push(dock_row("Close " + n.to_string() + " windows", 10, it.id))
|
||||
}
|
||||
rows.push(menu_row("Dock settings...", 3))
|
||||
self.open_menu(it.name, rows, w.slot, x)
|
||||
}
|
||||
|
||||
///| A dock menu row was chosen for the dock in `slot`.
|
||||
fn DesktopShell::dock_menu_choice(self : DesktopShell, slot : String, row : MenuRow) -> Unit {
|
||||
match self.widget_by_slot(slot) {
|
||||
None => ()
|
||||
Some(w) => {
|
||||
let (cfg, items) = self.dock_state(w)
|
||||
let pins = cfg.pins(self.apps)
|
||||
match row.kind {
|
||||
7 => self.launch_catalog_app(row.arg)
|
||||
8 => self.set_module_setting(slot, "pinned", @dock.encode_pins(@dock.toggle_pin(pins, row.arg)))
|
||||
9 => {
|
||||
let delta = if row.value == "-1" { -1 } else { 1 }
|
||||
self.set_module_setting(slot, "pinned", @dock.encode_pins(@dock.move_pin(pins, row.arg, delta)))
|
||||
}
|
||||
10 =>
|
||||
for it in items {
|
||||
if it.id == row.arg {
|
||||
for win in it.windows {
|
||||
self.actions.push(Window(win, Close))
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| The name of the dock icon under the pointer and that icon's centre x on screen, if any.
|
||||
fn DesktopShell::dock_label(self : DesktopShell) -> (String, Int)? {
|
||||
match self.widget_by_slot(self.hover_slot) {
|
||||
Some(w) if w.is_dock() =>
|
||||
match self.dock_item_at(w, self.ptr_x, self.ptr_y) {
|
||||
Some((items, i)) => {
|
||||
let cfg = dock_config(w)
|
||||
Some((items[i].name, w.rect.x + @dock.item_center(items, cfg, w.rect.h, i)))
|
||||
}
|
||||
None => None
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
||||
///| The name the dock's hover label shows now ("" when none shows).
|
||||
pub fn DesktopShell::dock_hover_name(self : DesktopShell) -> String {
|
||||
if self.menu_open || self.drag_active {
|
||||
return ""
|
||||
}
|
||||
match self.dock_label() {
|
||||
Some((name, _)) => name
|
||||
None => ""
|
||||
}
|
||||
}
|
||||
|
||||
///| The name of the dock icon under the pointer, in a label above it.
|
||||
fn DesktopShell::render_dock_label(self : DesktopShell, tokens : @theme.Tokens, out : Array[@scene.DrawOp]) -> Unit {
|
||||
match self.dock_label() {
|
||||
Some((name, cx)) => {
|
||||
let fs = tokens.font_size.reinterpret_as_int() - 2
|
||||
let lw = @ui.text_width(name, fs) + 20
|
||||
let lh = 24
|
||||
let lx = clamp_menu(cx - lw / 2, 4, self.screen_w - lw - 4)
|
||||
let ly = self.panel_rect.y - lh - 6
|
||||
let r = tokens.radius.reinterpret_as_int()
|
||||
translate(
|
||||
[
|
||||
@ui.fill_rect(@ui.rect(0, 0, lw, lh), tokens.palette.surface_popup, radius=r),
|
||||
@ui.stroke_rect(@ui.rect(0, 0, lw, lh), tokens.palette.border, radius=r),
|
||||
@ui.text(lw / 2, lh / 2, name, fs, tokens.palette.foreground, align=CENTER),
|
||||
],
|
||||
lx,
|
||||
ly,
|
||||
out,
|
||||
)
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ pub fn DesktopShell::window_icon(self : DesktopShell, app_id : String) -> UInt {
|
||||
if app_id.length() == 0 { 0U } else { self.app_icon(app_id) }
|
||||
}
|
||||
|
||||
///| Publish the icons table (app id -> image handle) for the windows' apps.
|
||||
///| Publish the icons table (app id -> image handle) for the windows' apps and the dock's.
|
||||
fn DesktopShell::publish_icons(self : DesktopShell) -> Unit {
|
||||
let t = @wasm.Table::new()
|
||||
let seen : Map[String, Bool] = {}
|
||||
@@ -146,6 +146,18 @@ fn DesktopShell::publish_icons(self : DesktopShell) -> Unit {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The dock's apps, running or not.
|
||||
for id in self.dock_app_ids() {
|
||||
if !seen.contains(id) {
|
||||
seen.set(id, true)
|
||||
let h = self.app_icon(id)
|
||||
if h != 0U {
|
||||
t.str(id)
|
||||
t.int(h.reinterpret_as_int())
|
||||
t.end_row()
|
||||
}
|
||||
}
|
||||
}
|
||||
@wasm.publish(Icons, t)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
"chandra/desktop/lib/moon" @moon,
|
||||
"chandra/desktop/lib/timefmt" @timefmt,
|
||||
"chandra/desktop/lib/launcher" @launcher,
|
||||
"chandra/desktop/lib/dock" @dock,
|
||||
"chandra/desktop/compositor/scene" @scene,
|
||||
"jqlssg/moonedn" @edn,
|
||||
"chandra/desktop/compositor/sys" @sys,
|
||||
|
||||
+11
-20
@@ -335,6 +335,9 @@ pub(all) struct DesktopShell {
|
||||
mut drag_x0 : Int
|
||||
mut drag_y0 : Int
|
||||
mut drag_active : Bool
|
||||
/// Where the pointer last was (the dock's hover label follows it).
|
||||
mut ptr_x : Int
|
||||
mut ptr_y : Int
|
||||
// WIT inspector state (see inspector.mbt)
|
||||
mut inspect_on : Bool
|
||||
mut hover_id : String
|
||||
@@ -442,6 +445,8 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
|
||||
drag_x0: 0,
|
||||
drag_y0: 0,
|
||||
drag_active: false,
|
||||
ptr_x: -1,
|
||||
ptr_y: -1,
|
||||
inspect_on: false,
|
||||
hover_id: "",
|
||||
hover_x: 0,
|
||||
@@ -781,6 +786,8 @@ pub fn DesktopShell::pointer_up(self : DesktopShell) -> Bool {
|
||||
|
||||
///| Pointer motion; returns true when over a popup or the menu (so windows don't see it).
|
||||
pub fn DesktopShell::pointer_move(self : DesktopShell, x : Int, y : Int) -> Bool {
|
||||
self.ptr_x = x
|
||||
self.ptr_y = y
|
||||
if self.desk_drag {
|
||||
self.desk_set = true
|
||||
self.desk_x = x - self.desk_off_x
|
||||
@@ -822,26 +829,6 @@ pub fn DesktopShell::pointer_move(self : DesktopShell, x : Int, y : Int) -> Bool
|
||||
Some(w) => ignore(self.deliver(w, false, PointerMove(x - w.rect.x, y - w.rect.y)))
|
||||
None => ()
|
||||
}
|
||||
// Hover: the widget under the pointer sees moves, the one it left sees a leave.
|
||||
let hovered = match self.widget_at(x, y) {
|
||||
Some(w) if !self.popup_covers(x, y) => Some(w)
|
||||
_ => None
|
||||
}
|
||||
let hslot = match hovered {
|
||||
Some(w) => w.slot
|
||||
None => ""
|
||||
}
|
||||
if hslot != self.hover_slot {
|
||||
match self.widget_by_slot(self.hover_slot) {
|
||||
Some(old) => ignore(self.deliver(old, false, PointerLeave))
|
||||
None => ()
|
||||
}
|
||||
self.hover_slot = hslot
|
||||
}
|
||||
match hovered {
|
||||
Some(w) => ignore(self.deliver(w, false, PointerMove(x - w.rect.x, y - w.rect.y)))
|
||||
None => ()
|
||||
}
|
||||
let mut over = false
|
||||
for w in self.widgets.copy() {
|
||||
if w.popup_rect.w > 0 {
|
||||
@@ -950,6 +937,7 @@ pub fn DesktopShell::render(
|
||||
if self.widgets.iter().any(w => w.has_cap("system") || w.has_cap("windows")) {
|
||||
@wasm.set_windows(self.win_list)
|
||||
}
|
||||
self.settle_dock_pins()
|
||||
if self.widgets.iter().any(w => w.has_cap("icons")) {
|
||||
self.publish_icons()
|
||||
}
|
||||
@@ -977,6 +965,9 @@ pub fn DesktopShell::render(
|
||||
self.refresh_popup(wd)
|
||||
self.draw_popup(wd, panel_ops)
|
||||
}
|
||||
if !self.menu_open && !self.drag_active {
|
||||
self.render_dock_label(tokens, panel_ops)
|
||||
}
|
||||
if self.menu_open {
|
||||
self.render_menu(w, tokens, panel_ops)
|
||||
} else {
|
||||
|
||||
@@ -188,7 +188,7 @@ fn DesktopShell::panel_slots(self : DesktopShell) -> Array[@panel.SlotIn] {
|
||||
let w = self.widgets[i]
|
||||
out.push({
|
||||
id: w.slot,
|
||||
pref_w: w.pl.pref_w,
|
||||
pref_w: self.dock_width(w).unwrap_or(w.pl.pref_w),
|
||||
pref_h: w.pl.pref_h,
|
||||
min_w: w.pl.min_w,
|
||||
stretch: w.pl.stretch,
|
||||
@@ -753,12 +753,8 @@ pub fn DesktopShell::set_power_timeouts(self : DesktopShell, screen_off : Int, s
|
||||
self.save_state()
|
||||
}
|
||||
|
||||
///| Carry out what modules asked of the host during their last calls.
|
||||
fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
while true {
|
||||
match @wasm.next_request() {
|
||||
None => break
|
||||
Some(Launch(id)) => {
|
||||
///| Start the catalog app `id` (a desktop file id) and remember it as the latest launch.
|
||||
fn DesktopShell::launch_catalog_app(self : DesktopShell, id : String) -> Unit {
|
||||
match self.command_for(id) {
|
||||
Some(bin) =>
|
||||
if @sys.spawn(bin, self.display) {
|
||||
@@ -769,7 +765,14 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
}
|
||||
None => self.say("No executable for " + id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| Carry out what modules asked of the host during their last calls.
|
||||
fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
while true {
|
||||
match @wasm.next_request() {
|
||||
None => break
|
||||
Some(Launch(id)) => self.launch_catalog_app(id)
|
||||
Some(FocusWindow(n)) => self.actions.push(FocusWindow(n.to_int64().to_uint64()))
|
||||
Some(SetLayout(m)) => self.actions.push(SetLayout(m))
|
||||
Some(Logout) => self.actions.push(Logout)
|
||||
@@ -958,6 +961,10 @@ pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool
|
||||
self.open_window_menu(win, x)
|
||||
true
|
||||
}
|
||||
Some(w) if self.dock_item_at(w, x, y) is Some((items, i)) => {
|
||||
self.open_dock_menu(w, items, i, x)
|
||||
true
|
||||
}
|
||||
Some(w) => {
|
||||
self.name_catalog()
|
||||
let rows : Array[MenuRow] = []
|
||||
@@ -1037,6 +1044,10 @@ fn DesktopShell::open_window_menu(self : DesktopShell, win : WinInfo, x : Int) -
|
||||
fn config_rows(items : Array[@wasm.ConfigItem]) -> Array[MenuRow] {
|
||||
let rows : Array[MenuRow] = []
|
||||
for it in items {
|
||||
if it.label.length() == 0 {
|
||||
// Kept by the module (e.g. the dock's pinned apps) but not a menu choice.
|
||||
continue
|
||||
}
|
||||
if it.choices.length() == 0 {
|
||||
let on = it.value == "on"
|
||||
rows.push({ ..menu_row(it.label, 4, arg=it.key), value: if on { "off" } else { "on" }, ticked: on })
|
||||
@@ -1141,6 +1152,7 @@ fn DesktopShell::menu_pointer_down(self : DesktopShell, x : Int, y : Int) -> Boo
|
||||
3 => self.open_module_settings(slot)
|
||||
4 => self.choose_module_setting(slot, row.arg, row.value)
|
||||
6 => self.actions.push(Window(row.window_id, row.window_cmd))
|
||||
7 | 8 | 9 | 10 => self.dock_menu_choice(slot, row)
|
||||
// A heading: the menu stays open.
|
||||
_ => self.menu_open = true
|
||||
}
|
||||
|
||||
+528
-64
@@ -1,56 +1,412 @@
|
||||
///| Dock-style quick launcher: a row of app tiles that grow under the pointer,
|
||||
/// click to start. Pure: the component stub passes in the app list and tokens.
|
||||
///| The dock: pinned apps first, then (after a thin divider) apps that are running but not pinned,
|
||||
/// each drawn with its theme icon (or a coloured letter tile when the theme has none) and a dot
|
||||
/// under it per open window, up to three, lit when the app has focus. The icon under the pointer
|
||||
/// grows, its neighbours a little. A click starts an app that isn't running, brings a running
|
||||
/// one's newest window forward, and when the app already has focus steps to its next window.
|
||||
///
|
||||
/// Pure: the component (components/dock) hands in the app catalog, the windows and an icon lookup.
|
||||
/// The shell runs the same `items` / `item_at` to draw the hover label and the per-app right-click
|
||||
/// menu (Pin, Move, Quit), so both always agree on which app is where.
|
||||
|
||||
///| Most tiles shown; the catalog is ordered defaults, recents, then the rest.
|
||||
pub let max_tiles : Int = 8
|
||||
// ---------------------------------------------------------------- settings
|
||||
|
||||
///| Space between tile slots.
|
||||
let gap : Int = 6
|
||||
|
||||
///| Side padding of the whole dock.
|
||||
let pad : Int = 6
|
||||
|
||||
///| Tile edge when not hovered, for a widget `h` pixels tall.
|
||||
fn base_size(h : Int) -> Int {
|
||||
let s = h - 14
|
||||
if s < 16 { 16 } else if s > 32 { 32 } else { s }
|
||||
///| One item of the right-click "Module settings" menu (the `module-config` record). An item
|
||||
/// with an empty label is kept by the shell but not listed (the pinned apps).
|
||||
#derive(Eq, Debug)
|
||||
pub(all) struct ConfigEntry {
|
||||
key : String
|
||||
label : String
|
||||
choices : Array[String]
|
||||
value : String
|
||||
}
|
||||
|
||||
///| Distance between tile centres.
|
||||
fn pitch(h : Int) -> Int {
|
||||
base_size(h) + gap
|
||||
///| Icon sizes offered in the dock's settings.
|
||||
pub let size_choices : Array[String] = ["Small", "Medium", "Large"]
|
||||
|
||||
///| The pinned apps when nobody has chosen yet: the first this many of the catalog (its default
|
||||
/// apps come first). The shell saves that choice the first time it sees the dock.
|
||||
pub let default_pin_count : Int = 5
|
||||
|
||||
///| What the user picked for the dock.
|
||||
pub(all) struct DockConfig {
|
||||
/// Pinned app ids in dock order; None until chosen (then the catalog's first few).
|
||||
mut pinned : Array[String]?
|
||||
/// One of `size_choices`.
|
||||
mut size : String
|
||||
mut magnify : Bool
|
||||
/// Show apps that run but aren't pinned.
|
||||
mut running : Bool
|
||||
}
|
||||
|
||||
///| Preferred widget width for `n` tiles.
|
||||
pub fn preferred_width(n : Int) -> Int {
|
||||
let n = if n > max_tiles { max_tiles } else { n }
|
||||
pad * 2 + n * pitch(34) - gap
|
||||
///|
|
||||
pub fn DockConfig::new() -> DockConfig {
|
||||
{ pinned: None, size: "Medium", magnify: true, running: true }
|
||||
}
|
||||
|
||||
///| Index of the tile slot under widget-local `x`, or -1 (outside the tile row / padding / gap).
|
||||
pub fn tile_at(n : Int, h : Int, x : Int, y : Int) -> Int {
|
||||
let n = if n > max_tiles { max_tiles } else { n }
|
||||
if y < 0 || y >= h || x < pad {
|
||||
return -1
|
||||
///| A config built from saved key/value pairs (what the shell reads back from the module).
|
||||
pub fn DockConfig::from_pairs(pairs : Array[(String, String)]) -> DockConfig {
|
||||
let c = DockConfig::new()
|
||||
for p in pairs {
|
||||
ignore(c.set(p.0, p.1))
|
||||
}
|
||||
let rel = x - pad
|
||||
let i = rel / pitch(h)
|
||||
if i >= n {
|
||||
return -1
|
||||
c
|
||||
}
|
||||
|
||||
///|
|
||||
fn on_off(b : Bool) -> String {
|
||||
if b { "on" } else { "off" }
|
||||
}
|
||||
|
||||
///| The pinned list as the `pinned` setting's value: ids joined by ";", and ";" alone for an
|
||||
/// empty list (the empty string means "not chosen yet").
|
||||
pub fn encode_pins(ids : Array[String]) -> String {
|
||||
if ids.length() == 0 {
|
||||
return ";"
|
||||
}
|
||||
let sb = StringBuilder::new()
|
||||
for i = 0; i < ids.length(); i = i + 1 {
|
||||
if i > 0 {
|
||||
sb.write_char(';')
|
||||
}
|
||||
sb.write_string(ids[i])
|
||||
}
|
||||
sb.to_string()
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn decode_pins(s : String) -> Array[String]? {
|
||||
if s.length() == 0 {
|
||||
return None
|
||||
}
|
||||
let out : Array[String] = []
|
||||
for part in s.split(";") {
|
||||
let id = part.to_string()
|
||||
if id.length() > 0 && !out.contains(id) {
|
||||
out.push(id)
|
||||
}
|
||||
}
|
||||
Some(out)
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn DockConfig::items(self : DockConfig) -> Array[ConfigEntry] {
|
||||
[
|
||||
{ key: "icon-size", label: "Icon size", choices: size_choices, value: self.size },
|
||||
{ key: "magnify", label: "Magnify icons under the pointer", choices: [], value: on_off(self.magnify) },
|
||||
{ key: "running", label: "Show running apps that aren't pinned", choices: [], value: on_off(self.running) },
|
||||
{
|
||||
key: "pinned",
|
||||
label: "",
|
||||
choices: [],
|
||||
value: match self.pinned {
|
||||
Some(p) => encode_pins(p)
|
||||
None => ""
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
///| Apply one setting; true when it changed something. Unknown keys and values are ignored.
|
||||
pub fn DockConfig::set(self : DockConfig, key : String, value : String) -> Bool {
|
||||
let flag = fn(cur : Bool, set : (Bool) -> Unit) -> Bool {
|
||||
match value {
|
||||
"on" if !cur => {
|
||||
set(true)
|
||||
true
|
||||
}
|
||||
"off" if cur => {
|
||||
set(false)
|
||||
true
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
match key {
|
||||
"icon-size" =>
|
||||
if size_choices.contains(value) && value != self.size {
|
||||
self.size = value
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
"magnify" => flag(self.magnify, b => self.magnify = b)
|
||||
"running" => flag(self.running, b => self.running = b)
|
||||
"pinned" => {
|
||||
let p = decode_pins(value)
|
||||
if p != self.pinned {
|
||||
self.pinned = p
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
///| The pins in use: the chosen ones, or the catalog's first `default_pin_count`.
|
||||
pub fn DockConfig::pins(self : DockConfig, apps : Array[@types.AppEntry]) -> Array[String] {
|
||||
match self.pinned {
|
||||
Some(p) => p
|
||||
None => {
|
||||
let out : Array[String] = []
|
||||
for a in apps {
|
||||
if out.length() < default_pin_count {
|
||||
out.push(a.id)
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| The module's settings (one module instance per wasm instance).
|
||||
pub let config : DockConfig = DockConfig::new()
|
||||
|
||||
// ---------------------------------------------------------------- items
|
||||
|
||||
///| A window as the dock sees it.
|
||||
pub(all) struct DockWindow {
|
||||
id : UInt64
|
||||
app_id : String
|
||||
focused : Bool
|
||||
}
|
||||
|
||||
///| One icon in the dock.
|
||||
#derive(Debug)
|
||||
pub(all) struct DockItem {
|
||||
/// The catalog id (desktop file id) when known, else the windows' app id.
|
||||
id : String
|
||||
name : String
|
||||
glyph : String
|
||||
pinned : Bool
|
||||
/// Its open windows, oldest first.
|
||||
windows : Array[UInt64]
|
||||
/// One of its windows has focus.
|
||||
focused : Bool
|
||||
}
|
||||
|
||||
///| The id among `ids` of the app whose windows carry `app_id`: the same id, the same ignoring
|
||||
/// case, or the id's last dotted part (`org.gnome.Nautilus` for windows of `nautilus`), or the
|
||||
/// window's last dotted part (`firefox` for windows of `org.mozilla.firefox`).
|
||||
pub fn match_app(app_id : String, ids : Array[String]) -> String? {
|
||||
if app_id.length() == 0 {
|
||||
return None
|
||||
}
|
||||
if ids.contains(app_id) {
|
||||
return Some(app_id)
|
||||
}
|
||||
let low = app_id.to_lower()
|
||||
for id in ids {
|
||||
if id.to_lower() == low {
|
||||
return Some(id)
|
||||
}
|
||||
}
|
||||
let tail = fn(s : String) -> String {
|
||||
let parts = s.split(".").to_array()
|
||||
parts[parts.length() - 1].to_string().to_lower()
|
||||
}
|
||||
for id in ids {
|
||||
if id.contains(".") && tail(id) == low {
|
||||
return Some(id)
|
||||
}
|
||||
}
|
||||
if app_id.contains(".") {
|
||||
let t = tail(app_id)
|
||||
for id in ids {
|
||||
if id.to_lower() == t {
|
||||
return Some(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
///| The catalog app whose name, without spaces and ignoring case, is `app_id` (windows of
|
||||
/// `xterm` belong to `debian-xterm.desktop`, named "XTerm").
|
||||
pub fn match_name(app_id : String, apps : Array[@types.AppEntry]) -> String? {
|
||||
if app_id.length() == 0 {
|
||||
return None
|
||||
}
|
||||
let low = app_id.to_lower()
|
||||
for a in apps {
|
||||
if a.name.to_lower().replace_all(old=" ", new="") == low {
|
||||
return Some(a.id)
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
///| The dock's icons: the pinned apps in their order, then the other running apps in the order
|
||||
/// they first opened a window (when `cfg.running`). Windows without an app id aren't shown.
|
||||
pub fn items(
|
||||
cfg : DockConfig,
|
||||
apps : Array[@types.AppEntry],
|
||||
wins : Array[DockWindow],
|
||||
) -> Array[DockItem] {
|
||||
let by_id : Map[String, @types.AppEntry] = Map([])
|
||||
for a in apps {
|
||||
by_id.set(a.id, a)
|
||||
}
|
||||
let catalog_ids = apps.map(a => a.id)
|
||||
let pins = cfg.pins(apps)
|
||||
let sorted = wins.copy()
|
||||
sorted.sort_by((a, b) => a.id.compare(b.id))
|
||||
let out : Array[DockItem] = []
|
||||
let index : Map[String, Int] = Map([])
|
||||
let make = fn(id : String, pinned : Bool) -> DockItem {
|
||||
match by_id.get(id) {
|
||||
Some(a) => { id, name: a.name, glyph: a.glyph, pinned, windows: [], focused: false }
|
||||
None => {
|
||||
let parts = id.split(".").to_array()
|
||||
let name = parts[parts.length() - 1].to_string()
|
||||
{ id, name, glyph: app_glyph(id, id), pinned, windows: [], focused: false }
|
||||
}
|
||||
}
|
||||
}
|
||||
for p in pins {
|
||||
if !index.contains(p) {
|
||||
index.set(p, out.length())
|
||||
out.push(make(p, true))
|
||||
}
|
||||
}
|
||||
for w in sorted {
|
||||
let owner = match match_app(w.app_id, pins) {
|
||||
Some(id) => Some(id)
|
||||
None =>
|
||||
match match_app(w.app_id, catalog_ids) {
|
||||
Some(id) => Some(id)
|
||||
None =>
|
||||
match match_name(w.app_id, apps) {
|
||||
Some(id) => Some(id)
|
||||
None => if w.app_id.length() > 0 { Some(w.app_id) } else { None }
|
||||
}
|
||||
}
|
||||
}
|
||||
match owner {
|
||||
None => ()
|
||||
Some(id) => {
|
||||
let i = match index.get(id) {
|
||||
Some(i) => i
|
||||
None => {
|
||||
if !cfg.running {
|
||||
continue
|
||||
}
|
||||
index.set(id, out.length())
|
||||
out.push(make(id, false))
|
||||
out.length() - 1
|
||||
}
|
||||
}
|
||||
let it = out[i]
|
||||
it.windows.push(w.id)
|
||||
if w.focused {
|
||||
out[i] = { ..it, focused: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
///| Index of the first unpinned item (items.length() when all are pinned).
|
||||
fn first_running(items : Array[DockItem]) -> Int {
|
||||
let mut i = 0
|
||||
while i < items.length() && items[i].pinned {
|
||||
i = i + 1
|
||||
}
|
||||
// The gap between slots belongs to the nearer tile so the cursor never flickers off it.
|
||||
i
|
||||
}
|
||||
|
||||
///| Edge length of tile `i` given the hovered tile (-1 for none): the hovered tile
|
||||
/// grows most, its neighbours half as much.
|
||||
pub fn tile_size(i : Int, hover : Int, h : Int) -> Int {
|
||||
let base = base_size(h)
|
||||
let room = h - 4 - base
|
||||
let extra = if room > 8 { 8 } else if room < 0 { 0 } else { room }
|
||||
if hover < 0 {
|
||||
// ---------------------------------------------------------------- geometry
|
||||
|
||||
///| Side padding of the whole dock, and the room between two icons.
|
||||
let pad : Int = 6
|
||||
|
||||
///|
|
||||
let gap : Int = 6
|
||||
|
||||
///| Width of the divider between pinned and running apps.
|
||||
let divider_w : Int = 11
|
||||
|
||||
///| Rows of pixels kept free under the icons for the window dots.
|
||||
let dots_h : Int = 6
|
||||
|
||||
///| Icon edge for the chosen size in a dock `h` pixels tall.
|
||||
pub fn icon_size(cfg : DockConfig, h : Int) -> Int {
|
||||
let want = match cfg.size {
|
||||
"Small" => 20
|
||||
"Large" => 28
|
||||
_ => 24
|
||||
}
|
||||
let most = h - dots_h - 2
|
||||
let s = if want > most { most } else { want }
|
||||
if s < 12 {
|
||||
12
|
||||
} else {
|
||||
s
|
||||
}
|
||||
}
|
||||
|
||||
///| Distance between icon centres.
|
||||
fn pitch(cfg : DockConfig, h : Int) -> Int {
|
||||
icon_size(cfg, h) + gap
|
||||
}
|
||||
|
||||
///| Left edge of item `i`'s slot.
|
||||
fn slot_x(items : Array[DockItem], cfg : DockConfig, h : Int, i : Int) -> Int {
|
||||
let split = first_running(items)
|
||||
let extra = if i >= split && split > 0 { divider_w } else { 0 }
|
||||
pad + i * pitch(cfg, h) + extra
|
||||
}
|
||||
|
||||
///| Width that shows every item.
|
||||
pub fn preferred_width(items : Array[DockItem], cfg : DockConfig, h : Int) -> Int {
|
||||
let n = items.length()
|
||||
if n == 0 {
|
||||
return 80
|
||||
}
|
||||
slot_x(items, cfg, h, n - 1) + icon_size(cfg, h) + pad
|
||||
}
|
||||
|
||||
///| How many items fit in a dock `w` wide.
|
||||
fn visible(items : Array[DockItem], cfg : DockConfig, w : Int, h : Int) -> Int {
|
||||
let mut n = 0
|
||||
while n < items.length() && slot_x(items, cfg, h, n) + icon_size(cfg, h) + pad <= w {
|
||||
n = n + 1
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
///| The item under dock-local (x, y), or -1. The gap after an icon belongs to it, so the pointer
|
||||
/// never drops off the dock between two icons.
|
||||
pub fn item_at(items : Array[DockItem], cfg : DockConfig, w : Int, h : Int, x : Int, y : Int) -> Int {
|
||||
if y < 0 || y >= h || x < 0 || x >= w {
|
||||
return -1
|
||||
}
|
||||
let n = visible(items, cfg, w, h)
|
||||
for i = 0; i < n; i = i + 1 {
|
||||
let x0 = slot_x(items, cfg, h, i)
|
||||
if x >= x0 - gap / 2 && x < x0 + pitch(cfg, h) - gap / 2 {
|
||||
return i
|
||||
}
|
||||
}
|
||||
-1
|
||||
}
|
||||
|
||||
///| Centre x of item `i`, dock-local (for the shell's hover label and menu).
|
||||
pub fn item_center(items : Array[DockItem], cfg : DockConfig, h : Int, i : Int) -> Int {
|
||||
slot_x(items, cfg, h, i) + icon_size(cfg, h) / 2
|
||||
}
|
||||
|
||||
///| Edge of item `i`'s icon with `hover` the item under the pointer (-1: none): the hovered icon
|
||||
/// grows most and its neighbours half as much, when magnifying.
|
||||
pub fn item_size(cfg : DockConfig, i : Int, hover : Int, h : Int) -> Int {
|
||||
let base = icon_size(cfg, h)
|
||||
if !cfg.magnify || hover < 0 {
|
||||
return base
|
||||
}
|
||||
let room = h - dots_h - base
|
||||
let extra = if room > 8 { 8 } else if room < 0 { 0 } else { room }
|
||||
let d = if i > hover { i - hover } else { hover - i }
|
||||
if d == 0 {
|
||||
base + extra
|
||||
@@ -61,6 +417,8 @@ pub fn tile_size(i : Int, hover : Int, h : Int) -> Int {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- letter tiles
|
||||
|
||||
///| Tile colours: fixed saturated hues picked from the app id so an app keeps its colour.
|
||||
let hues : Array[(Int, Int, Int)] = [
|
||||
(0xE0, 0x5A, 0x4F), (0xE8, 0x92, 0x3A), (0xD9, 0xB5, 0x2E), (0x4F, 0xAE, 0x6B),
|
||||
@@ -104,8 +462,9 @@ pub fn app_glyph(app_id : String, fallback : String) -> String {
|
||||
"?"
|
||||
}
|
||||
|
||||
///| An app's icon: a rounded tile `s` pixels square centred on (cx, cy) in the app's colour, with
|
||||
/// its glyph in white. Shared by the dock and the task manager so an app looks the same in both.
|
||||
///| An app's stand-in icon: a rounded tile `s` pixels square centred on (cx, cy) in the app's
|
||||
/// colour, with its glyph in white. Shared by the dock and the task manager so an app looks the
|
||||
/// same in both when its icon theme has nothing for it.
|
||||
pub fn app_icon(
|
||||
cx : Int,
|
||||
cy : Int,
|
||||
@@ -123,64 +482,169 @@ pub fn app_icon(
|
||||
]
|
||||
}
|
||||
|
||||
///| Draw the dock into `size`. `hover` is the hovered tile index or -1.
|
||||
// ---------------------------------------------------------------- drawing
|
||||
|
||||
///| Draw the dock into `size`. `hover` is the item under the pointer or -1; `icon` gives an app
|
||||
/// id's theme icon handle (0: none, a letter tile is drawn).
|
||||
pub fn render(
|
||||
size : @types.Size,
|
||||
t : @theme.Tokens,
|
||||
apps : Array[@types.AppEntry],
|
||||
cfg : DockConfig,
|
||||
items : Array[DockItem],
|
||||
hover : Int,
|
||||
icon : (String) -> UInt,
|
||||
) -> Array[@types.DrawOp] {
|
||||
let w = size.w.reinterpret_as_int()
|
||||
let h = size.h.reinterpret_as_int()
|
||||
let r = t.radius.reinterpret_as_int()
|
||||
let n = if apps.length() > max_tiles { max_tiles } else { apps.length() }
|
||||
let ops : Array[@types.DrawOp] = [
|
||||
@ui.fill_rect(@ui.rect(0, 0, w, h), t.palette.surface, radius=r + 4),
|
||||
@ui.fill_rect(@ui.rect(0, 0, w, h), @ui.with_alpha(t.palette.surface_hover, 150), radius=r + 4),
|
||||
]
|
||||
if n == 0 {
|
||||
if items.length() == 0 {
|
||||
ops.push(
|
||||
@ui.text(w / 2, h / 2, "No apps", t.font_size.reinterpret_as_int() - 2, t.palette.foreground_muted, align=CENTER),
|
||||
)
|
||||
return ops
|
||||
}
|
||||
let n = visible(items, cfg, w, h)
|
||||
let base = icon_size(cfg, h)
|
||||
let cy = (h - dots_h) / 2 + 2
|
||||
let split = first_running(items)
|
||||
if split > 0 && split < n {
|
||||
let x = slot_x(items, cfg, h, split) - gap / 2 - divider_w / 2 - 1
|
||||
ops.push(@ui.fill_rect(@ui.rect(x, 6, 1, h - 12), t.palette.border))
|
||||
}
|
||||
for i = 0; i < n; i = i + 1 {
|
||||
let s = tile_size(i, hover, h)
|
||||
let cx = pad + i * pitch(h) + base_size(h) / 2
|
||||
ops.append(app_icon(cx, h / 2, s, apps[i].id, apps[i].glyph, hover=i == hover))
|
||||
let it = items[i]
|
||||
let s = item_size(cfg, i, hover, h)
|
||||
let cx = slot_x(items, cfg, h, i) + base / 2
|
||||
// Grow upwards from the icons' common baseline so the row doesn't wobble.
|
||||
let icy = cy + base / 2 - s / 2
|
||||
if i == hover {
|
||||
ops.push(
|
||||
@ui.fill_rect(@ui.rect(cx - s / 2 - 3, icy - s / 2 - 3, s + 6, s + 6), @ui.with_alpha(t.palette.foreground, 36), radius=r),
|
||||
)
|
||||
}
|
||||
let handle = icon(it.id)
|
||||
if handle != 0U {
|
||||
ops.push(Image({ rect: @ui.rect(cx - s / 2, icy - s / 2, s, s), image: handle }))
|
||||
} else {
|
||||
ops.append(app_icon(cx, icy, s, it.id, it.glyph, hover=i == hover))
|
||||
}
|
||||
// One dot per window, up to three; lit when the app has focus.
|
||||
let dots = if it.windows.length() > 3 { 3 } else { it.windows.length() }
|
||||
let col = if it.focused { t.palette.accent } else { t.palette.foreground_muted }
|
||||
let dw = if it.focused && dots == 1 { 10 } else { 4 }
|
||||
let total = dots * dw + (dots - 1) * 3
|
||||
for d = 0; d < dots; d = d + 1 {
|
||||
let dx = cx - total / 2 + d * (dw + 3)
|
||||
ops.push(@ui.fill_rect(@ui.rect(dx, h - 5, dw, 3), col, radius=1))
|
||||
}
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
///| Name shown for tile `i` (used for the hover tooltip popup).
|
||||
pub fn tile_name(apps : Array[@types.AppEntry], i : Int) -> String {
|
||||
if i >= 0 && i < apps.length() && i < max_tiles {
|
||||
apps[i].name
|
||||
// ---------------------------------------------------------------- input
|
||||
|
||||
///| What a pointer event asks the host to do.
|
||||
#derive(Eq, Debug)
|
||||
pub(all) enum DockAction {
|
||||
Nothing
|
||||
/// Start the app with this catalog id.
|
||||
Launch(String)
|
||||
/// Bring this window forward (restoring it if minimized).
|
||||
Focus(UInt64)
|
||||
}
|
||||
|
||||
///| The window a click on `it` brings forward: the newest when the app isn't focused, the next
|
||||
/// one after the focused window when it is (so repeated clicks walk through its windows). None
|
||||
/// when there is nothing to do (one window, already focused).
|
||||
pub fn click_target(it : DockItem, focused_window : UInt64?) -> UInt64? {
|
||||
let n = it.windows.length()
|
||||
if n == 0 {
|
||||
return None
|
||||
}
|
||||
match focused_window {
|
||||
Some(f) if it.focused => {
|
||||
let mut at = -1
|
||||
for i = 0; i < n; i = i + 1 {
|
||||
if it.windows[i] == f {
|
||||
at = i
|
||||
}
|
||||
}
|
||||
if n == 1 {
|
||||
None
|
||||
} else {
|
||||
""
|
||||
Some(it.windows[(at + 1) % n])
|
||||
}
|
||||
}
|
||||
_ => Some(it.windows[n - 1])
|
||||
}
|
||||
}
|
||||
|
||||
///| Pointer events -> (new hover, redraw?, app id to launch). Pure so it can be tested.
|
||||
///| Pointer events -> (new hover, redraw?, action). Pure so it can be tested. `focused_window`
|
||||
/// is the window with keyboard focus, if any.
|
||||
pub fn handle(
|
||||
apps : Array[@types.AppEntry],
|
||||
items : Array[DockItem],
|
||||
cfg : DockConfig,
|
||||
hover : Int,
|
||||
w : Int,
|
||||
h : Int,
|
||||
focused_window : UInt64?,
|
||||
event : @types.InputEvent,
|
||||
) -> (Int, Bool, String?) {
|
||||
) -> (Int, Bool, DockAction) {
|
||||
match event {
|
||||
PointerMove(p) => {
|
||||
let i = tile_at(apps.length(), h, p.x, p.y)
|
||||
(i, i != hover, None)
|
||||
let i = item_at(items, cfg, w, h, p.x, p.y)
|
||||
(i, i != hover, Nothing)
|
||||
}
|
||||
PointerLeave => (-1, hover != -1, None)
|
||||
PointerLeave => (-1, hover != -1, Nothing)
|
||||
PointerDown(p) => {
|
||||
let i = tile_at(apps.length(), h, p.x, p.y)
|
||||
if i >= 0 {
|
||||
(i, true, Some(apps[i].id))
|
||||
let i = item_at(items, cfg, w, h, p.x, p.y)
|
||||
if i < 0 {
|
||||
return (hover, false, Nothing)
|
||||
}
|
||||
let it = items[i]
|
||||
if it.windows.length() == 0 {
|
||||
(i, true, Launch(it.id))
|
||||
} else {
|
||||
(hover, false, None)
|
||||
match click_target(it, focused_window) {
|
||||
Some(win) => (i, true, Focus(win))
|
||||
None => (i, false, Nothing)
|
||||
}
|
||||
}
|
||||
_ => (hover, false, None)
|
||||
}
|
||||
_ => (hover, false, Nothing)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- pins
|
||||
|
||||
///| `pins` with `id` added at the end, or taken out when it is there.
|
||||
pub fn toggle_pin(pins : Array[String], id : String) -> Array[String] {
|
||||
if pins.contains(id) {
|
||||
pins.filter(p => p != id)
|
||||
} else {
|
||||
let out = pins.copy()
|
||||
out.push(id)
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
///| `pins` with `id` moved `delta` places (-1 left, 1 right), clamped to the ends.
|
||||
pub fn move_pin(pins : Array[String], id : String, delta : Int) -> Array[String] {
|
||||
let out = pins.copy()
|
||||
let mut at = -1
|
||||
for i = 0; i < out.length(); i = i + 1 {
|
||||
if out[i] == id {
|
||||
at = i
|
||||
}
|
||||
}
|
||||
let to = at + delta
|
||||
if at < 0 || to < 0 || to >= out.length() {
|
||||
return out
|
||||
}
|
||||
out[at] = out[to]
|
||||
out[to] = id
|
||||
out
|
||||
}
|
||||
+149
-30
@@ -1,36 +1,22 @@
|
||||
///|
|
||||
fn apps() -> Array[@types.AppEntry] {
|
||||
["a", "b", "c"].map(id => { id, name: id + "!", comment: "", category: "", glyph: id.to_upper() })
|
||||
["foot", "firefox", "org.gnome.Nautilus", "gimp", "org.kde.kate", "vlc"].map(id => {
|
||||
id,
|
||||
name: id + "!",
|
||||
comment: "",
|
||||
category: "",
|
||||
glyph: id.to_upper(),
|
||||
})
|
||||
}
|
||||
|
||||
///|
|
||||
test "tiles hit-test by slot and grow around the hovered one" {
|
||||
let h = 34
|
||||
assert_eq(tile_at(3, h, 0, 10), -1)
|
||||
assert_eq(tile_at(3, h, 12, 10), 0)
|
||||
assert_eq(tile_at(3, h, 12 + pitch(h), 10), 1)
|
||||
assert_eq(tile_at(3, h, 12 + 5 * pitch(h), 10), -1)
|
||||
assert_true(tile_size(1, 1, h) > tile_size(0, 1, h))
|
||||
assert_eq(tile_size(2, 0, h), base_size(h))
|
||||
fn win(id : Int, app : String, focused? : Bool = false) -> DockWindow {
|
||||
{ id: id.to_uint64(), app_id: app, focused }
|
||||
}
|
||||
|
||||
///|
|
||||
test "click launches the app under the pointer; move sets hover" {
|
||||
let a = apps()
|
||||
let (hv, redraw, launch) = handle(a, -1, 34, PointerMove({ x: 12, y: 10 }))
|
||||
assert_eq(hv, 0)
|
||||
assert_true(redraw)
|
||||
assert_true(launch is None)
|
||||
let (_, _, launch) = handle(a, hv, 34, PointerDown({ x: 12 + pitch(34), y: 10 }))
|
||||
assert_eq(launch, Some("b"))
|
||||
let (hv, redraw, _) = handle(a, 0, 34, PointerLeave)
|
||||
assert_eq(hv, -1)
|
||||
assert_true(redraw)
|
||||
}
|
||||
|
||||
///|
|
||||
test "render draws one tile and glyph per app, capped at max_tiles" {
|
||||
let t : @theme.Tokens = {
|
||||
fn tokens() -> @theme.Tokens {
|
||||
{
|
||||
name: "t",
|
||||
palette: {
|
||||
desktop_top: @ui.color(0, 0, 0, 255),
|
||||
@@ -49,11 +35,144 @@ test "render draws one tile and glyph per app, capped at max_tiles" {
|
||||
spacing: 6U,
|
||||
panel_height: 44U,
|
||||
}
|
||||
assert_eq(render(@ui.size(preferred_width(3), 34), t, apps(), -1).length(), 1 + 3 * 2)
|
||||
let many = Array::makei(20, i => ({ id: i.to_string(), name: "n", comment: "", category: "", glyph: "x" } : @types.AppEntry))
|
||||
assert_eq(render(@ui.size(300, 34), t, many, 2).length(), 1 + max_tiles * 2)
|
||||
assert_eq(tile_name(apps(), 1), "b!")
|
||||
assert_eq(tile_name(apps(), 9), "")
|
||||
}
|
||||
|
||||
///|
|
||||
test "without a choice the dock pins the catalog's first apps; the choice round-trips" {
|
||||
let c = DockConfig::new()
|
||||
assert_eq(c.pins(apps()), ["foot", "firefox", "org.gnome.Nautilus", "gimp", "org.kde.kate"])
|
||||
assert_eq(c.items()[3].value, "")
|
||||
assert_true(c.set("pinned", "vlc;foot"))
|
||||
assert_eq(c.pins(apps()), ["vlc", "foot"])
|
||||
assert_eq(c.items()[3], { key: "pinned", label: "", choices: [], value: "vlc;foot" })
|
||||
// Unpinning everything is a choice too, not "back to the defaults".
|
||||
assert_true(c.set("pinned", encode_pins([])))
|
||||
assert_eq(c.pins(apps()), [])
|
||||
assert_eq(decode_pins(""), None)
|
||||
assert_eq(decode_pins("a;;b;a"), Some(["a", "b"]))
|
||||
// The other settings.
|
||||
assert_false(c.set("icon-size", "Huge"))
|
||||
assert_true(c.set("icon-size", "Large"))
|
||||
assert_true(c.set("magnify", "off"))
|
||||
assert_false(c.set("magnify", "off"))
|
||||
let d = DockConfig::from_pairs([("icon-size", "Small"), ("running", "off")])
|
||||
assert_eq(d.size, "Small")
|
||||
assert_false(d.running)
|
||||
}
|
||||
|
||||
///|
|
||||
test "windows find their app by id, case, or the last dotted part" {
|
||||
let ids = ["foot", "org.gnome.Nautilus", "firefox"]
|
||||
assert_eq(match_app("foot", ids), Some("foot"))
|
||||
assert_eq(match_app("FOOT", ids), Some("foot"))
|
||||
assert_eq(match_app("nautilus", ids), Some("org.gnome.Nautilus"))
|
||||
assert_eq(match_app("org.mozilla.firefox", ids), Some("firefox"))
|
||||
assert_eq(match_app("gimp", ids), None)
|
||||
assert_eq(match_app("", ids), None)
|
||||
// By the app's name: xterm's windows belong to debian-xterm.desktop ("XTerm").
|
||||
let xterm : Array[@types.AppEntry] = [{ id: "debian-xterm", name: "XTerm", comment: "", category: "", glyph: "X" }]
|
||||
assert_eq(match_name("xterm", xterm), Some("debian-xterm"))
|
||||
assert_eq(match_name("vim", xterm), None)
|
||||
assert_eq(items(DockConfig::new(), xterm, [win(1, "xterm")]).map(i => i.windows.length()), [1])
|
||||
}
|
||||
|
||||
///|
|
||||
test "pinned apps come first in their order, then running ones, with their windows" {
|
||||
let c = DockConfig::from_pairs([("pinned", "firefox;foot")])
|
||||
let its = items(c, apps(), [
|
||||
win(7, "foot", focused=true),
|
||||
win(3, "foot"),
|
||||
win(5, "vlc"),
|
||||
win(9, "unknown.app"),
|
||||
win(2, ""),
|
||||
])
|
||||
assert_eq(its.map(i => i.id), ["firefox", "foot", "vlc", "unknown.app"])
|
||||
assert_eq(its.map(i => i.pinned), [true, true, false, false])
|
||||
assert_eq(its[1].windows, [3UL, 7UL]) // oldest first
|
||||
assert_true(its[1].focused)
|
||||
assert_false(its[0].focused)
|
||||
assert_eq(its[0].windows.length(), 0)
|
||||
// Not in the catalog: named after the id's last part, with a letter for its tile.
|
||||
assert_eq(its[3].name, "app")
|
||||
assert_eq(its[3].glyph, "A")
|
||||
// Running apps can be hidden.
|
||||
assert_true(c.set("running", "off"))
|
||||
assert_eq(items(c, apps(), [win(5, "vlc"), win(7, "foot")]).map(i => i.id), ["firefox", "foot"])
|
||||
}
|
||||
|
||||
///|
|
||||
test "items are hit-tested by slot, with a divider before the running apps" {
|
||||
let c = DockConfig::from_pairs([("pinned", "foot;firefox")])
|
||||
let its = items(c, apps(), [win(1, "vlc")])
|
||||
let h = 36
|
||||
let w = preferred_width(its, c, h)
|
||||
let p = icon_size(c, h) + 6
|
||||
assert_eq(item_at(its, c, w, h, 6, 10), 0)
|
||||
assert_eq(item_at(its, c, w, h, 6 + p, 10), 1)
|
||||
// The divider shifts the running app right.
|
||||
assert_eq(item_center(its, c, h, 2) - item_center(its, c, h, 1), p + 11)
|
||||
assert_eq(item_at(its, c, w, h, item_center(its, c, h, 2), 10), 2)
|
||||
assert_eq(item_at(its, c, w, h, w + 5, 10), -1)
|
||||
assert_eq(item_at(its, c, w, h, 6, -1), -1)
|
||||
// Too narrow for all of them: the ones that don't fit can't be hit.
|
||||
assert_eq(item_at(its, c, w - 10, h, item_center(its, c, h, 2), 10), -1)
|
||||
// Bigger icons, wider dock; magnification grows the hovered one most.
|
||||
let big = DockConfig::from_pairs([("pinned", "foot;firefox"), ("icon-size", "Large")])
|
||||
assert_true(preferred_width(items(big, apps(), []), big, 44) > preferred_width(items(c, apps(), []), c, 44))
|
||||
assert_true(item_size(c, 1, 1, h) > item_size(c, 0, 1, h))
|
||||
assert_true(item_size(c, 0, 1, h) > item_size(c, 3, 1, h))
|
||||
assert_true(c.set("magnify", "off"))
|
||||
assert_eq(item_size(c, 1, 1, h), icon_size(c, h))
|
||||
}
|
||||
|
||||
///|
|
||||
test "a click starts an app that isn't running and walks through a running app's windows" {
|
||||
let c = DockConfig::from_pairs([("pinned", "foot;firefox")])
|
||||
let its = items(c, apps(), [win(3, "foot"), win(8, "foot")])
|
||||
let h = 36
|
||||
let w = preferred_width(its, c, h)
|
||||
let x0 = item_center(its, c, h, 0)
|
||||
let x1 = item_center(its, c, h, 1)
|
||||
let (hv, redraw, act) = handle(its, c, -1, w, h, None, PointerMove({ x: x1, y: 10 }))
|
||||
assert_eq((hv, redraw, act), (1, true, Nothing))
|
||||
assert_eq(handle(its, c, 1, w, h, None, PointerMove({ x: x1, y: 10 })).1, false)
|
||||
assert_eq(handle(its, c, 1, w, h, None, PointerDown({ x: x1, y: 10 })).2, Launch("firefox"))
|
||||
// Not focused: its newest window comes forward.
|
||||
assert_eq(handle(its, c, 0, w, h, Some(99UL), PointerDown({ x: x0, y: 10 })).2, Focus(8UL))
|
||||
// Focused: the next of its windows, round and round.
|
||||
let its = items(c, apps(), [win(3, "foot"), win(8, "foot", focused=true)])
|
||||
assert_eq(handle(its, c, 0, w, h, Some(8UL), PointerDown({ x: x0, y: 10 })).2, Focus(3UL))
|
||||
let its = items(c, apps(), [win(3, "foot", focused=true)])
|
||||
assert_eq(handle(its, c, 0, w, h, Some(3UL), PointerDown({ x: x0, y: 10 })).2, Nothing)
|
||||
let (hv, redraw, _) = handle(its, c, 0, w, h, None, PointerLeave)
|
||||
assert_eq((hv, redraw), (-1, true))
|
||||
}
|
||||
|
||||
///|
|
||||
test "render draws each icon (theme image or letter tile), a dot per window and the divider" {
|
||||
let c = DockConfig::from_pairs([("pinned", "foot;firefox")])
|
||||
let its = items(c, apps(), [win(3, "foot", focused=true), win(4, "vlc"), win(5, "vlc")])
|
||||
let h = 36
|
||||
let w = preferred_width(its, c, h)
|
||||
let ops = render(@ui.size(w, h), tokens(), c, its, -1, id => if id == "firefox" { 42U } else { 0U })
|
||||
let images = ops.filter(op => op is Image(_))
|
||||
assert_eq(images.length(), 1)
|
||||
let texts = ops.filter(op => op is Text(_))
|
||||
assert_eq(texts.length(), 2) // foot's and vlc's letter tiles
|
||||
// background + divider + foot (tile, glyph, 1 dot) + firefox (image) + vlc (tile, glyph, 2 dots)
|
||||
assert_eq(ops.length(), 1 + 1 + 3 + 1 + 4)
|
||||
// Nothing to show.
|
||||
let none = DockConfig::from_pairs([("pinned", ";")])
|
||||
assert_eq(render(@ui.size(80, h), tokens(), none, [], -1, _ => 0U).length(), 2)
|
||||
}
|
||||
|
||||
///|
|
||||
test "pins are toggled and moved within bounds" {
|
||||
assert_eq(toggle_pin(["a", "b"], "b"), ["a"])
|
||||
assert_eq(toggle_pin(["a"], "c"), ["a", "c"])
|
||||
assert_eq(move_pin(["a", "b", "c"], "b", -1), ["b", "a", "c"])
|
||||
assert_eq(move_pin(["a", "b", "c"], "c", 1), ["a", "b", "c"])
|
||||
assert_eq(move_pin(["a", "b", "c"], "x", 1), ["a", "b", "c"])
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "chandra/desktop/lib/dock"
|
||||
|
||||
import {
|
||||
"chandra/desktop/interface/chandra/desktop/theme",
|
||||
"chandra/desktop/interface/chandra/desktop/types",
|
||||
"moonbitlang/core/debug",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn app_glyph(String, String) -> String
|
||||
|
||||
pub fn app_icon(Int32, Int32, Int32, String, String, hover? : Bool) -> Array[@types.DrawOp]
|
||||
|
||||
pub fn click_target(DockItem, UInt64?) -> UInt64?
|
||||
|
||||
pub let config : DockConfig
|
||||
|
||||
pub fn decode_pins(String) -> Array[String]?
|
||||
|
||||
pub let default_pin_count : Int32
|
||||
|
||||
pub fn encode_pins(Array[String]) -> String
|
||||
|
||||
pub fn handle(Array[DockItem], DockConfig, Int32, Int32, Int32, UInt64?, @types.InputEvent) -> (Int32, Bool, DockAction)
|
||||
|
||||
pub fn icon_size(DockConfig, Int32) -> Int32
|
||||
|
||||
pub fn item_at(Array[DockItem], DockConfig, Int32, Int32, Int32, Int32) -> Int32
|
||||
|
||||
pub fn item_center(Array[DockItem], DockConfig, Int32, Int32) -> Int32
|
||||
|
||||
pub fn item_size(DockConfig, Int32, Int32, Int32) -> Int32
|
||||
|
||||
pub fn items(DockConfig, Array[@types.AppEntry], Array[DockWindow]) -> Array[DockItem]
|
||||
|
||||
pub fn match_app(String, Array[String]) -> String?
|
||||
|
||||
pub fn move_pin(Array[String], String, Int32) -> Array[String]
|
||||
|
||||
pub fn preferred_width(Array[DockItem], DockConfig, Int32) -> Int32
|
||||
|
||||
pub fn render(@types.Size, @theme.Tokens, DockConfig, Array[DockItem], Int32, (String) -> UInt32) -> Array[@types.DrawOp]
|
||||
|
||||
pub let size_choices : Array[String]
|
||||
|
||||
pub fn tile_color(String) -> @types.Color
|
||||
|
||||
pub fn toggle_pin(Array[String], String) -> Array[String]
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) struct ConfigEntry {
|
||||
key : String
|
||||
label : String
|
||||
choices : Array[String]
|
||||
value : String
|
||||
}
|
||||
|
||||
#derive(Eq, @debug.Debug)
|
||||
pub(all) enum DockAction {
|
||||
Nothing
|
||||
Launch(String)
|
||||
Focus(UInt64)
|
||||
}
|
||||
|
||||
pub(all) struct DockConfig {
|
||||
mut pinned : Array[String]?
|
||||
mut size : String
|
||||
mut magnify : Bool
|
||||
mut running : Bool
|
||||
}
|
||||
pub fn DockConfig::from_pairs(Array[(String, String)]) -> Self
|
||||
pub fn DockConfig::items(Self) -> Array[ConfigEntry]
|
||||
pub fn DockConfig::new() -> Self
|
||||
pub fn DockConfig::pins(Self, Array[@types.AppEntry]) -> Array[String]
|
||||
pub fn DockConfig::set(Self, String, String) -> Bool
|
||||
|
||||
#derive(@debug.Debug)
|
||||
pub(all) struct DockItem {
|
||||
id : String
|
||||
name : String
|
||||
glyph : String
|
||||
pinned : Bool
|
||||
windows : Array[UInt64]
|
||||
focused : Bool
|
||||
}
|
||||
|
||||
pub(all) struct DockWindow {
|
||||
id : UInt64
|
||||
app_id : String
|
||||
focused : Bool
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -2,7 +2,7 @@
|
||||
clock-digital clock-widget
|
||||
clock-binary clock-widget
|
||||
launcher launcher-widget
|
||||
dock launcher-widget
|
||||
dock dock-widget
|
||||
shell shell
|
||||
tasks taskbar-widget
|
||||
layout layout-widget
|
||||
|
||||
+14
-1
@@ -18,7 +18,7 @@ world configurable {
|
||||
export module-config;
|
||||
}
|
||||
|
||||
/// The application launcher (and the dock, which uses only the first two). The launcher's popup
|
||||
/// The application launcher. The launcher's popup
|
||||
/// also ends in a session row: Reload, Log out, Suspend, Restart, Power off.
|
||||
world launcher-widget {
|
||||
include widget;
|
||||
@@ -28,6 +28,19 @@ world launcher-widget {
|
||||
import power;
|
||||
}
|
||||
|
||||
/// The dock: pinned apps plus running ones, with their theme icons, a dot per open window, a click
|
||||
/// that starts the app or brings its windows forward, and right-click settings (icon size,
|
||||
/// magnification, running apps). The shell keeps the pinned list (hidden `pinned` setting) and
|
||||
/// draws the per-app right-click menu (Pin, Move, Quit), sharing lib/dock's layout.
|
||||
world dock-widget {
|
||||
include widget;
|
||||
import app-catalog;
|
||||
import app-launch;
|
||||
import windows;
|
||||
import icons;
|
||||
export module-config;
|
||||
}
|
||||
|
||||
world panel {
|
||||
import theme;
|
||||
export panel-layout;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
The dock: pinned apps plus running ones, with their theme icons, a dot per open window, a click
|
||||
that starts the app or brings its windows forward, and right-click settings (icon size,
|
||||
magnification, running apps). The shell keeps the pinned list (hidden `pinned` setting) and
|
||||
draws the per-app right-click menu (Pin, Move, Quit), sharing lib/dock's layout.
|
||||
@@ -0,0 +1,2 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,12 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "chandra/desktop/world/dock-widget"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
Reference in new issue
Block a user