Launcher: pick up web apps as they are installed, categories, scrolling
CI / test (push) Failing after 49s

- Read the app catalog again when the Applications menu opens if .desktop files were added or removed (and on Reload); it was only read at login, so a PWA installed during the session was missing from the menu and its search
- List a Chromium browser's web apps in their own category ("Chrome Apps", "Chromium Apps", ...), as Plasma does; don't take one for the default browser
- Category column and a scrollable list (wheel, scrollbar) when the catalog doesn't fit the menu
- Show menu-spec main category names instead of the first Categories= entry; sort apps A-Z (they were sorted shortest name first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-28 23:42:10 -08:00
1 parent aa92aaac6f
commit 68baf1a467
11 files changed
+578 -109

No files matched your search

+3
View File
@@ -2427,6 +2427,9 @@ fn ChandraCompositor::dispatch_input_inner(
}
None => ()
}
if axis == 0U && self.shell.scroll_popup(xi, yi, v, discrete) {
return
}
if self.overview is Some(_) {
return // nothing scrolls under the overview
}
+3 -2
View File
@@ -80,8 +80,9 @@ test "the dock is the panel's task manager: empty + opens Applications, pin from
let launcher = comp.shell.slot_of("launcher")
let pr = comp.shell.slot_popup_rect(launcher)
assert_true(pr.w > 0)
// (The apps are right of the category column, when the machine has enough of them for one.)
// Right-click the first app there: Open, Pin to dock. Pinning keeps the menu open.
click_at(comp, pr.x + 40, pr.y + 60, 20U, btn=273U)
click_at(comp, pr.x + pr.w - 60, pr.y + 60, 20U, btn=273U)
assert_true(comp.shell.menu_open)
assert_eq(comp.shell.menu_rows.map(r => r.label), ["Open", "Pin to dock"])
let first = comp.shell.menu_title
@@ -91,7 +92,7 @@ test "the dock is the panel's task manager: empty + opens Applications, pin from
let pinned = comp.shell.module_setting("dock", "pinned").unwrap_or("")
assert_true(pinned.length() > 1 && pinned != ";")
// The same app's menu now offers Unpin.
click_at(comp, pr.x + 40, pr.y + 60, 30U, btn=273U)
click_at(comp, pr.x + pr.w - 60, pr.y + 60, 30U, btn=273U)
assert_eq(comp.shell.menu_title, first)
assert_true(comp.shell.menu_rows.map(r => r.label).contains("Unpin from dock"))
comp.handle_input(@nested.InputEvent::Key(1U, true), 35U) // Escape closes the menu
+2 -1
View File
@@ -1138,7 +1138,8 @@ test "dragging a floating window's corner resizes it" {
/// bottom, 8 px margins, 4 px gaps).
fn launcher_button(comp : @host.ChandraCompositor, i : Int) -> (Int, Int) {
let pr = comp.shell.slot_popup_rect(comp.shell.slot_of("launcher"))
(pr.x + 8 + i * 65 + 30, pr.y + pr.h - 44 + 6 + 15)
let bw = (pr.w - 2 * 8 - 4 * 4) / 5
(pr.x + 8 + i * (bw + 4) + bw / 2, pr.y + pr.h - 44 + 6 + 15)
}
///|
+59
View File
@@ -0,0 +1,59 @@
///| Web apps (PWAs) Chrome installs, in the Applications menu: they are picked up when the menu
/// next opens, in a "Chrome Apps" category, and the wheel scrolls the list.
/// Needs the modules built: scripts/build-modules.sh.
test "a web app installed while running is in the menu's Chrome Apps" {
let data = "/tmp/chandra-webapps-" + @sys.getpid().to_string()
let dir = data + "/applications"
assert_true(@sys.mkdir_p(dir))
let app = fn(id : String, name : String, rest : String) {
ignore(
@sys.write_file_bytes(
dir + "/" + id + ".desktop",
@sys.str_to_utf8_bytes("[Desktop Entry]\nType=Application\nName=" + name + "\n" + rest),
),
)
}
for i = 0; i < 12; i = i + 1 {
app("chandra-game" + i.to_string(), "Chandra Game " + i.to_string(), "Exec=true\nCategories=Game;\n")
}
let socket_path = "/tmp/wayland-moon-webapps-" + @sys.getpid().to_string() + ".sock"
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
comp.shell.xdg_dirs = { ..comp.shell.xdg_dirs, data_home: data, data_dirs: [] }
comp.shell.toggle_launcher()
comp.shell.toggle_launcher()
let id = "chrome-chandratestappid-Default"
assert_eq(comp.shell.apps.length(), 12)
assert_false(comp.shell.apps.iter().any(a => a.id == id))
// Chrome installs it.
app(
id,
"Chandra Web App",
"Exec=/opt/google/chrome/google-chrome --profile-directory=Default --app-id=chandratestappid\n",
)
comp.shell.toggle_launcher()
for _ in 0..<10 {
@sys.sleep_ms(30) // the popup slides in
ignore(comp.compose_frame())
}
let a = comp.shell.apps.filter(a => a.id == id)
assert_eq(a.map(a => (a.name, a.category)), [("Chandra Web App", "Chrome Apps")])
let slot = comp.shell.slot_of("launcher")
let pr = comp.shell.slot_popup_rect(slot)
let texts = fn() { comp.shell.slot_popup_texts(slot).map(t => t.0) }
assert_true(texts().contains("Chrome Apps"))
// The wheel over the list scrolls it (the shell's copy of the menu follows the module's).
let (lx, ly) = (pr.x + pr.w - 60, pr.y + 60)
comp.handle_input(@nested.InputEvent::PointerMove(lx.to_double(), ly.to_double()), 1U)
comp.handle_input(@nested.InputEvent::Scroll(0U, 15.0, 1), 2U)
assert_eq(comp.shell.launcher_state.scroll, 3)
// Its category lists it.
let cats = ["All", "Chrome Apps", "Games"]
let i = cats.search("Chrome Apps").unwrap()
click_at(comp, pr.x + 20, pr.y + 52 + i * 26 + 12, 10U)
ignore(comp.compose_frame())
assert_eq(comp.shell.launcher_state.category, "Chrome Apps")
assert_true(texts().contains("Chandra Web App"))
assert_false(texts().contains("Chandra Game 0"))
ignore(@sys.write_file_bytes("_build/launcher_webapps.png", @renderer.encode_png(comp.compose_frame())))
comp.shell.shutdown()
}