fix: autorotate-iio: fix D-Bus events not processed when display is idle#337
Merged
soreau merged 2 commits intoWayfireWM:masterfrom Apr 23, 2026
Merged
Conversation
The plugin used an OUTPUT_EFFECT_PRE hook (on_frame) to pump the GLib main context. This hook only fires while the compositor is actively rendering frames for that output. When the display is idle — no damaged windows, no animations — no frames are rendered, so GLib's main context never runs and property-change signals from iio-sensor-proxy queue up unprocessed. Rotation stops working until something triggers a redraw (e.g. an active terminal window causes continuous repaints). Fix: replace on_frame with a wl_event_loop_add_timer(50ms) wired into the Wayland event loop via wl_display_get_event_loop(). This pumps the GLib main context at a steady rate regardless of display activity. Additional fixes: - Guard against a null Glib::Variant from get_cached_property() when the D-Bus proxy cache is not yet populated; calling .get() on an uninitialized Variant crashes the compositor. - Call update_orientation() immediately after ClaimAccelerometer so the initial device orientation is applied without waiting for a change event. - Add an asymmetric debounce state machine to handle noisy sensors: 500ms to commit a rotation, 1200ms to return to normal. The longer normal timeout prevents the screen from flipping back during the brief "normal" readings that occur mid-rotation on some hardware. The rotation timer is not reset on subsequent non-normal readings so the delay is measured from the first reading, not the last.
Member
|
@borisi1 Thank you for the detailed issue report and pull request. You can find a diff to fix the code style in the CI output, then we can merge your work. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
LGTM, Thanks. |
Member
|
In the kernel per https://docs.kernel.org/process/coding-assistants.html the format for AI attributions is as follows: Format: Example: I think it makes sense to use the same convention. Thanks to @benjamin-otte for pointing this out. |
Member
|
@borisi1 The last comment is only for informational purposes going forward. Feel free to ignore it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #336.
Problem
The plugin drove the GLib main context from an
OUTPUT_EFFECT_PREhook that only fires while the compositor renders frames. When the display is idle, no frames render, GLib never runs, andiio-sensor-proxyproperty-change signals queue up unprocessed — rotation silently stops working.Changes
Main fix: Replace
on_frame/OUTPUT_EFFECT_PREwith awl_event_loop_add_timer(50ms)on the Wayland event loop (wl_display_get_event_loop(wf::get_core().display)). This pumps the GLib main context at a steady rate regardless of display activity.Null-guard on
Glib::Variant:get_cached_property()may leave the variant uninitialized if the D-Bus proxy cache is not yet populated. Calling.get()on it crashes the compositor.Call
update_orientation()afterClaimAccelerometer: Without this the plugin only reacts to orientation changes — it never reads the current orientation at startup.Asymmetric debounce state machine: Some accelerometers oscillate between the target orientation and "normal" during a physical rotation, resetting the debounce timer on each reading and delaying rotation by 15–20 seconds. The fix:
Testing
Tested on Lenovo Yoga 9 14IRP8 (Intel Iris Xe, eDP-1 @ 3840×2400 scale 2.4), CachyOS, kernel 7.0.0-1-cachyos, wayfire-git r110, wlroots 0.20, iio-sensor-proxy 3.x.