Skip to content

Commit

Permalink
Fix missed renders on Wayland on temporally close events
Browse files Browse the repository at this point in the history
Despite the fix in the previous commit (3d7e47c), 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.
  • Loading branch information
joanbm authored and Cloudef committed Jun 30, 2022
1 parent 6e74133 commit c7a5812
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/renderers/wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c7a5812

Please sign in to comment.