Dock: plain icons always come before the task pills
CI / test (push) Failing after 2m33s

With window titles on, a pinned app that was running drew as a pill in its
pin slot, so idle pinned icons ended up between pills. Now the dock shows
the pinned apps that aren't running first, then every task: running pinned
apps in pin order, then the other running apps. The divider sits between
the two groups. Squeezing the pills to icons keeps the order; with titles
off the plain pinned order stays. Move left / right in the menu follow the
pin list, not the shown position.

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 01:53:43 +00:00
1 parent 5403777451
commit 01bd8281d5
5 files changed
+72 -26

No files matched your search

+14 -7
View File
@@ -271,7 +271,8 @@ pub fn owner_of(
}
///| 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.
/// they first opened a window (when `cfg.running`). With window titles on, the pinned apps that
/// aren't running come first, so plain icons never sit after a task pill. Windows without an app id aren't shown.
pub fn items(
cfg : DockConfig,
apps : Array[@types.AppEntry],
@@ -329,13 +330,19 @@ pub fn items(
}
}
}
out
if !cfg.titles {
return out
}
// With window titles the running apps are task pills: the plain icons (pinned apps that
// aren't running) come first, then every task, pinned ones in pin order, then the others.
out.filter(it => it.windows.length() == 0) + out.filter(it => it.windows.length() > 0)
}
///| Index of the first unpinned item (items.length() when all are pinned).
fn first_running(items : Array[DockItem]) -> Int {
/// With window titles on the divider sits between the plain icons and the tasks instead.
fn first_running(items : Array[DockItem], cfg : DockConfig) -> Int {
let mut i = 0
while i < items.length() && items[i].pinned {
while i < items.length() && items[i].pinned && !(cfg.titles && items[i].windows.length() > 0) {
i = i + 1
}
i
@@ -386,7 +393,7 @@ fn widths(items : Array[DockItem], cfg : DockConfig, w : Int, h : Int) -> Array[
let base = icon_size(cfg, h)
let titled = items.map(it => cfg.titles && it.windows.length() > 0)
let n = items.length()
let split = first_running(items)
let split = first_running(items, cfg)
let fixed = 2 * pad + (if n > 1 { (n - 1) * gap } else { 0 }) +
(if split > 0 && split < n { divider_w } else { 0 })
let mut nt = 0
@@ -419,7 +426,7 @@ pub fn titled_at(items : Array[DockItem], cfg : DockConfig, w : Int, h : Int, i
///| Left edge of item `i`'s slot.
fn slot_x(items : Array[DockItem], cfg : DockConfig, w : Int, h : Int, i : Int) -> Int {
let ws = widths(items, cfg, w, h)
let split = first_running(items)
let split = first_running(items, cfg)
let mut x = pad
for j = 0; j < i; j = j + 1 {
x = x + ws[j] + gap
@@ -616,7 +623,7 @@ pub fn render(
let base = icon_size(cfg, h)
let cy = (h - dots_h) / 2 + 2
let fs = t.font_size.reinterpret_as_int() - 3
let split = first_running(items)
let split = first_running(items, cfg)
if split > 0 && split < n {
let x = slot_x(items, cfg, w, h, split) - gap / 2 - divider_w / 2 - 1
ops.push(@ui.fill_rect(@ui.rect(x, 6, 1, h - 12), t.palette.border))
+33 -8
View File
@@ -190,9 +190,11 @@ test "a window's app: a pin, a catalog app, or its own id" {
test "activate starts an app without windows and brings one forward otherwise" {
let c = DockConfig::from_pairs([("pinned", "foot;firefox")])
let its = items(c, apps(), [win(3, "foot", focused=true), win(4, "foot")])
assert_eq(activate(its[1], Some(3UL)), Launch("firefox"))
assert_eq(activate(its[0], None), Focus(4UL))
assert_eq(activate(its[0], Some(3UL)), Focus(4UL))
// Firefox isn't running, so it comes first (before foot's task pill).
assert_eq(its.map(i => i.id), ["firefox", "foot"])
assert_eq(activate(its[0], Some(3UL)), Launch("firefox"))
assert_eq(activate(its[1], None), Focus(4UL))
assert_eq(activate(its[1], Some(3UL)), Focus(4UL))
}
///|
@@ -232,22 +234,45 @@ test "apps with windows are titled pills that shrink, then drop their titles, as
let its = items(c, apps(), [win(3, "foot"), win(4, "vlc", minimized=true), win(5, "vlc")])
let h = 36
let base = icon_size(c, h)
// Room for all: foot and vlc get full pills, firefox (no windows) stays an icon.
assert_eq(widths(its, c, 1000, h), [label_max, base, label_max])
assert_eq(item_title(its[0]), "foot window")
// Room for all: firefox (no windows) is an icon, first; foot and vlc get full pills.
assert_eq(its.map(i => i.id), ["firefox", "foot", "vlc"])
assert_eq(widths(its, c, 1000, h), [base, label_max, label_max])
assert_eq(item_title(its[1]), "foot window")
assert_eq(item_title(its[2]), "vlc! (2)")
assert_eq(its[2].minimized, 1)
// Less room: the pills share what's left...
let ws = widths(its, c, 300, h)
assert_true(ws[0] < label_max && ws[0] >= label_min && ws[0] == ws[2])
assert_true(ws[1] < label_max && ws[1] >= label_min && ws[1] == ws[2])
assert_true(slot_x(its, c, 300, h, 2) + ws[2] + 6 <= 300)
// ...and below label_min they are icons again.
assert_eq(widths(its, c, 150, h), [base, base, base])
// A click anywhere on a pill is that app.
assert_eq(item_at(its, c, 1000, h, 6 + label_max - 10, 10), 0)
let x1 = slot_x(its, c, 1000, h, 1)
assert_eq(item_at(its, c, 1000, h, x1 + label_max - 10, 10), 1)
let ops = render(@ui.size(1000, h), tokens(), c, its, -1, _ => 0U)
assert_true(ops.iter().any(op => op is Text(t) && t.text == "foot window"))
// Off: icons only.
assert_true(c.set("titles", "off"))
assert_eq(widths(its, c, 1000, h), [base, base, base])
}
///|
test "with titles, plain icons always come before the tasks" {
let c = DockConfig::from_pairs([("pinned", "firefox;nautilus-x;foot;gimp")])
let a = apps() + [{ id: "nautilus-x", name: "Files", comment: "", category: "", glyph: "F" }]
let wins = [win(1, "firefox"), win(2, "foot"), win(3, "vlc"), win(4, "org.kde.kate")]
let its = items(c, a, wins)
// Not running: Files, GIMP; then the tasks: pinned Firefox, foot, then vlc and Kate.
assert_eq(its.map(i => i.id), ["nautilus-x", "gimp", "firefox", "foot", "vlc", "org.kde.kate"])
// The divider goes between the icons and the tasks.
assert_eq(first_running(its, c), 2)
let h = 36
assert_eq(slot_x(its, c, 2000, h, 2) - slot_x(its, c, 2000, h, 1), icon_size(c, h) + 6 + 11)
// Squeezed to icons, the order stays (so a click lands where it did).
assert_eq(widths(its, c, 200, h).map(x => x == icon_size(c, h)), [true, true, true, true, true, true])
// Titles off: the pinned order, running apps after the divider.
assert_true(c.set("titles", "off"))
let its = items(c, a, wins)
assert_eq(its.map(i => i.id), ["firefox", "nautilus-x", "foot", "gimp", "vlc", "org.kde.kate"])
assert_eq(first_running(its, c), 4)
}