- Lock the session from the power button or `chandra-ctl lock` - Unlock with a face or the password; the password always works - Add compositor lock module with tests, and a polkit unlock policy (org.chandra.unlock) - Document the lock flow in docs/lock.md and link it from the README - Add generated interface bindings for the compositor and widget components
This commit is contained in:
1 parent
7501fc3ad9
commit
c790f96e58
131 files changed
+4693
-274
No files matched your search
+130
-19
@@ -12,6 +12,20 @@ fn osk_comp(tag : String, enable_osk? : Bool = true) -> @host.ChandraCompositor
|
||||
comp
|
||||
}
|
||||
|
||||
///| Replace the panel with the compact 9-module handset set (`rotate` and `osk` included).
|
||||
fn load_handset_modules(comp : @host.ChandraCompositor) -> Unit raise {
|
||||
for slot in comp.shell.slots() {
|
||||
ignore(comp.shell.unload_slot(slot))
|
||||
}
|
||||
for id in [
|
||||
"launcher", "dock", "session-settings", "network", "battery", "clock-digital", "screenshot",
|
||||
"rotate", "osk",
|
||||
] {
|
||||
assert_true(comp.shell.load_module(id))
|
||||
}
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
|
||||
///|
|
||||
test "OSK stays disabled under CHANDRA_TEST_CONFIG=1 unless explicitly enabled" {
|
||||
let socket_path = "/tmp/wayland-moon-osk-disabled-" + @sys.getpid().to_string() + ".sock"
|
||||
@@ -89,10 +103,15 @@ test "OSK delivers evdev keys and one-shot Shift modifier to focused Wayland cli
|
||||
}
|
||||
|
||||
///|
|
||||
test "OSK Hide button dismisses keyboard and KB pill or client tap reopens it" {
|
||||
test "OSK Hide button dismisses keyboard and KB panel module or client tap reopens it" {
|
||||
let socket_path = "/tmp/wayland-moon-osk-hide-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 540, 1170).unwrap()
|
||||
comp.set_osk_enabled(true)
|
||||
ignore(comp.compose_frame())
|
||||
load_handset_modules(comp)
|
||||
let kr = rect_of(comp, "osk")
|
||||
assert_true(kr.w > 0 && kr.y >= comp.output_h - comp.theme.panel_height)
|
||||
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Notes", "notes")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
let (ti, _) = text_input_for(comp, a)
|
||||
@@ -104,15 +123,24 @@ test "OSK Hide button dismisses keyboard and KB pill or client tap reopens it" {
|
||||
click_at(comp, hx, hy, 20U)
|
||||
assert_false(comp.osk_is_visible())
|
||||
|
||||
// Tapping the compact "KB" toggle pill reopens it.
|
||||
let tr = comp.osk_toggle_rect()
|
||||
click_at(comp, tr.x + tr.w / 2, tr.y + tr.h / 2, 30U)
|
||||
assert_true(comp.osk_is_visible())
|
||||
// No floating "KB" or "Rot" pills are drawn above the panel when hidden.
|
||||
comp.damage.mark_full()
|
||||
let scene = comp.compose_scene().unwrap()
|
||||
for op in scene.panel_ops {
|
||||
match op {
|
||||
@scene.DrawOp::Text(_, y, text, _, _, _, _) if text == "KB" || text == "Rot" =>
|
||||
assert_true(y >= comp.output_h - comp.theme.panel_height)
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
||||
// Hide again, then tap inside the client window with active text input -> reopens.
|
||||
let (hx2, hy2) = comp.osk_key_center("Hide").unwrap()
|
||||
click_at(comp, hx2, hy2, 40U)
|
||||
// Tapping the "KB" panel module reopens the keyboard, and tapping it again hides it.
|
||||
click_module(comp, "osk", 30U)
|
||||
assert_true(comp.osk_is_visible())
|
||||
click_module(comp, "osk", 35U)
|
||||
assert_false(comp.osk_is_visible())
|
||||
|
||||
// Tap inside the client window with active text input -> reopens.
|
||||
let g = comp.windows.get(1UL).unwrap().geometry
|
||||
click_at(comp, g.x + g.w / 2, g.y + g.h / 2, 50U)
|
||||
assert_true(comp.osk_is_visible())
|
||||
@@ -160,24 +188,24 @@ test "OSK reaches the bottom edge in a strict kiosk, which has no panel" {
|
||||
}
|
||||
|
||||
///|
|
||||
test "Rot pill tap rotates CW, right-click flips 180 deg, and rotate control commands update size" {
|
||||
test "Rotate panel module rotates CW and rotate control commands update size" {
|
||||
let comp = osk_comp("rotate")
|
||||
let rr = comp.osk_rotate_rect()
|
||||
let rx = rr.x + rr.w / 2
|
||||
let ry = rr.y + rr.h / 2
|
||||
load_handset_modules(comp)
|
||||
let rr = rect_of(comp, "rotate")
|
||||
assert_true(rr.w > 0 && rr.y >= comp.output_h - comp.theme.panel_height)
|
||||
|
||||
// Tap Rot pill -> queues 90 deg CW rotation.
|
||||
click_at(comp, rx, ry, 10U)
|
||||
// Tap Rotate panel module -> queues 90 deg CW rotation.
|
||||
click_module(comp, "rotate", 10U)
|
||||
assert_eq(comp.take_pending_rotation(), Some(1))
|
||||
assert_eq(comp.current_rotation(), 1)
|
||||
comp.apply_rotated_size(1170, 540)
|
||||
assert_eq((comp.output_w, comp.output_h), (1170, 540))
|
||||
|
||||
// Right-click / long-press Rot pill -> queues 180 deg flip (1 -> 3 = 270 deg).
|
||||
let rr2 = comp.osk_rotate_rect()
|
||||
click_at(comp, rr2.x + rr2.w / 2, rr2.y + rr2.h / 2, 20U, btn=273U)
|
||||
assert_eq(comp.take_pending_rotation(), Some(3))
|
||||
assert_eq(comp.current_rotation(), 3)
|
||||
// Tap Rotate panel module again -> queues 180 deg rotation.
|
||||
click_module(comp, "rotate", 20U)
|
||||
assert_eq(comp.take_pending_rotation(), Some(2))
|
||||
assert_eq(comp.current_rotation(), 2)
|
||||
comp.apply_rotated_size(540, 1170)
|
||||
|
||||
// chandra-ctl rotate 0 / flip / status.
|
||||
let (out0, ok0) = comp.control_command("rotate 0")
|
||||
@@ -198,3 +226,86 @@ test "Rot pill tap rotates CW, right-click flips 180 deg, and rotate control com
|
||||
assert_eq(out_st, ["ok 180 540x1170"])
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "handset panel loads all 9 modules including rotate and osk inside 540px width" {
|
||||
let comp = osk_comp("handset-fit")
|
||||
load_handset_modules(comp)
|
||||
let ids = comp.shell.loaded_modules().filter(m => m.0 != "desktop").map(m => m.1)
|
||||
assert_eq(ids, [
|
||||
"launcher", "dock", "session-settings", "network", "battery", "clock-digital", "screenshot",
|
||||
"rotate", "osk",
|
||||
])
|
||||
for id in ids {
|
||||
let r = rect_of(comp, id)
|
||||
assert_true(r.w > 0 && r.x >= 0 && r.x + r.w <= comp.output_w)
|
||||
assert_true(r.y >= comp.output_h - comp.theme.panel_height)
|
||||
}
|
||||
comp.damage.mark_full()
|
||||
let scene = comp.compose_scene().unwrap()
|
||||
for op in scene.panel_ops {
|
||||
match op {
|
||||
@scene.DrawOp::Text(_, y, text, _, _, _, _) if text == "KB" || text == "Rot" =>
|
||||
assert_true(y >= comp.output_h - comp.theme.panel_height)
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "KB panel module toggles OSK manually even when auto-OSK is disabled" {
|
||||
let socket_path = "/tmp/wayland-moon-osk-manual-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 540, 1170).unwrap()
|
||||
ignore(comp.compose_frame())
|
||||
load_handset_modules(comp)
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Notes", "notes")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
let (ti, kbd) = text_input_for(comp, a)
|
||||
text_input_state(comp, a, ti, true, 50, 50, 16)
|
||||
// Auto-OSK is off, so text-input-v3 does not pop it open on its own.
|
||||
assert_false(comp.osk_is_visible())
|
||||
ignore(drain_args(a))
|
||||
|
||||
// Clicking the KB panel module opens the OSK manually and typing reaches the client.
|
||||
click_module(comp, "osk", 20U)
|
||||
assert_true(comp.osk_is_visible())
|
||||
let (ax, ay) = comp.osk_key_center("a").unwrap()
|
||||
click_at(comp, ax, ay, 30U)
|
||||
let keys = drain_args(a).filter(m => m.0 == kbd && m.1 == 3U)
|
||||
assert_eq(keys.length(), 2)
|
||||
assert_eq((keys[0].2[2], keys[0].2[3]), (30U, 1U))
|
||||
|
||||
// Clicking KB again closes the manually opened OSK.
|
||||
click_module(comp, "osk", 40U)
|
||||
assert_false(comp.osk_is_visible())
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "clicking KB or Rotate panel modules keeps the launcher popup open" {
|
||||
let comp = osk_comp("launcher-keep")
|
||||
load_handset_modules(comp)
|
||||
click_module(comp, "launcher", 10U)
|
||||
assert_true(comp.shell.popup_open())
|
||||
assert_true(comp.osk_is_visible())
|
||||
|
||||
let (hx, hy) = comp.osk_key_center("Hide").unwrap()
|
||||
click_at(comp, hx, hy, 20U)
|
||||
assert_false(comp.osk_is_visible())
|
||||
assert_true(comp.shell.popup_open())
|
||||
|
||||
// Tapping Rotate leaves the Launcher popup open and does not accidentally reopen the OSK.
|
||||
click_module(comp, "rotate", 30U)
|
||||
assert_true(comp.shell.popup_open())
|
||||
assert_false(comp.osk_is_visible())
|
||||
assert_eq(comp.take_pending_rotation(), Some(1))
|
||||
|
||||
// Tapping KB opens the OSK while keeping the Launcher popup open above it.
|
||||
click_module(comp, "osk", 40U)
|
||||
assert_true(comp.shell.popup_open())
|
||||
assert_true(comp.osk_is_visible())
|
||||
let pr = comp.shell.open_popup_rect().unwrap()
|
||||
assert_true(pr.y + pr.h <= comp.osk_rect().y)
|
||||
comp.close()
|
||||
}
|
||||
Reference in new issue
Block a user