Add a built-in on-screen keyboard for handset sessions
CI / test (push) Failing after 52s

- Opens for text-input-v3 fields, terminals, launcher search, Network password, emoji picker and the password dialog; a KB pill summons it manually.
- Enabled on CHASSIS=handset; CHANDRA_OSK=1|0 overrides, and it stays off under CHANDRA_TEST_CONFIG.
- Work area and panel popups shrink above the keyboard so focused content stays visible.
- Keys send evdev codes with Shift, Ctrl and Alt modifiers.
- chandra-ctl: `screenshot [PATH]` saves a PNG without opening the editor.
- Key names cover the full punctuation set and shifted symbols.
- Launcher plasmoid min width drops from 60 to 36.
This commit is contained in:
nandi committed 2026-11-28 00:18:32 -08:00
1 parent 1205329abd
commit 905dab8725
21 files changed
+1335 -68

No files matched your search

+5 -2
View File
@@ -32,9 +32,12 @@ fn read_battery_polled() -> BatteryInfo {
b
}
///| Names Linux gives batteries (ACPI, Apple, Chromebooks, many ARM boards). The tree is not listed:
///| Names Linux gives batteries (ACPI, Apple, Qualcomm/ARM fuel gauges). The tree is not listed:
/// a lookup of each name keeps this to plain file reads, which every host serves.
let battery_names : Array[String] = ["BAT0", "BAT1", "BAT2", "BATT", "BATC", "CMB0", "CMB1", "battery"]
let battery_names : Array[String] = [
"BAT0", "BAT1", "BAT2", "BATT", "BATC", "CMB0", "CMB1", "battery", "bq27411-0", "qcom-battery",
"bms", "max170xx_battery", "axp20x-battery", "rk817-battery",
]
///| The `battery.status` record: state is the `charge-state` index (0 none, 1 discharging,
/// 2 charging, 3 full, 4 not charging).
+20 -3
View File
@@ -24,8 +24,25 @@ pub let wallpaper_desktop : String = "wallpaper"
///|
pub let clock_card_desktop : String = "clock-card"
///| What fills a fresh session's desktop: the clock card, as before desktop modules.
let default_desktop : String = "clock-card"
///|
pub let icon_desktop : String = "icon-desktop"
///| Default desktop choice for a fresh session: Icon Desktop on handsets (or
/// CHANDRA_DEFAULT_DESKTOP when set), otherwise the clock card. Tests keep the clock card.
pub fn default_desktop_id() -> String {
if @sys.getenv("CHANDRA_TEST_CONFIG") != "" {
return clock_card_desktop
}
let env = @sys.getenv("CHANDRA_DEFAULT_DESKTOP")
if env.length() > 0 {
return env
}
let info = @utf8.decode_lossy(@sys.read_file_bytes("/etc/machine-info"))
if info.contains("CHASSIS=handset") {
return icon_desktop
}
clock_card_desktop
}
///| A module's frame request is capped at this (ms): a module can't put itself to sleep for
/// hours by mistake and miss its own animation.
@@ -81,7 +98,7 @@ fn DesktopShell::write_desktop_choice(self : DesktopShell) -> Unit {
_ => entries.push(e)
}
}
if self.desk_choice != default_desktop {
if self.desk_choice != default_desktop_id() {
entries.push((@edn.Value::Keyword("desktop"), @edn.Value::Text(self.desk_choice)))
}
write_state_file(entries)
+35 -1
View File
@@ -416,6 +416,8 @@ pub(all) struct DesktopShell {
desk_saved : Map[String, String]
/// The menu's top edge when it opens at the pointer (the desktop menu); -1 above the panel.
mut menu_anchor_y : Int
/// Extra bottom inset reserved for panel popups (e.g. an open on-screen keyboard).
mut popup_bottom_inset : Int
}
///|
@@ -538,7 +540,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
wit_cache: {},
recents: [],
launcher_state: @launcher.State::new(),
desk_choice: default_desktop,
desk_choice: default_desktop_id(),
desk_choice_read: false,
desk_mod: None,
desk_backdrop: 0,
@@ -554,6 +556,7 @@ pub fn DesktopShell::new(display : String) -> DesktopShell {
desk_covered: false,
desk_saved: {},
menu_anchor_y: -1,
popup_bottom_inset: 0,
}
sh.order_apps()
sh
@@ -681,6 +684,37 @@ fn DesktopShell::open_popup_widget(self : DesktopShell) -> Widget? {
None
}
///| The module id of the currently open panel popup, or "" when none (or only the menu is open).
pub fn DesktopShell::open_popup_module_id(self : DesktopShell) -> String {
match self.open_popup_widget() {
Some(w) => w.module_id
None => ""
}
}
///| The screen rectangle of the currently open panel popup, if any.
pub fn DesktopShell::open_popup_rect(self : DesktopShell) -> @scene.Rect? {
match self.open_popup_widget() {
Some(w) if w.popup_rect.w > 0 => Some(w.popup_rect)
_ => None
}
}
///| Reserve extra room at the bottom for popups (e.g. an open on-screen keyboard) and
/// reposition any open popup above it.
pub fn DesktopShell::set_popup_bottom_inset(self : DesktopShell, inset : Int) -> Unit {
let v = if inset > 0 { inset } else { 0 }
if self.popup_bottom_inset == v {
return
}
self.popup_bottom_inset = v
for w in self.widgets.copy() {
if w.popup_rect.w > 0 {
self.refresh_popup(w)
}
}
}
///|
fn DesktopShell::widget_at(self : DesktopShell, x : Int, y : Int) -> Widget? {
for w in self.widgets {
+38 -3
View File
@@ -34,6 +34,20 @@ fn fresh_panel(has_battery : Bool) -> Array[String] {
out
}
///| Compact default panel for handsets (omits desktop-only inspector, tiling toggle, and moon
/// disc so the dock, launcher, settings, Wi-Fi, battery, clock, and screenshot have room).
let handset_panel : Array[String] = [
"launcher", "dock", "session-settings", "network", "battery", "clock-digital", "screenshot",
]
///| Whether a fresh session runs on a handset chassis (tests keep the desktop layout).
fn is_handset_panel() -> Bool {
if @sys.getenv("CHANDRA_TEST_CONFIG") != "" {
return false
}
@utf8.decode_lossy(@sys.read_file_bytes("/etc/machine-info")).contains("CHASSIS=handset")
}
///|
test "a fresh panel gets the battery module only on a machine with a battery" {
assert_false(fresh_panel(false).contains("battery"))
@@ -189,12 +203,23 @@ fn DesktopShell::panel_slots(self : DesktopShell) -> Array[@panel.SlotIn] {
first_stretch = i
}
}
let compact = self.screen_w > 0 && self.screen_w < 720
let out : Array[@panel.SlotIn] = []
for i = 0; i < self.widgets.length(); i = i + 1 {
let w = self.widgets[i]
let base_w = self.dock_width(w).unwrap_or(w.pl.pref_w)
let pref_w = if compact &&
(w.module_id == "launcher" ||
w.module_id == "session-settings" ||
w.module_id == "network" ||
w.module_id == "screenshot") {
36
} else {
base_w
}
out.push({
id: w.slot,
pref_w: self.dock_width(w).unwrap_or(w.pl.pref_w),
pref_w,
pref_h: w.pl.pref_h,
min_w: w.pl.min_w,
stretch: w.pl.stretch,
@@ -337,7 +362,12 @@ fn DesktopShell::ensure_booted(self : DesktopShell) -> Unit {
let saved = self.load_panel_config()
let entries = match saved {
Some(e) => migrate_panel(e)
None => fresh_panel(read_battery().state != 0)
None =>
if is_handset_panel() {
handset_panel
} else {
fresh_panel(read_battery().state != 0)
}
}
match saved {
Some(old) if saved_panel_version() < panel_version => {
@@ -972,7 +1002,12 @@ fn DesktopShell::refresh_popup(self : DesktopShell, w : Widget) -> Unit {
w.popup_hot = false
}
Some(ps) => {
let (px, py) = @panel.popup_position(self.screen_w, self.screen_h - self.panel_h, w.rect.x, ps.w, ps.h, 6)
let bottom = if self.popup_bottom_inset > self.panel_h {
self.popup_bottom_inset
} else {
self.panel_h
}
let (px, py) = @panel.popup_position(self.screen_w, self.screen_h - bottom, w.rect.x, ps.w, ps.h, 6)
w.popup_rect = { x: px, y: py, w: ps.w, h: ps.h }
w.popup_ops = ps.ops
if !was_open {