Add backlight control to the shell and regenerate WIT bindings
CI / test (push) Canceled after 0s

- Add compositor/shell/backlight.mbt for backlight control in the shell
- Update wit/capabilities.wit and wit/host/plasmoids.wit, then regenerate the component and interface ffi.mbt bindings (mostly export reordering)
- Add world/launcher-widget/README.md
This commit is contained in:
nandi committed 2026-11-28 02:16:07 -08:00
1 parent 2e00009c79
commit 74235cb0ca
84 files changed
+1525 -864

No files matched your search

+59 -1
View File
@@ -1739,7 +1739,7 @@ test "the settings module's Power tab steps the timeouts and confirms power off"
// Rows of 28 below the tab bar (40): [Battery heading, battery,] When idle, screen off,
// suspend, Now, Suspend, Restart, Power off.
let n = (pr.h - 40 - 6) / 28
assert_true(n == 7 || n == 9)
assert_true(n == 7 || n == 9 || n == 11)
let first = n - 7
let row_y = fn(i : Int) { pr.y + 40 + (first + i) * 28 + 13 }
assert_eq(comp.shell.screen_off_min, 10)
@@ -1775,3 +1775,61 @@ test "power timeouts are saved to state.edn and restored" {
assert_false(read_state_edn().contains(":power"))
}
}
///|
test "power key toggles manual screen off and wakes without leaking touches" {
let comp = new_comp("powerbtn")
comp.note_activity(1000UL)
assert_eq(comp.power_tick(1000UL), NoChange)
// Pressing KEY_POWER (116) turns screen off; releasing it leaves it off.
comp.handle_input(@nested.InputEvent::Key(116U, true), 10U)
comp.handle_input(@nested.InputEvent::Key(116U, false), 20U)
assert_eq(comp.power_tick(1050UL), ScreenOff)
assert_eq(comp.power_tick(1060UL), NoChange)
// Stray touch/pointer activity while manually blanked does not wake the screen.
comp.handle_input(@nested.InputEvent::PointerMove(50.0, 50.0), 30U)
assert_eq(comp.power_tick(1100UL), NoChange)
// Second KEY_POWER press wakes the screen and keeps it awake after release.
comp.handle_input(@nested.InputEvent::Key(116U, true), 40U)
comp.handle_input(@nested.InputEvent::Key(116U, false), 50U)
assert_eq(comp.power_tick(1200UL), ScreenOn)
assert_eq(comp.power_tick(1300UL), NoChange)
// Control socket screen commands work symmetrically.
let (r1, ok1) = comp.control_command("screen off")
assert_true(ok1 && r1 == ["ok off"])
assert_eq(comp.power_tick(1400UL), ScreenOff)
let (r2, ok2) = comp.control_command("screen on")
assert_true(ok2 && r2 == ["ok on"])
assert_eq(comp.power_tick(1500UL), ScreenOn)
}
///|
test "settings Power tab displays and adjusts backlight brightness" {
let root = "/tmp/chandra-test-backlight"
let dev = root + "/ae94000.dsi.0"
ignore(@sys.mkdir_p(dev))
assert_eq(@sys.write_file_bytes(dev + "/max_brightness", @utf8.encode("1000\n")), 0)
assert_eq(@sys.write_file_bytes(dev + "/brightness", @utf8.encode("500\n")), 0)
@shell.set_backlight_root(root)
let comp = new_comp("brightness")
comp.shell.refresh_brightness()
let slot = comp.shell.slot_of("session-settings")
assert_true(comp.shell.open_settings(Power))
ignore(comp.compose_frame())
let texts = comp.shell.slot_popup_texts(slot).map(t => t.0)
assert_true(texts.contains("Brightness"))
assert_true(texts.contains("50%"))
let pr = comp.shell.slot_popup_rect(slot)
let (_, br) = comp.control_command("brightness 80")
assert_true(br)
ignore(comp.compose_frame())
assert_true(comp.shell.slot_popup_texts(slot).map(t => t.0).contains("80%"))
assert_eq(@shell.read_backlight_percent(), 80)
// Clicking the '-' button (x inside [margin..47]) steps 80 -> 70%.
let n = (pr.h - 40 - 6) / 28
let bright_row = n - 8
assert_true(bright_row >= 1)
click_at(comp, pr.x + 25, pr.y + 40 + bright_row * 28 + 13, 10U)
assert_eq(@shell.read_backlight_percent(), 70)
@shell.set_backlight_root("/sys/class/backlight")
}