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

+72
View File
@@ -326,6 +326,9 @@ pub(all) struct ChandraCompositor {
mut osk_pressed : Int?
mut osk_hover : Int?
mut osk_pointer_grab : Bool
/// Output rotation (`0=0`, `1=90 CW`, `2=180 flip`, `3=270 CW`) and pending backend switch.
mut rotation : Int
mut pending_rotation : Int?
}
///|
@@ -475,6 +478,8 @@ pub fn ChandraCompositor::new(
osk_pressed: None,
osk_hover: None,
osk_pointer_grab: false,
rotation: initial_rotation_from_env(),
pending_rotation: None,
}
// Client popups (menus) are placed to stay on screen: the server asks for the output's
// rectangle relative to the parent's content origin when it applies constraint adjustment.
@@ -524,6 +529,72 @@ fn ChandraCompositor::recompute_work_area(self : ChandraCompositor) -> Unit {
self.damage.mark_full()
}
///| Initial display rotation parsed from `CHANDRA_ROTATE` (`0|90|180|270` or `0..3`).
fn initial_rotation_from_env() -> Int {
match @sys.getenv("CHANDRA_ROTATE") {
"90" | "1" => 1
"180" | "2" => 2
"270" | "3" => 3
_ => 0
}
}
///| Queue a display rotation (`0=0`, `1=90 CW`, `2=180 flip`, `3=270 CW`). Applied by the
/// DRM/KMS host loop on the next iteration.
pub fn ChandraCompositor::request_rotation(self : ChandraCompositor, rot : Int) -> Unit {
let r = (rot % 4 + 4) % 4
self.pending_rotation = Some(r)
self.damage.mark_full()
}
///| Rotate the display 90 degrees clockwise.
pub fn ChandraCompositor::rotate_cw(self : ChandraCompositor) -> Unit {
self.request_rotation(self.rotation + 1)
}
///| Rotate the display 90 degrees counter-clockwise.
pub fn ChandraCompositor::rotate_ccw(self : ChandraCompositor) -> Unit {
self.request_rotation(self.rotation + 3)
}
///| Flip the display 180 degrees.
pub fn ChandraCompositor::rotate_flip(self : ChandraCompositor) -> Unit {
self.request_rotation(self.rotation + 2)
}
///| Current output rotation (`0=0`, `1=90`, `2=180`, `3=270`).
pub fn ChandraCompositor::current_rotation(self : ChandraCompositor) -> Int {
self.rotation
}
///| Consume any pending rotation request for the DRM backend.
pub fn ChandraCompositor::take_pending_rotation(self : ChandraCompositor) -> Int? {
match self.pending_rotation {
Some(r) => {
self.pending_rotation = None
self.rotation = r
Some(r)
}
None => None
}
}
///| Apply the new logical `(w, h)` reported by KMS after a rotation; forces a full redraw even
/// when dimensions match (such as a 180-degree flip).
pub fn ChandraCompositor::apply_rotated_size(self : ChandraCompositor, w : Int, h : Int) -> Unit {
if w > 0 && h > 0 && (w != self.output_w || h != self.output_h) {
self.resize(w, h)
}
self.last_frame = None
self.last_sig = None
self.frame_changed = true
self.damage.mark_full()
match self.emoji_ui {
Some(ui) => self.emoji_place(ui)
None => ()
}
}
///| The output changed size (the nested window was resized, maximized or made fullscreen):
/// lay the desktop out for the new size, so nothing is drawn past the edge and cropped away.
pub fn ChandraCompositor::resize(self : ChandraCompositor, w : Int, h : Int) -> Unit {
@@ -963,6 +1034,7 @@ pub fn ChandraCompositor::step(self : ChandraCompositor) -> Unit {
/// a pending screenshot, a toast counting down): the main loop keeps its frame pace then instead
/// of sleeping until an fd wakes it.
pub fn ChandraCompositor::has_timed_work(self : ChandraCompositor) -> Bool {
self.pending_rotation is Some(_) ||
self.rec is Some(_) ||
self.shot_request is Some(_) ||
self.rec_request is Some(_) ||