CI / test (push) Failing after 52s
- 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
46 lines
1.2 KiB
MoonBit
46 lines
1.2 KiB
MoonBit
///| Implementation of `chandra:desktop/plasmoid` for the on-screen keyboard toggle ("KB"):
|
|
/// a compact panel button that shows or hides the built-in OSK.
|
|
|
|
///|
|
|
pub fn info() -> PlasmoidInfo {
|
|
{
|
|
id: "org.chandra.osk",
|
|
name: "Keyboard",
|
|
preferred: { w: 44, h: 34 },
|
|
min_width: 34,
|
|
stretch: false,
|
|
}
|
|
}
|
|
|
|
///|
|
|
pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
|
|
let t = @theme.get_tokens()
|
|
let w = size.w.reinterpret_as_int()
|
|
let h = size.h.reinterpret_as_int()
|
|
let on = @osk.is_visible()
|
|
let bg = if on { t.palette.accent } else { t.palette.surface_hover }
|
|
let fg = if on { t.palette.accent_foreground } else { t.palette.foreground }
|
|
let fs = t.font_size.reinterpret_as_int()
|
|
let kfs = if fs - 2 < 10 { 10 } else { fs - 2 }
|
|
[
|
|
@ui.fill_rect(@ui.rect(0, 0, w, h), bg, radius=t.radius.reinterpret_as_int()),
|
|
@ui.text(w / 2, h / 2, "KB", kfs, fg, align=CENTER, bold=true),
|
|
]
|
|
}
|
|
|
|
///|
|
|
pub fn popup() -> PopupSurface? {
|
|
None
|
|
}
|
|
|
|
///|
|
|
pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
|
|
match (target, event) {
|
|
(WIDGET, PointerDown(_)) => {
|
|
@osk.set_visible(!@osk.is_visible())
|
|
true
|
|
}
|
|
_ => false
|
|
}
|
|
}
|