Commit a65af25
fix: autorotate-iio: fix D-Bus events not processed when display is idle (#337)
* fix: autorotate-iio: fix D-Bus events not processed when display is idle
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.
* fix code style to pass uncrustify CI check
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 8d73a10 commit a65af25
1 file changed
Lines changed: 83 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
108 | 115 | | |
109 | 116 | | |
110 | 117 | | |
| |||
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
157 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
158 | 169 | | |
| 170 | + | |
159 | 171 | | |
160 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
| |||
185 | 200 | | |
186 | 201 | | |
187 | 202 | | |
188 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
189 | 207 | | |
190 | 208 | | |
191 | 209 | | |
| |||
210 | 228 | | |
211 | 229 | | |
212 | 230 | | |
| 231 | + | |
213 | 232 | | |
214 | 233 | | |
215 | 234 | | |
| |||
228 | 247 | | |
229 | 248 | | |
230 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
231 | 255 | | |
232 | 256 | | |
233 | 257 | | |
| |||
238 | 262 | | |
239 | 263 | | |
240 | 264 | | |
241 | | - | |
| 265 | + | |
242 | 266 | | |
243 | | - | |
244 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
245 | 314 | | |
246 | 315 | | |
247 | 316 | | |
| |||
259 | 328 | | |
260 | 329 | | |
261 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
262 | 337 | | |
263 | 338 | | |
264 | 339 | | |
265 | 340 | | |
266 | 341 | | |
267 | 342 | | |
268 | | - | |
| 343 | + | |
| 344 | + | |
269 | 345 | | |
270 | 346 | | |
271 | 347 | | |
| |||
0 commit comments