Add display rotation: Rot pill, chandra-ctl rotate, sensor auto-rotate
CI / test (push) Failing after 51s

- Rotate the display 0/90/180/270 degrees in the KMS host, with scanout and libinput touch/pointer coordinates transformed to match
- Add a touch "Rot" pill beside "KB": tap turns 90 CW, long-press or right-click flips 180
- Add `chandra-ctl rotate [cw|ccw|flip|0|90|180|270|status]`; CHANDRA_ROTATE sets the initial orientation
- Add session/chandra-auto-rotate, which follows iio-sensor-proxy orientation (disable with CHANDRA_AUTO_ROTATE=0)
- Advertise window_menu, maximize, fullscreen and minimize via xdg_toplevel.wm_capabilities (xdg_wm_base v5+)
- Add docs/handset.md covering handset touch, scaling, OSK and rotation
This commit is contained in:
nandi committed 2026-11-28 00:39:24 -08:00
1 parent 905dab8725
commit 2e00009c79
21 files changed
+669 -63

No files matched your search

+75 -28
View File
@@ -118,6 +118,13 @@ pub fn ChandraCompositor::osk_toggle_rect(self : ChandraCompositor) -> @scene.Re
@scene.Rect::new(x, y, w, h)
}
///| Compact "Rot" pill beside the "KB" pill: tap rotates 90 deg CW, long-press/right-click flips 180 deg.
pub fn ChandraCompositor::osk_rotate_rect(self : ChandraCompositor) -> @scene.Rect {
let kb = self.osk_toggle_rect()
let w = 44
@scene.Rect::new((kb.x - w - 6).max(4), kb.y, w, kb.h)
}
///| Show or hide the OSK, resizing `work_area` and lifting panel popups so focused content stays
/// above the keyboard.
fn ChandraCompositor::osk_set_visible(self : ChandraCompositor, want : Bool) -> Unit {
@@ -429,7 +436,7 @@ fn ChandraCompositor::osk_key_at(self : ChandraCompositor, x : Int, y : Int) ->
None
}
///| Whether `(x, y)` hits either the open OSK or its compact reopen pill.
///| Whether `(x, y)` hits either the open OSK or its compact corner pills ("Rot" / "KB").
fn ChandraCompositor::osk_hit_any(self : ChandraCompositor, x : Int, y : Int) -> Bool {
if !self.osk_enabled {
return false
@@ -437,7 +444,8 @@ fn ChandraCompositor::osk_hit_any(self : ChandraCompositor, x : Int, y : Int) ->
if self.osk_visible {
self.osk_rect().contains(x, y)
} else {
!self.kiosk_strict() && self.osk_toggle_rect().contains(x, y)
!self.kiosk_strict() &&
(self.osk_toggle_rect().contains(x, y) || self.osk_rotate_rect().contains(x, y))
}
}
@@ -578,16 +586,31 @@ fn ChandraCompositor::osk_input(
}
return false
}
if !self.kiosk_strict() && self.osk_toggle_rect().contains(xi, yi) {
if self.osk_hover != Some(-1) {
self.osk_hover = Some(-1)
self.damage.mark_full()
if !self.kiosk_strict() {
let hover = if self.osk_toggle_rect().contains(xi, yi) {
Some(-1)
} else if self.osk_rotate_rect().contains(xi, yi) {
Some(-2)
} else {
None
}
match hover {
Some(id) => {
if self.osk_hover != Some(id) {
self.osk_hover = Some(id)
self.damage.mark_full()
}
return true
}
None =>
if self.osk_hover == Some(-1) || self.osk_hover == Some(-2) {
self.osk_hover = None
self.damage.mark_full()
}
}
if self.osk_pointer_grab {
return true
}
return true
}
if self.osk_hover == Some(-1) {
self.osk_hover = None
self.damage.mark_full()
}
false
}
@@ -606,6 +629,10 @@ fn ChandraCompositor::osk_input(
self.osk_manual_show = true
self.osk_sync()
}
Some(-2) =>
if !self.osk_visible && !self.kiosk_strict() && self.osk_rotate_rect().contains(xi, yi) {
self.rotate_cw()
}
Some(idx) =>
if self.osk_visible && self.osk_key_at(xi, yi) == Some(idx) {
self.osk_activate_key(idx, time_ms)
@@ -623,13 +650,30 @@ fn ChandraCompositor::osk_input(
}
return true
}
if !self.osk_visible && !self.kiosk_strict() && self.osk_toggle_rect().contains(xi, yi) {
if button == 272U && pressed {
self.osk_pointer_grab = true
self.osk_pressed = Some(-1)
self.damage.mark_full()
if !self.osk_visible && !self.kiosk_strict() {
let pill = if self.osk_toggle_rect().contains(xi, yi) {
Some(-1)
} else if self.osk_rotate_rect().contains(xi, yi) {
Some(-2)
} else {
None
}
match pill {
Some(id) => {
if pressed {
if button == 272U {
self.osk_pointer_grab = true
self.osk_pressed = Some(id)
self.damage.mark_full()
} else if button == 273U && id == -2 {
// Long-press / right-click on Rot flips 180 degrees.
self.rotate_flip()
}
}
return true
}
None => ()
}
return true
}
false
}
@@ -658,18 +702,21 @@ fn ChandraCompositor::osk_ops(self : ChandraCompositor) -> Array[@scene.DrawOp]
if self.kiosk_strict() {
return ops
}
let tr = self.osk_toggle_rect()
let bg = if self.osk_pressed == Some(-1) {
pal.accent
} else if self.osk_hover == Some(-1) {
pal.surface_hover
} else {
@scene.Rgba::new(pal.surface_popup.r.to_int(), pal.surface_popup.g.to_int(), pal.surface_popup.b.to_int(), 230)
let pills = [(self.osk_rotate_rect(), -2, "Rot"), (self.osk_toggle_rect(), -1, "KB")]
for pill in pills {
let (tr, id, label) = pill
let bg = if self.osk_pressed == Some(id) {
pal.accent
} else if self.osk_hover == Some(id) {
pal.surface_hover
} else {
@scene.Rgba::new(pal.surface_popup.r.to_int(), pal.surface_popup.g.to_int(), pal.surface_popup.b.to_int(), 230)
}
let fg = if self.osk_pressed == Some(id) { pal.accent_foreground } else { pal.foreground }
ops.push(@scene.DrawOp::FillRect(tr, bg, rad + 4))
ops.push(@scene.DrawOp::StrokeRect(tr, pal.border, 1, rad + 4))
ops.push(@scene.DrawOp::Text(tr.x + tr.w / 2, tr.y + tr.h / 2, label, (fs - 2).max(10), fg, @scene.TextAlign::Center, true))
}
let fg = if self.osk_pressed == Some(-1) { pal.accent_foreground } else { pal.foreground }
ops.push(@scene.DrawOp::FillRect(tr, bg, rad + 4))
ops.push(@scene.DrawOp::StrokeRect(tr, pal.border, 1, rad + 4))
ops.push(@scene.DrawOp::Text(tr.x + tr.w / 2, tr.y + tr.h / 2, "KB", (fs - 2).max(10), fg, @scene.TextAlign::Center, true))
return ops
}
let r = self.osk_rect()