Gate accelerometer auto-rotation on tablet mode (X11 + Wayland)#832
Gate accelerometer auto-rotation on tablet mode (X11 + Wayland)#832ggiesen wants to merge 1 commit into
Conversation
…and) Muffin auto-rotates the built-in panel from the accelerometer (MetaOrientationManager + MetaMonitorManager) whenever orientation-lock is off, but it never checks whether the device is folded into tablet mode, so it rotates in laptop/clamshell posture too. Gate apply_orientation() on ClutterSeat:touch-mode (true only when a touchscreen is present and the device is in tablet mode or has no tablet-mode switch), honouring a new org.cinnamon.settings-daemon.peripherals.touchscreen disable-rotation-in-laptop-mode key. Also honour orientation-lock on the touch-mode / setting-change paths (MetaOrientationManager only emits while unlocked, but the new handlers call the apply path directly). Add meta_orientation_manager_get_orientation_lock(). The native/Wayland backend already exposes touch-mode from libinput. The X11 backend had no source for SW_TABLET_MODE, so meta-seat-x11.c now reads the evdev switch directly (found by capability, with GUdev hot-plug recovery and a bounded login-ACL-race retry) and folds it into touch-mode, so the same gate works under X11. Issue: linuxmint/cinnamon#10697
|
Companion PRs now open: schema key in cinnamon-settings-daemon#463, and the Display Automatic screen rotation combobox in cinnamon#13826 (the UI @mtwebster suggested in linuxmint/cinnamon#10697). The three go together. |
|
Field-testing note (no code changes - recording behaviour on a second platform). I've tested this on two HP convertibles, both Linux Mint / X11:
Caveat worth documenting: "Tablet mode only" gates correctly only where the hardware exposes a real fold switch. On a machine without one it cannot distinguish laptop from tablet, so the right thing is to err toward rotating - i.e. use "Enabled", which bypasses the gate entirely (the same escape-hatch role as KWin/KScreen's tri-state Always). On no-reliable-sensor hardware Tablet mode only effectively degrades to Enabled/Always behaviour, which is the desired failure direction. I specifically do not recommend For completeness: I considered and rejected compositor-side heuristics to auto-detect bad switches - "rotate until the switch toggles" would reintroduce laptop-mode rotation at every cold boot, and persisting a "proven" flag adds state yet still wouldn't fix the orientation-coupled case (that switch does toggle). The stateless read here mirrors the native/libinput backend, so no change is warranted. |
What
Cinnamon already auto-rotates the built-in panel from the accelerometer (Muffin's
MetaOrientationManager+MetaMonitorManager), gated only byorientation-lock. On a convertible that means it rotates in every posture — it never checks the tablet-mode switch, so the screen flips while the device is used as a laptop.This gates auto-rotation on tablet mode:
apply_orientation()now consultsClutterSeat:touch-mode(true only when a touchscreen is present and the device is in tablet mode or has no tablet-mode switch) plus a newdisable-rotation-in-laptop-modekey, and honoursorientation-lockon the touch-mode / setting-change paths.touch-modefrom libinput. The X11 backend had no source forSW_TABLET_MODE, someta-seat-x11.cnow reads the evdev switch directly (by capability, with hot-plug recovery and the login-ACL race handled) and folds it intotouch-mode— so the same gate works under X11, where Cinnamon mostly runs today.Devices with no tablet-mode switch (slates) are unaffected —
touch-modeis true, so they keep auto-rotating.Context / prior art
This is the feature from #10697 (cinnamon) / cinnamon-settings-daemon#359. The earlier PRs — cinnamon#10708 and cinnamon-settings-daemon#361 — implemented it in the csd orientation plugin, which was being removed as the orientation work moved into Muffin (the reason they were closed). This does it in Muffin, where rotation now lives.
Two small companion changes are needed (happy to open as linked PRs):
disable-rotation-in-laptop-mode(bool, defaulttrue) to the…peripherals.touchscreenschema (5 lines).uaccessudev rule so Muffin can read the switch as the session user (rule included in the companion repo below).Validation
Built as patched packages and dogfooded on an HP ZBook Studio x360 G5 (Mint 22.3, Cinnamon 6.6.7, Muffin 6.6.3, X11): rotation and tablet-mode gating handled entirely by Muffin, no external daemon. Rebased onto and applies cleanly to
master(6.7.3). Full patch set, udev rule, and build notes: https://gitlab.com/ggiesen/cinnamon-autorotateFeedback welcome
This is a proposal as much as a patch — happy to take feedback or change direction on any of it: the combobox-vs-toggle UX, the key name/layout, splitting the X11 seat change into its own commit, or sending the Wayland-gating part upstream to GNOME Mutter as well. Just point me at what fits Cinnamon best.