Dock and task manager are one module: titled window pills, pins, Super+1..9
CI / test (push) Failing after 30s

The panel had a task list and, beside it, a dock showing the same running
apps again. They are now one module, the dock, in the task list's place:

- Pinned apps, then running ones; an app with windows is a pill with its
  window's title (or name and window count) while there is room, an icon
  when the panel is crowded ("Show window titles" in Dock settings).
- Its right-click menu has the task list's window commands (Minimize /
  Restore, Maximize) for a single window, or the app's windows by title.
- It stretches like the task list did; new panels get it instead of
  tasks. A saved panel's "tasks" becomes the dock (one dock, where the
  task list was); pins are the dock's own setting, so they carry over.
- An empty dock shows a "+ Add apps" tile that opens the Applications
  menu, where right-clicking an app offers Open and Pin to dock (adding a
  dock to the panel if there is none).
- Super+1 .. Super+9 open the dock's first nine apps like a click
  (shortcut "dock-apps", rebindable in Settings > Shortcuts).
- "New window" / "Open" only for apps the catalog can start.

The tasks component, lib/panel's pill geometry and the taskbar-widget
world are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiPCFHRxaJQvwex6ry
This commit is contained in:
Claude committed 2026-11-26 00:08:05 +00:00
1 parent 42aa770452
commit 6253371cb3
28 files changed
+801 -1131

No files matched your search

+210 -6
View File
@@ -26,7 +26,23 @@ fn dock_config(w : Widget) -> @dock.DockConfig {
///| 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 })
self.win_list.map(e => {
id: e.id,
app_id: e.app_id,
focused: e.focused,
title: e.title,
minimized: self.win_info(e.id).map(i => i.minimized).unwrap_or(false),
})
}
///| The window list entry (minimized, maximized) of window `id`.
fn DesktopShell::win_info(self : DesktopShell, id : UInt64) -> WinInfo? {
for w in self.windows {
if w.id == id {
return Some(w)
}
}
None
}
///| The dock in `w`'s settings and icons, as the module computes them.
@@ -163,7 +179,9 @@ fn DesktopShell::open_dock_menu(
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 self.command_for(it.id) is Some(_) {
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()
@@ -176,6 +194,30 @@ fn DesktopShell::open_dock_menu(
} else {
rows.push(dock_row("Pin to dock", 8, it.id))
}
if n == 1 {
// The window's own commands, as the task list had them.
match self.win_info(it.windows[0]) {
Some(win) => {
rows.push(
if win.minimized {
window_row("Restore", win.id, Restore)
} else {
window_row("Minimize", win.id, Minimize)
},
)
rows.push(window_row(if win.maximized { "Restore size" } else { "Maximize" }, win.id, ToggleMaximize))
}
None => ()
}
} else if n > 1 {
// Its windows by title, so one can be picked straight away (a click cycles through them).
rows.push(menu_row("Windows", 5))
for win in it.windows {
let min = self.win_info(win).map(i => i.minimized).unwrap_or(false)
let label = self.window_title(win) + (if min { " (minimized)" } else { "" })
rows.push({ ..menu_row(label, 6), window_id: win, window_cmd: Restore })
}
}
if n == 1 {
rows.push(dock_row("Quit", 10, it.id))
} else if n > 1 {
@@ -185,15 +227,25 @@ fn DesktopShell::open_dock_menu(
self.open_menu(it.name, rows, w.slot, x)
}
///| A dock menu row was chosen for the dock in `slot`.
///| A dock menu row was chosen for the dock in `slot`. "Pin to dock" from the Applications menu
/// when there is no dock yet (`slot` "") puts one in the panel first.
fn DesktopShell::dock_menu_choice(self : DesktopShell, slot : String, row : MenuRow) -> Unit {
match self.widget_by_slot(slot) {
let dock = match self.widget_by_slot(slot) {
Some(w) => Some(w)
None if row.kind == 8 => self.add_dock()
None => None
}
if row.kind == 7 {
self.launch_catalog_app(row.arg)
return
}
match dock {
None => ()
Some(w) => {
let slot = w.slot
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 }
@@ -220,7 +272,10 @@ fn DesktopShell::dock_label(self : DesktopShell) -> (String, Int)? {
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)))
if @dock.titled_at(items, cfg, w.rect.w, w.rect.h, i) {
return None
}
Some((items[i].name, w.rect.x + @dock.item_center(items, cfg, w.rect.w, w.rect.h, i)))
}
None => None
}
@@ -263,3 +318,152 @@ fn DesktopShell::render_dock_label(self : DesktopShell, tokens : @theme.Tokens,
None => ()
}
}
// ---------------------------------------------------------------- pinning from elsewhere
///| The first dock in the panel, if any.
fn DesktopShell::dock_widget(self : DesktopShell) -> Widget? {
for w in self.widgets {
if w.is_dock() {
return Some(w)
}
}
None
}
///| A window's title ("Window" when it has none).
fn DesktopShell::window_title(self : DesktopShell, id : UInt64) -> String {
for e in self.win_list {
if e.id == id && e.title.length() > 0 {
return e.title
}
}
"Window"
}
///| Put a dock into the panel, just after the Applications button (or first), with its
/// first pins settled. None when the dock module can't be found or loaded.
fn DesktopShell::add_dock(self : DesktopShell) -> Widget? {
self.name_catalog()
match self.find_module("dock") {
None => {
self.say("Dock module not found (build it with scripts/build-modules.sh)")
None
}
Some(c) =>
match self.load_path(c.path) {
None => None
Some(w) => {
let mut at = 0
for i = 0; i < self.widgets.length(); i = i + 1 {
if self.widgets[i].module_id == launcher_module {
at = i + 1
}
}
self.widgets.retain(x => x.slot != w.slot)
self.widgets.insert(at, w)
self.settle_dock_pins()
self.save_panel_config()
Some(w)
}
}
}
}
///| "Pin to dock" or "Unpin from dock" for app `id` (a catalog or window app id) as a row of
/// another menu, and the dock's slot that row acts on ("" when there is no dock yet: pinning
/// then adds one).
fn DesktopShell::pin_row(self : DesktopShell, id : String) -> (MenuRow, String) {
match self.dock_widget() {
Some(w) => {
let pinned = dock_config(w).pins(self.apps).contains(id)
(dock_row(if pinned { "Unpin from dock" } else { "Pin to dock" }, 8, id), w.slot)
}
None => (dock_row("Pin to dock", 8, id), "")
}
}
///| The right-click menu of an app in the Applications menu: Open, and Pin to dock / Unpin.
fn DesktopShell::open_app_menu(self : DesktopShell, app : @types.AppEntry, x : Int) -> Unit {
let (pin, slot) = self.pin_row(app.id)
self.open_menu(app.name, [dock_row("Open", 7, app.id), pin], slot, x)
}
///| The app under (x, y) in the Applications menu's popup, if it is open there.
fn DesktopShell::launcher_app_at(self : DesktopShell, x : Int, y : Int) -> @types.AppEntry? {
match self.popup_at(x, y) {
Some(w) if w.module_id == launcher_module => {
let shown = @launcher.filter(self.apps, self.launcher_state.query)
let i = @launcher.row_at(self.apps, self.launcher_state, { x: x - w.popup_rect.x, y: y - w.popup_rect.y })
if i >= 0 && i < shown.length() {
Some(shown[i])
} else {
None
}
}
_ => None
}
}
///| Follow an event the launcher module was handed, so the shell knows what its popup lists
/// (its search text) for the right-click menu. The module's own state stays the truth for
/// whether it is open.
fn DesktopShell::follow_launcher(self : DesktopShell, w : Widget, popup : Bool, ev : @wasm.PlasmoidEvent) -> Unit {
let st = self.launcher_state
let e : @types.InputEvent = match ev {
PointerMove(x, y) => PointerMove({ x, y })
PointerDown(x, y) => PointerDown({ x, y })
PointerUp(x, y) => PointerUp({ x, y })
PointerLeave => PointerLeave
FocusLost => FocusLost
KeyDown(k) => KeyDown(k)
}
ignore(@launcher.handle_event(self.apps, st, if popup { Popup } else { Widget }, e, _ => Ok(())))
if w.popup_rect.w == 0 {
@launcher.close(st)
} else if !st.open {
// Open in the module (its launch failed and kept it open): open here too.
ignore(@launcher.handle_event(self.apps, st, Widget, PointerDown({ x: 0, y: 0 }), _ => Ok(())))
}
}
///| Super+`n` (1-based): what a click on the dock's `n`-th icon does, start the app or bring its
/// windows forward. False when there is no dock or no such icon.
pub fn DesktopShell::open_dock_item(self : DesktopShell, n : Int) -> Bool {
self.ensure_booted()
match self.dock_widget() {
None => false
Some(w) => {
let (_, items) = self.dock_state(w)
if n < 1 || n > items.length() {
return false
}
let mut focused : UInt64? = None
for e in self.win_list {
if e.focused {
focused = Some(e.id)
}
}
match @dock.activate(items[n - 1], focused) {
Launch(id) => self.launch_catalog_app(id)
Focus(win) => self.actions.push(FocusWindow(win))
Nothing => ()
}
true
}
}
}
///| A left click on the dock in `w` at (x, y): the empty dock's "+" opens the Applications menu,
/// where right-clicking an app pins it. True when the shell took the click.
fn DesktopShell::dock_click(self : DesktopShell, w : Widget) -> Bool {
if !w.is_dock() {
return false
}
let (_, items) = self.dock_state(w)
if items.length() > 0 {
return false
}
self.toggle_launcher()
true
}
+8
View File
@@ -351,6 +351,9 @@ pub(all) struct DesktopShell {
wit_cache : Map[String, String]
/// Most-recently-launched app ids, newest first (persisted).
recents : Array[String]
/// The launcher module's state as the shell follows it (dock.mbt `follow_launcher`): what its
/// popup lists, for the right-click "Pin to dock" menu.
launcher_state : @launcher.State
}
///|
@@ -459,6 +462,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
comps: [],
wit_cache: {},
recents: [],
launcher_state: @launcher.State::new(),
}
sh.order_apps()
sh
@@ -634,6 +638,9 @@ fn DesktopShell::deliver(self : DesktopShell, w : Widget, popup : Bool, ev : @wa
// The module may have unloaded itself (or been replaced) while handling the event.
if self.widget_by_slot(w.slot) is Some(_) {
self.refresh_popup(w)
if w.module_id == launcher_module {
self.follow_launcher(w, popup, ev)
}
}
changed
}
@@ -780,6 +787,7 @@ pub fn DesktopShell::pointer_up(self : DesktopShell) -> Bool {
self.save_panel_config()
} else {
match self.widget_by_slot(slot) {
Some(w) if self.dock_click(w) => ()
Some(w) => ignore(self.deliver(w, false, PointerDown(self.drag_x0 - w.rect.x, self.drag_y0 - w.rect.y)))
None => ()
}
+44
View File
@@ -50,6 +50,10 @@ pub(all) enum ShortcutAction {
RecordRegion
RecordScreen
RecordWindow
/// The dock's apps by number: the combo opens the first, the same modifiers with 2 .. 9 the
/// second to ninth (when the combo's key is 1). Like clicking the icon: start the app or bring
/// its windows forward. See `Shortcuts::dock_app`.
DockApps
} derive(Eq, Debug)
///| One row of the shortcut table.
@@ -77,6 +81,7 @@ pub let shortcut_table : Array[ShortcutDef] = [
{ id: "record-region", label: "Record a region", action: RecordRegion, default_text: "Super+Shift+R" },
{ id: "record-screen", label: "Record the screen", action: RecordScreen, default_text: "Super+Alt+R" },
{ id: "record-window", label: "Record a window", action: RecordWindow, default_text: "Super+Ctrl+R" },
{ id: "dock-apps", label: "Open dock app 1-9", action: DockApps, default_text: "Super+1" },
]
///| evdev code -> key name, for the keys a combo can end in (US layout names).
@@ -487,3 +492,42 @@ pub fn DesktopShell::publish_shortcuts(self : DesktopShell) -> Unit {
}
@wasm.publish(Shortcuts, t)
}
///| evdev codes of the 1 and 9 keys (the row above the letters).
let key_1 : UInt = 2
///|
let key_9 : UInt = 10
///| Which of the dock's apps (1-9) `combo` opens: the "Open dock app" combo itself is the first,
/// and when that combo ends in 1, the same modifiers with 2 .. 9 open the second to ninth.
pub fn Shortcuts::dock_app(self : Shortcuts, combo : KeyCombo) -> Int? {
let mods = combo.mods & combo_mods
for i = 0; i < self.bindings.length(); i = i + 1 {
if shortcut_table[i].action == DockApps {
match self.bindings[i] {
Some(c) if c.mods == mods => {
if c.key == key_1 && combo.key >= key_1 && combo.key <= key_9 {
return Some((combo.key - key_1).reinterpret_as_int() + 1)
}
if same_key(c.key, combo.key) {
return Some(1)
}
}
_ => ()
}
}
}
None
}
///|
test "Super+1 .. Super+9 open the dock's apps" {
let sc = Shortcuts::defaults()
assert_eq(sc.dock_app({ mods: mod_logo, key: 2 }), Some(1))
assert_eq(sc.dock_app({ mods: mod_logo, key: 6 }), Some(5))
assert_eq(sc.dock_app({ mods: mod_logo, key: 10 }), Some(9))
assert_eq(sc.dock_app({ mods: mod_logo, key: 11 }), None) // 0
assert_eq(sc.dock_app({ mods: mod_logo | mod_shift, key: 3 }), None)
assert_eq(sc.dock_app({ mods: 0, key: 3 }), None)
}
+40 -51
View File
@@ -11,9 +11,10 @@
/// and opens that tab. A module may also export `module-config`: its own settings, listed under
/// "Module settings..." in its right-click menu and remembered in state.edn (module_config.mbt).
///| Modules loaded into a fresh panel, in order. `tasks` stretches, so what follows it packs right.
///| Modules loaded into a fresh panel, in order. The dock (pinned and running apps, the task
/// manager) stretches, so what follows it packs right.
let default_panel : Array[String] = [
"launcher", "inspector", "layout", "tasks", "moon-disc", "network", "clock-digital", "screenshot",
"launcher", "inspector", "layout", "dock", "moon-disc", "network", "clock-digital", "screenshot",
"session-settings",
]
@@ -47,9 +48,13 @@ test "a fresh panel gets the battery module only on a machine with a battery" {
/// - logout, the Log out button, is the Application Launcher's session row (Reload, Log out,
/// Suspend, Restart, Power off). A saved panel drops it, or gets the launcher in its place when
/// it had none (migrate_panel).
/// - tasks, the Task Manager's window pills, is the dock: pinned and running apps, titled pills
/// when there is room, each window's menu. A saved panel with both keeps one dock, where the
/// task list was (migrate_panel); the dock's pins carry over (they are the dock's own setting).
let retired_modules : Map[String, String] = {
"clock-digital12": "clock-digital",
"logout": "launcher",
"tasks": "dock",
}
///| The id a module goes by now ("clock-digital12" -> "clock-digital").
@@ -105,7 +110,7 @@ fn stem(path : String) -> String {
}
}
///| The WIT world ("clock-widget", "taskbar-widget", ...) a module was built for, read from the
///| The WIT world ("clock-widget", "dock-widget", ...) a module was built for, read from the
/// `<name>.meta.json` that build-modules.sh writes next to it; "" when unknown (a module loaded
/// from elsewhere). Two modules are interchangeable only when their worlds match.
fn module_world(path : String) -> String {
@@ -222,12 +227,21 @@ fn wall_secs() -> Int {
/// module list "wallpaper" or "module-manager": the settings module takes the first one's place
/// (a panel that already has it just drops them). The Log out button moved into the launcher the
/// same way: "logout" becomes the launcher when the panel has none, else it is dropped. Other
/// retired modules (clock-digital12) become the module that replaced them.
/// retired modules (clock-digital12) become the module that replaced them; the task list and the
/// dock become one dock, in the task list's place.
fn migrate_panel(entries : Array[String]) -> Array[String] {
let has_settings = entries.contains("session-settings")
let has_launcher = entries.contains("launcher")
// One dock, where the task list was when there was one (it sat in the stretching place).
let dock_at = match entries.search("tasks") {
Some(i) => i
None => entries.search("dock").unwrap_or(-1)
}
let out : Array[String] = []
for e in entries {
for i, e in entries {
if (e == "tasks" || e == "dock") && i != dock_at {
continue
}
if e == "wallpaper" || e == "module-manager" {
if !has_settings && !out.contains("session-settings") {
out.push("session-settings")
@@ -251,9 +265,17 @@ test "a saved panel's wallpaper button becomes the settings module" {
assert_eq(migrate_panel(["clock"]), ["clock"])
}
///|
test "a saved panel's task list and dock become one dock, in the task list's place" {
assert_eq(migrate_panel(["launcher", "tasks", "clock-digital", "dock"]), ["launcher", "dock", "clock-digital"])
assert_eq(migrate_panel(["dock", "launcher", "tasks"]), ["launcher", "dock"])
assert_eq(migrate_panel(["launcher", "dock", "clock-digital"]), ["launcher", "dock", "clock-digital"])
assert_eq(current_module_id("tasks"), "dock")
}
///|
test "a saved panel's 12-hour clock becomes the digital clock" {
assert_eq(migrate_panel(["tasks", "clock-digital12", "logout"]), ["tasks", "clock-digital", "launcher"])
assert_eq(migrate_panel(["tasks", "clock-digital12", "logout"]), ["dock", "clock-digital", "launcher"])
assert_eq(current_module_id("clock-digital12"), "clock-digital")
assert_eq(current_module_id("clock-binary"), "clock-binary")
}
@@ -262,10 +284,10 @@ test "a saved panel's 12-hour clock becomes the digital clock" {
test "a saved panel's Log out button folds into the launcher" {
// The launcher's session row has Log out now: the old button is dropped...
assert_eq(migrate_panel(["launcher", "tasks", "session-settings", "logout"]), [
"launcher", "tasks", "session-settings",
"launcher", "dock", "session-settings",
])
// ...or becomes the launcher on a panel without one, so Log out stays reachable.
assert_eq(migrate_panel(["tasks", "logout"]), ["tasks", "launcher"])
assert_eq(migrate_panel(["tasks", "logout"]), ["dock", "launcher"])
assert_eq(migrate_panel(["logout", "launcher"]), ["launcher"])
assert_false(default_panel.contains("logout"))
}
@@ -945,8 +967,8 @@ let menu_w : Int = 250
///| Most "Replace with" rows listed.
let max_replace_rows : Int = 8
///| Right-click: on a window's pill in the task manager that window's menu (Minimize or Restore,
/// Maximize, Quit); on a module its menu (Module settings, System settings, replace, remove); on
///| Right-click: on an app in the open Applications menu its Open / Pin to dock menu; on an app in
/// the dock its menu (dock.mbt); on a module its menu (Module settings, System settings, replace, remove); on
/// empty panel space System settings (whose Panel tab adds modules). True when consumed.
pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool {
self.ensure_booted()
@@ -955,12 +977,16 @@ pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool
}
let was_open = self.menu_open
self.menu_open = false
// An app in the open Applications menu: Open, Pin to dock. The menu stays open behind it.
match self.launcher_app_at(x, y) {
Some(app) => {
self.open_app_menu(app, x)
return true
}
None => ()
}
self.dismiss_popups("")
match self.widget_at(x, y) {
Some(w) if self.task_at(w, x, y) is Some(win) => {
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
@@ -1002,43 +1028,6 @@ pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool
}
}
///| The task manager module's id: its pills are hit-tested here (lib/panel/tasks.mbt) so a
/// right-click on one opens that window's menu.
let tasks_module_id : String = "org.chandra.tasks"
///| The window whose task-bar pill is under (x, y) when `w` is the task manager. The pills are
/// the windows in opening order (by id, as the module sorts them).
fn DesktopShell::task_at(self : DesktopShell, w : Widget, x : Int, y : Int) -> WinInfo? {
if w.pl.id != tasks_module_id || !inside(w.rect, x, y) {
return None
}
// The module sorts by the 32-bit id it is handed through `windows.list-windows`.
let key = (win : WinInfo) => win.id.to_int().reinterpret_as_uint()
let wins = self.windows.copy()
wins.sort_by((a, b) => key(a).compare(key(b)))
let i = @panel.task_pill_at(x - w.rect.x, wins.length(), w.rect.w)
if i >= 0 {
Some(wins[i])
} else {
None
}
}
///| The window menu of a task-bar pill, titled with the window's title.
fn DesktopShell::open_window_menu(self : DesktopShell, win : WinInfo, x : Int) -> Unit {
let rows = [
if win.minimized {
window_row("Restore", win.id, Restore)
} else {
window_row("Minimize", win.id, Minimize)
},
window_row(if win.maximized { "Restore size" } else { "Maximize" }, win.id, ToggleMaximize),
window_row("Quit", win.id, Close),
]
let title = if win.title.length() > 0 { win.title } else { "Window" }
self.open_menu(title, rows, "", x)
}
///| The module's own settings as menu rows: an on/off setting is one row, ticked when on; a
/// setting with choices is a heading and one row per choice, the current one ticked.
fn config_rows(items : Array[@wasm.ConfigItem]) -> Array[MenuRow] {