1
0
mirror of https://github.com/Cloudef/bemenu synced 2024-11-23 09:21:59 +01:00

Fix missed renders on Wayland on temporally close events

Despite the fix in the previous commit (3d7e47c4e6), the following command:
    { echo one; echo two; } | BEMENU_BACKEND=wayland bemenu --grab
Will likely still show the 'Loading...' text after all items are available.

A related problem (also on Wayland) is that when pressing two keys (for the
filter) almost simultaneously, sometimes only one of the keys will be rendered.
The other key will only be shown on the next render. For example:
    - Filter shows "s"
    - User presses the "o" and "n" keys simultaneously
    - Filter shows "so" ["n" appears to have been lost]
    - User presses the "g" key
    - Filter shows "song" [now the "n" has been rendered]

Both problems have the same root cause: If two events that cause a render happen
"close enough" to each other, often the second event will not cause a render.

As far as I can tell, the cause is that the "dirty && render_pending" render
check should not check the dirty flag at all, just "render_pending".

With "dirty && render_pending", if two events happen in close succession:
- On the first event, generally dirty==true, render_pending==true, a render
  will happen, the frame callback will be set, and both flags will be cleared.
- For the second event, generally dirty==true and render_pending==false.
  dirty will be unset and nothing will happen.
- When the frame triggers, render_pending is set, but no render will happen
  because dirty==false

With just "render_pending" (the change in this commit):
- On the first event, generally dirty==true, render_pending==false, the frame
  callback will be set, and dirty will be cleared.
- For the second event, generally dirty==true and render_pending==false.
  dirty will be unset and nothing will happen.
- When the frame triggers, render_pending is set, then a render will be done.
This commit is contained in:
Joan Bruguera 2022-06-29 00:24:12 +02:00 committed by Jari Vetoniemi
parent 6e74133876
commit c7a5812352

@ -26,7 +26,7 @@ render(struct bm_menu *menu)
struct window *window;
wl_list_for_each(window, &wayland->windows, link) {
if (menu->dirty && window->render_pending)
if (window->render_pending)
bm_wl_window_render(window, wayland->display, menu);
}
wl_display_flush(wayland->display);