Launcher: Reload session, and Log out moves in from its own module
CI / test (push) Failing after 17s
CI / test (push) Failing after 17s
The Application Launcher's menu now ends in a session row: Reload, Log out, Suspend, Restart,
Power off. Log out, Restart and Power off take a second click on the same button (a status line
says "Click Log out again to confirm"); Reload and Suspend act at once.
- Reload calls the new session.reload, which reaches the shell as the ReloadSession request
(native stub: request 8 with n 1; host plasmoids.wit: reload-session; host-wasm: Req::ReloadSession)
and runs DesktopShell::reload_modules(""): every panel module again from disk, in place, with
its settings. Windows and apps keep running. The compositor redraws the whole frame after it.
- Suspend / Restart / Power off use the power capability, the same calls as Settings > Power.
- The standalone logout module is gone (component, world, components.txt). Saved panels drop
"logout", or get the launcher in its place when they had none; panel.edn is rewritten without
it. A stale logout.wasm is hidden from Settings > Panel (retired_modules).
- Tests: lib/launcher session row, shell migrate_panel, host input tests for Log out and Reload,
host-wasm launcher session row; control_test uses inspector.wasm instead of logout.wasm.
- README and docs/reloading.md describe the session row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjKUnSS3D92ThigvJf
This commit is contained in:
37 files changed
+420
-827
No files matched your search
@@ -88,7 +88,7 @@ pub(all) struct ChandraCompositor {
|
||||
/// can restore them.
|
||||
mut desktop_hidden : Array[UInt64]
|
||||
mut layout_mode : @wm.LayoutMode
|
||||
/// Set when the user asked to end the session (the logout button); the main loop then exits.
|
||||
/// Set when the user asked to end the session (the launcher's Log out); the main loop then exits.
|
||||
mut quit_requested : Bool
|
||||
/// Alt+Tab switcher (switcher.mbt): whether it is up, its window list (most recent first) and selection.
|
||||
mut switcher_on : Bool
|
||||
@@ -1203,6 +1203,11 @@ fn ChandraCompositor::run_shell_actions(self : ChandraCompositor) -> Unit {
|
||||
@shell.ShellAction::Screenshot(code) => self.screenshot_request(code)
|
||||
@shell.ShellAction::SystemPower(a) => self.system_power(a)
|
||||
@shell.ShellAction::Window(wid, cmd) => self.window_command(wid, cmd)
|
||||
@shell.ShellAction::ModulesReloaded => {
|
||||
// The panel changed under the frame signature's feet (as after `chandra-ctl reload`).
|
||||
self.frame_changed = true
|
||||
self.damage.mark_full()
|
||||
}
|
||||
@shell.ShellAction::SetLayout(m) =>
|
||||
match m {
|
||||
0 => self.set_layout_mode(@wm.LayoutMode::Tiling)
|
||||
|
||||
@@ -126,9 +126,9 @@ test "a module that fails to reload stays loaded and the error is reported" {
|
||||
let (comp, path) = control_comp("fail")
|
||||
let dir = "/tmp/chandra-control-badmod-" + @sys.getpid().to_string()
|
||||
ignore(@sys.mkdir_p(dir))
|
||||
let good = @sys.read_file_bytes("build/components/logout.wasm")
|
||||
let good = @sys.read_file_bytes("build/components/inspector.wasm")
|
||||
assert_true(good.length() > 0)
|
||||
let copy = dir + "/logout.wasm"
|
||||
let copy = dir + "/inspector.wasm"
|
||||
ignore(@sys.write_file_bytes(copy, good))
|
||||
assert_true(comp.shell.load_module(copy))
|
||||
let before = panel_order(comp)
|
||||
|
||||
@@ -560,6 +560,8 @@ test "a panel saved with the old 12-hour clock gets the Digital Clock with the s
|
||||
assert_eq(a.module_setting("clock-digital12", "date"), None)
|
||||
let panel = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/panel.edn"))
|
||||
assert_true(panel.contains("\"clock-digital\"") && !panel.contains("clock-digital12"))
|
||||
// The old Log out button became the launcher, which has Log out now.
|
||||
assert_true(panel.contains("\"launcher\"") && !panel.contains("logout"))
|
||||
assert_true(panel.contains(":version 2"))
|
||||
// Only once: a format chosen afterwards sticks across restarts.
|
||||
a.set_module_setting(a.slot_of("clock-digital"), "format", "24-hour")
|
||||
@@ -1040,31 +1042,56 @@ test "dragging a floating window's corner resizes it" {
|
||||
assert_eq(g1.h, g0.h - 40)
|
||||
}
|
||||
|
||||
///| Centre of session-row button `i` (0 Reload, 1 Log out, 2 Suspend, 3 Restart, 4 Power off)
|
||||
/// in the launcher's open popup (geometry from lib/launcher: 5 buttons in a 44 px row at the
|
||||
/// 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)
|
||||
}
|
||||
|
||||
///|
|
||||
test "the logout button asks first, then ends the session" {
|
||||
let comp = new_comp("logout")
|
||||
let slot = comp.shell.slot_of("logout")
|
||||
test "the launcher's Log out asks first, then ends the session" {
|
||||
let comp = new_comp("launcher-logout")
|
||||
let slot = comp.shell.slot_of("launcher")
|
||||
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
|
||||
assert_false(comp.quit_requested)
|
||||
// A click opens the popup; nothing is requested yet.
|
||||
click_module(comp, "logout", 1U)
|
||||
let pr = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr.w > 0)
|
||||
// The old Log out button is gone from the default panel.
|
||||
assert_false(comp.shell.slots().map(s => comp.shell.slot_module(s)).contains("logout"))
|
||||
click_module(comp, "launcher", 1U)
|
||||
assert_true(comp.shell.slot_popup_rect(slot).w > 0)
|
||||
ignore(comp.compose_frame())
|
||||
// The first click on Log out only arms it.
|
||||
let (x, y) = launcher_button(comp, 1)
|
||||
click_at(comp, x, y, 5U)
|
||||
ignore(comp.compose_frame())
|
||||
assert_false(comp.quit_requested)
|
||||
// Cancel (second row) closes it without logging out.
|
||||
click_at(comp, pr.x + 20, pr.y + 6 + 30 + 5, 5U)
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).w, 0)
|
||||
assert_false(comp.quit_requested)
|
||||
// Open again and choose Log out (first row).
|
||||
click_module(comp, "logout", 10U)
|
||||
let pr2 = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr2.w > 0)
|
||||
click_at(comp, pr2.x + 20, pr2.y + 6 + 5, 15U)
|
||||
assert_true(comp.shell.slot_popup_rect(slot).w > 0)
|
||||
assert_true(comp.shell.slot_popup_texts(slot).iter().any(t => t.0 == "Click Log out again to confirm"))
|
||||
// The second ends the session.
|
||||
let (x, y) = launcher_button(comp, 1)
|
||||
click_at(comp, x, y, 10U)
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(comp.quit_requested)
|
||||
}
|
||||
|
||||
///|
|
||||
test "the launcher's Reload reloads every panel module in place" {
|
||||
let comp = new_comp("launcher-reload")
|
||||
let before = comp.shell.slots().map(s => comp.shell.slot_module(s))
|
||||
let slots_before = comp.shell.slots()
|
||||
click_module(comp, "launcher", 1U)
|
||||
ignore(comp.compose_frame())
|
||||
let (x, y) = launcher_button(comp, 0)
|
||||
click_at(comp, x, y, 5U)
|
||||
ignore(comp.compose_frame())
|
||||
assert_false(comp.quit_requested)
|
||||
// Same modules in the same order, each a fresh instance (new slot ids).
|
||||
assert_eq(comp.shell.slots().map(s => comp.shell.slot_module(s)), before)
|
||||
for s in comp.shell.slots() {
|
||||
assert_false(slots_before.contains(s))
|
||||
}
|
||||
}
|
||||
|
||||
///| Contents of state.edn in the scratch config dir.
|
||||
fn read_state_edn() -> String {
|
||||
let dir = match @sys.getenv("XDG_CONFIG_HOME") {
|
||||
|
||||
@@ -151,7 +151,7 @@ pub(all) enum WindowCommand {
|
||||
pub(all) enum ShellAction {
|
||||
SetLayout(Int)
|
||||
FocusWindow(UInt64)
|
||||
/// A module (the logout button) asked to end the session.
|
||||
/// A module (the launcher's Log out) asked to end the session.
|
||||
Logout
|
||||
/// The Dark mode setting changed: the compositor swaps the theme (see `dark_mode`).
|
||||
ThemeChanged
|
||||
@@ -162,6 +162,8 @@ pub(all) enum ShellAction {
|
||||
SystemPower(Int)
|
||||
/// A row of a task-bar pill's right-click menu: do this to that window.
|
||||
Window(UInt64, WindowCommand)
|
||||
/// The launcher's Reload reloaded the panel modules: the whole frame needs drawing again.
|
||||
ModulesReloaded
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///| One wasm module loaded into the panel.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
///| Modules loaded into a fresh panel, in order. `tasks` stretches, so what follows it packs right.
|
||||
let default_panel : Array[String] = [
|
||||
"launcher", "inspector", "layout", "tasks", "moon-disc", "network", "clock-digital", "screenshot",
|
||||
"session-settings", "logout",
|
||||
"session-settings",
|
||||
]
|
||||
|
||||
///| A fresh panel's modules: the defaults, plus the battery before the clock on a machine that
|
||||
@@ -44,7 +44,13 @@ test "a fresh panel gets the battery module only on a machine with a battery" {
|
||||
/// works everywhere a module is named (saved panels, load_module), it is just never listed:
|
||||
/// a stale build/components/clock-digital12.wasm or an old installed copy stays out of the picker.
|
||||
/// - clock-digital12, the 12-hour clock, is the Digital Clock, which now starts in 12-hour mode.
|
||||
let retired_modules : Map[String, String] = { "clock-digital12": "clock-digital" }
|
||||
/// - 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).
|
||||
let retired_modules : Map[String, String] = {
|
||||
"clock-digital12": "clock-digital",
|
||||
"logout": "launcher",
|
||||
}
|
||||
|
||||
///| The id a module goes by now ("clock-digital12" -> "clock-digital").
|
||||
fn current_module_id(id : String) -> String {
|
||||
@@ -214,16 +220,22 @@ fn wall_secs() -> Int {
|
||||
|
||||
///| Panels saved before the wallpaper chooser and the module manager moved into the settings
|
||||
/// module list "wallpaper" or "module-manager": the settings module takes the first one's place
|
||||
/// (a panel that already has it just drops them). Retired modules (clock-digital12) become
|
||||
/// the module that replaced them.
|
||||
/// (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.
|
||||
fn migrate_panel(entries : Array[String]) -> Array[String] {
|
||||
let has_settings = entries.contains("session-settings")
|
||||
let has_launcher = entries.contains("launcher")
|
||||
let out : Array[String] = []
|
||||
for e in entries {
|
||||
if e == "wallpaper" || e == "module-manager" {
|
||||
if !has_settings && !out.contains("session-settings") {
|
||||
out.push("session-settings")
|
||||
}
|
||||
} else if e == "logout" {
|
||||
if !has_launcher && !out.contains("launcher") {
|
||||
out.push("launcher")
|
||||
}
|
||||
} else {
|
||||
out.push(current_module_id(e))
|
||||
}
|
||||
@@ -233,7 +245,7 @@ fn migrate_panel(entries : Array[String]) -> Array[String] {
|
||||
|
||||
///|
|
||||
test "a saved panel's wallpaper button becomes the settings module" {
|
||||
assert_eq(migrate_panel(["launcher", "wallpaper", "logout"]), ["launcher", "session-settings", "logout"])
|
||||
assert_eq(migrate_panel(["launcher", "wallpaper", "logout"]), ["launcher", "session-settings"])
|
||||
assert_eq(migrate_panel(["wallpaper", "session-settings"]), ["session-settings"])
|
||||
assert_eq(migrate_panel(["module-manager", "clock", "wallpaper"]), ["session-settings", "clock"])
|
||||
assert_eq(migrate_panel(["clock"]), ["clock"])
|
||||
@@ -241,11 +253,23 @@ test "a saved panel's wallpaper button becomes the settings module" {
|
||||
|
||||
///|
|
||||
test "a saved panel's 12-hour clock becomes the digital clock" {
|
||||
assert_eq(migrate_panel(["tasks", "clock-digital12", "logout"]), ["tasks", "clock-digital", "logout"])
|
||||
assert_eq(migrate_panel(["tasks", "clock-digital12", "logout"]), ["tasks", "clock-digital", "launcher"])
|
||||
assert_eq(current_module_id("clock-digital12"), "clock-digital")
|
||||
assert_eq(current_module_id("clock-binary"), "clock-binary")
|
||||
}
|
||||
|
||||
///|
|
||||
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",
|
||||
])
|
||||
// ...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(["logout", "launcher"]), ["launcher"])
|
||||
assert_false(default_panel.contains("logout"))
|
||||
}
|
||||
|
||||
///| Load the panel on first use: the saved layout if there is one, else the default modules.
|
||||
fn DesktopShell::ensure_booted(self : DesktopShell) -> Unit {
|
||||
if self.booted {
|
||||
@@ -265,6 +289,9 @@ fn DesktopShell::ensure_booted(self : DesktopShell) -> Unit {
|
||||
self.migrate_module_cfg(old)
|
||||
write_panel_file(entries)
|
||||
}
|
||||
// A renamed or folded module (the Log out button, now in the launcher): rewrite the file so
|
||||
// the old name is gone for good.
|
||||
Some(old) if old != entries => write_panel_file(entries)
|
||||
_ => ()
|
||||
}
|
||||
for e in entries {
|
||||
@@ -743,6 +770,11 @@ fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
|
||||
Some(FocusWindow(n)) => self.actions.push(FocusWindow(n.to_int64().to_uint64()))
|
||||
Some(SetLayout(m)) => self.actions.push(SetLayout(m))
|
||||
Some(Logout) => self.actions.push(Logout)
|
||||
// The launcher's Reload: every panel module again from disk, in place.
|
||||
Some(ReloadSession) => {
|
||||
ignore(self.reload_modules(""))
|
||||
self.actions.push(ModulesReloaded)
|
||||
}
|
||||
Some(SetWallpaper(i)) => self.set_wallpaper(i)
|
||||
Some(SetSessionSetting(i, on)) => self.set_session_setting(i, on)
|
||||
Some(Screenshot(code)) => self.actions.push(Screenshot(code))
|
||||
|
||||
@@ -365,6 +365,8 @@ pub(all) enum HostRequest {
|
||||
/// The shortcuts capability: action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel
|
||||
/// the capture).
|
||||
Shortcut(Int)
|
||||
/// The session capability's `reload`: reload every loaded panel module from disk.
|
||||
ReloadSession
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -388,6 +390,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(PowerAction(a)) => Some(PowerAction(a))
|
||||
Some(Network(r)) => Some(Network(r.action, r.ssid, r.password))
|
||||
Some(Shortcut(code)) => Some(Shortcut(code))
|
||||
Some(ReloadSession) => Some(ReloadSession)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -787,6 +787,8 @@ pub(all) enum HostRequest {
|
||||
/// The shortcuts capability: action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel
|
||||
/// the capture).
|
||||
Shortcut(Int)
|
||||
/// The session capability's `reload`: reload every loaded panel module from disk.
|
||||
ReloadSession
|
||||
} derive(Eq, Debug)
|
||||
|
||||
///|
|
||||
@@ -810,7 +812,7 @@ pub fn next_request() -> HostRequest? {
|
||||
Some(MoveInstance(req_str(), delta))
|
||||
}
|
||||
7 => Some(Browse)
|
||||
8 => Some(Logout)
|
||||
8 => if c_host_req_int() == 1 { Some(ReloadSession) } else { Some(Logout) }
|
||||
9 => Some(SetWallpaper(c_host_req_int()))
|
||||
10 => Some(SetSessionSetting(c_host_req_int(), false))
|
||||
11 => Some(SetSessionSetting(c_host_req_int(), true))
|
||||
|
||||
@@ -52,7 +52,7 @@ static Inst insts[MAX_INST];
|
||||
enum {
|
||||
K_OTHER, K_TOKENS, K_CLOCK, K_APPS, K_LAUNCH, K_WINDOWS, K_FOCUS, K_LAYOUTS, K_LAYOUT_CUR, K_SET_LAYOUT,
|
||||
K_INSPECT_IS_ON, K_INSPECT_SET, K_MOD_AVAILABLE, K_MOD_LOADED, K_MOD_LOAD, K_MOD_UNLOAD, K_MOD_MOVE, K_MOD_BROWSE,
|
||||
K_SYSTEM_READ, K_WIN_ALL, K_WIN_FOCUS_ID, K_LOGOUT, K_WALLPAPERS, K_WALLPAPER_CUR, K_SET_WALLPAPER,
|
||||
K_SYSTEM_READ, K_WIN_ALL, K_WIN_FOCUS_ID, K_LOGOUT, K_RELOAD, K_WALLPAPERS, K_WALLPAPER_CUR, K_SET_WALLPAPER,
|
||||
K_SESSION_SETTINGS, K_SESSION_IS_ON, K_SESSION_SET,
|
||||
K_APP_ICON,
|
||||
K_SHOT_TAKE, K_SHOT_RECORD, K_SHOT_STOP, K_SHOT_IS_REC, K_SHOT_PTR, K_SHOT_SET_PTR,
|
||||
@@ -372,6 +372,7 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
|
||||
case K_SET_LAYOUT: push_req(3, a0, NULL); break;
|
||||
case K_FOCUS: push_req(2, a0, NULL); break;
|
||||
case K_LOGOUT: push_req(8, 0, NULL); break;
|
||||
case K_RELOAD: push_req(8, 1, NULL); break; /* 8: session; n 0 log out, 1 reload */
|
||||
case K_SET_WALLPAPER: push_req(9, a0, NULL); break;
|
||||
case K_SESSION_SET: push_req(a1 ? 11 : 10, a0, NULL); break; /* 10 off, 11 on */
|
||||
/* Request 12 carries the screenshot code: 0-3 take, 10-12 record, 20 stop, 30/31 pointer. */
|
||||
@@ -577,6 +578,7 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
|
||||
if (!strcmp(iface, "battery") && !strcmp(fn, "read")) return K_BAT_READ;
|
||||
if (!strcmp(iface, "icons") && !strcmp(fn, "app-icon")) return K_APP_ICON;
|
||||
if (!strcmp(iface, "session") && !strcmp(fn, "logout")) return K_LOGOUT;
|
||||
if (!strcmp(iface, "session") && !strcmp(fn, "reload")) return K_RELOAD;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "wallpapers")) return K_WALLPAPERS;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "current-wallpaper")) return K_WALLPAPER_CUR;
|
||||
if (!strcmp(iface, "wallpaper") && !strcmp(fn, "set-wallpaper")) return K_SET_WALLPAPER;
|
||||
|
||||
Reference in new issue
Block a user