diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-26 10:42:40 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-26 10:42:40 +0100 |
| commit | 6496d0660abf781ff2a76f97f9a5c03034d6cf45 (patch) | |
| tree | 36933a74a29c85eeea35d0a70f139bfc934c5527 | |
| parent | 8853bafd18e7172b6d12214519db1b167143fe66 (diff) | |
| download | deck-it-6496d0660abf781ff2a76f97f9a5c03034d6cf45.tar.gz deck-it-6496d0660abf781ff2a76f97f9a5c03034d6cf45.zip | |
feat(windows): horizontal strips grouped by workspace or app
The window grid becomes horizontal strips with All, Workspace and App
filters. Grouped views get one strip per workspace or app class, headed
by its icon; the choice is kept in localStorage. A strip is not rebuilt
while touched or within a second of scrolling, and keeps its scroll.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | AGENTS.md | 5 | ||||
| -rw-r--r-- | static/deck.css | 13 | ||||
| -rw-r--r-- | static/modules/windows.js | 78 |
3 files changed, 85 insertions, 11 deletions
@@ -148,7 +148,10 @@ Keep the server dependency-free apart from that one package. - The Windows tab's previews are `grim -T <stableId>` (Hyprland's stableId is the ext-foreign-toplevel identifier), served at `/api/windows/image/<id>` through `Module.image`, only for a window the last state listed; the URL - changes every 5s so the browser cache answers in between. Workspace icons + changes every 5s so the browser cache answers in between. The cards sit + in horizontal strips: one (All), or one per workspace or app class, the + choice kept in `localStorage`; a strip is not rebuilt while a finger is on + it or it scrolled in the last second, and keeps its scroll. Workspace icons come from keystone's `Workspaces.qml` map (`[windows] workspace_icons`). - A panel may export `peek(state)`; when it returns seconds > 0 `app.js` shows that tab that long and then goes back, unless the page is touched or diff --git a/static/deck.css b/static/deck.css index fdb79de..1bebd1a 100644 --- a/static/deck.css +++ b/static/deck.css @@ -225,7 +225,18 @@ select { content: ""; position: absolute; left: 50%; bottom: -10px; width: 6px; height: 6px; border-radius: 3px; background: var(--udt-accent); transform: translateX(-50%); } -.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 14px; } +.whead { display: flex; align-items: center; justify-content: space-between; gap: 12px; } +.wfilter { display: flex; gap: 8px; } +.wfilter .wtile { min-height: 44px; font-size: 1rem; } +.wrows { display: flex; flex-direction: column; gap: 16px; } +.wrow { display: flex; align-items: center; gap: 12px; } +.wlabel { + flex: none; width: 56px; min-height: 56px; display: grid; place-items: center; + color: var(--udt-accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; +} +.wlabel img { width: 40px; height: 40px; object-fit: contain; } +.wstrip { flex: 1; min-width: 0; display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; } +.wstrip .wcard { flex: 0 0 260px; scroll-snap-align: start; } .wcard { display: flex; flex-direction: column; gap: 6px; padding: 0; font: inherit; background: none; border: 0; color: inherit; cursor: pointer; min-width: 0; } .wbox { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; diff --git a/static/modules/windows.js b/static/modules/windows.js index fdd9ec8..ada6e61 100644 --- a/static/modules/windows.js +++ b/static/modules/windows.js @@ -136,7 +136,8 @@ function card(w, workspaces, wsIcons) { return c; } -function appIcon(w) { +// gone() runs when no icon name resolves. +function appIcon(w, gone) { if (!w.icons?.length) return null; const img = document.createElement("img"); img.className = "wicon"; @@ -145,6 +146,7 @@ function appIcon(w) { const next = () => { if (i >= w.icons.length) { img.remove(); + gone?.(); return; } img.src = `/icons/${w.icons[i++]}.svg`; @@ -154,6 +156,52 @@ function appIcon(w) { return img; } +// The window list is one horizontal strip, or one per workspace or app. +const GROUPS = { all: () => "", ws: (w) => w.workspace, app: (w) => w.class }; +const MODE_KEY = "deckit.windows.group"; +const saved = globalThis.localStorage?.getItem(MODE_KEY); +let mode = GROUPS[saved] ? saved : "all"; + +function rows(el) { + // A rebuild under a swiping finger kills the swipe: wait until the strips + // have been still for a second, the next poll catches up. + el._stale = el._touch || Date.now() - (el._held ?? 0) < 1000; + if (el._stale) return; + const st = el._st; + for (const b of el.querySelectorAll(".wfilter .wtile")) b.classList.toggle("on", b.dataset.k === mode); + const box = el.querySelector(".wrows"); + const scrolled = {}; + for (const r of box.children) scrolled[r.dataset.k] = r.querySelector(".wstrip").scrollLeft; + box.textContent = ""; + for (const [k, wins] of Map.groupBy(st.windows ?? [], GROUPS[mode])) { + const row = document.createElement("div"); + row.className = "wrow"; + row.dataset.k = k; + if (mode !== "all") { + const head = document.createElement("div"); + head.className = "wlabel"; + head.title = String(k); + if (mode === "ws") wsMark(head, k, st.wsIcons); + else { + const icon = appIcon(wins[0], () => { head.textContent = k; }); + if (icon) head.append(icon); + else head.textContent = k; + } + row.append(head); + } + const strip = document.createElement("div"); + strip.className = "wstrip"; + for (const w of wins) { + const c = card(w, st.workspaces, st.wsIcons); + c.dataset.id = w.id; + strip.append(c); + } + row.append(strip); + box.append(row); + strip.scrollLeft = scrolled[k] ?? 0; + } +} + export default { title: "Windows", tab: "Windows", @@ -163,8 +211,24 @@ export default { el.innerHTML = `<div class="windows"> <section class="deck-block"><h3>Workspaces</h3><div class="ws"></div></section> <section class="deck-block"><h3>Applications</h3><div class="launches"></div></section> - <section class="deck-block"><h3>Windows</h3><div class="wgrid"></div></section> + <section class="deck-block"><div class="whead"><h3>Windows</h3><div class="wfilter"></div></div> + <div class="wrows"></div></section> </div>`; + const filter = el.querySelector(".wfilter"); + for (const [k, label] of [["all", "All"], ["ws", "Workspace"], ["app", "App"]]) { + const b = tile(label, () => { + mode = k; + localStorage.setItem(MODE_KEY, k); + if (el._st) rows(el); + }); + b.dataset.k = k; + filter.append(b); + } + const box = el.querySelector(".wrows"); + const held = () => { el._held = Date.now(); }; + box.addEventListener("touchstart", () => { el._touch = true; held(); }, { passive: true }); + for (const ev of ["touchend", "touchcancel"]) box.addEventListener(ev, () => { el._touch = false; held(); }); + box.addEventListener("scroll", held, true); }, // A window that was not there on the last poll brings the tab forward for @@ -180,8 +244,10 @@ export default { update(st, el) { // Polled every second: rebuilding unchanged rows reloads every icon // through its fallbacks, which flickers, so only a change re-renders. + el._st = st; const key = JSON.stringify(st); if (key === el._last) { + if (el._stale) rows(el); for (const img of el.querySelectorAll(".wshot")) { const url = previewUrl({ id: img.closest(".wcard").dataset.id }); if (!img.src.endsWith(url)) { img.hidden = false; img.src = url; } @@ -221,12 +287,6 @@ export default { launches.append(b); } - const grid = el.querySelector(".wgrid"); - grid.textContent = ""; - for (const w of st.windows ?? []) { - const c = card(w, st.workspaces, st.wsIcons); - c.dataset.id = w.id; - grid.append(c); - } + rows(el); }, }; |
