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

Fix first render on Wayland after loading items with --grab

Currently, on the Wayland backend, the following command:
    { echo one; sleep 1; echo two; } | BEMENU_BACKEND=wayland bemenu --grab
Will keep showing the 'Loading...' text even after all items are available.
The items will only be shown after some input, e.g. a key press, happens.

This was a regression introduced by 5a095705d2878be423311fbfe5258fdcf9253c8e
(versions 0.6.5+). A dirty flag was added to avoid unnecessary redraws,
however, this flag is not reset between the renders before/after the items are
loaded, so the bm_menu_render call after the items are loaded is ignored
(on Wayland, which is the only renderer that currently uses the dirty flag).

Fix the issue by setting the dirty flag when the filter changes, so it will be
reset when changing from "Loading..." to empty and cause a redraw.
This commit is contained in:
Joan Bruguera 2022-06-28 23:34:53 +02:00 committed by Jari Vetoniemi
parent 8c1c29c0b9
commit 6e74133876

@ -177,10 +177,14 @@ bm_menu_set_filter(struct bm_menu *menu, const char *filter)
{
assert(menu);
if (strcmp(menu->filter ? menu->filter : "", filter ? filter : ""))
menu->dirty = true;
free(menu->filter);
menu->filter_size = (filter ? strlen(filter) : 0);
menu->filter = (menu->filter_size > 0 ? bm_strdup(filter) : NULL);
menu->curses_cursor = (menu->filter ? bm_utf8_string_screen_width(menu->filter) : 0);
menu->dirty |= (menu->cursor != menu->filter_size);
menu->cursor = menu->filter_size;
}