1
0
mirror of https://github.com/Cloudef/bemenu synced 2024-11-23 09:21:59 +01:00
bemenu/lib
Joan Bruguera 04b0d83d56 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
2022-07-05 10:06:57 +09:00
..
3rdparty Nuke CMake from existance 2020-02-07 16:03:08 +02:00
renderers Fix Wayland event loop order to avoid missed renders 2022-07-05 10:06:57 +09:00
bemenu.h Add option to define a border and border color 2022-06-29 15:13:09 +09:00
filter.c Declare filter_dmenu_fun as static 2020-12-13 17:10:07 +09:00
internal.h Add option to define a border and border color 2022-06-29 15:13:09 +09:00
item.c Refactor code to snake_style, turn renderers into plugins, and start 2014-10-22 22:46:51 +03:00
library.c Nuke CMake from existance 2020-02-07 16:03:08 +02:00
list.c Use sizeof(void*) and fix list remove. 2014-10-25 21:53:48 +03:00
menu.c Fix first render on Wayland after loading items with --grab 2022-06-30 09:40:08 +09:00
util.c get rid of all the internal symbols 2022-02-19 08:00:26 +09:00