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
}