Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Wayland event loop order to avoid missed renders
After the changes of the previous commit, the event loop flow on Wayland is: 1. Render windows if window->render_pending is set 2. Wait for events [NOTE: this includes the frame callback] 3. Schedule render if menu->dirty is set 4. Handle events (return from render) and repeat This can still miss renders since the menu->dirty flag is set in step (4), but the menu->dirty flag is checked in step (3). So if the event loop only does a single iteration (quite unusual as most user actions cause multiple events), we can get stuck on step (2) for a while. In order to avoid this problem, this changes the event loop order to: 1. Schedule render if menu->dirty is set 2. Wait for events [NOTE: this includes the frame callback] 3. Render windows if window->render_pending is set 4. Handle events (return from render) and repeat Script (for Sway) to reproduce the issue / verify the fix: #!/usr/bin/env sh mousesety() { swaymsg seat - cursor set 200 "$1" >/dev/null; sleep 0.2; } { while true; do mousesety 200; mousesety 300; mousesety 400; done } & trap 'kill $!' EXIT export BEMENU_BACKEND=wayland BEMENU_OPTS='--list 40 --hb #0000FF' yes | head -30 | bemenu Fixes: #274 Fixes: #275
- Loading branch information