Skip to content
Myr

main: fix --auto-select combined with --search

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This fixes an issue where --auto-select in combination with --search did not exit automatically when --search resulted in a single item. Handle both dmenu and application mode in the same way, by triggering the check after all entries have been loaded, and the match result has been updated. Add wayl_check_auto_select() for this purpose. This function is only used for this corner case, and not when checking auto-select after a key press, since it's inferior - we don't have an associated seat. Instead, this function always uses the "first" seat, whatever that is. For all of this to work, wayl_check_auto_select() must cancel the pending wayland socket read; executing an application (i.e. in application mode), causes fuzzel to try to receive an XDG activation token. This requires a wayland roundtrip. This doesn't work when wl_display_prepare_read() is active. Which it is, unless we're in an fdm_handler() callchain. And in this case we're not. Hence we must cancel it, and then re-enable it. This also means wayl_check_auto_select() *must not* be called from within an fdm_handler() callchain. Closes #633

authored by Daniel Eklöf · committed by Daniel Eklöf · parent c9ab144 · Browse files · 3 files+43 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+43 added−7 removed

  • other:+43 added−7 removed

3 files+43 added−7 removed

modified:main.c+4 added
735 unmodified lines
736 return false;737 }738739 wayl_refresh(wayl);740741 if (event == EVENT_APPS_ALL_LOADED)742 wayl_check_auto_select(wayl);743744 return true;745}746747/*
1536 unmodified lines
modified:wayland.c+37 added-7 removed
586 unmodified lines
587 }588 return false;589}590591/*592 * NOTE: this function is expected to be called from an outside593 * context. It MUST NOT be called while inside a fdm_handler()594 * callchain */595bool596wayl_check_auto_select(struct wayland *wayl)597{598 if (tll_length(wayl->seats) == 0)599 return false;600601 struct seat *seat = &tll_front(wayl->seats);602603 /*604 * This is finicky... check_auto_select() _may_ result in an605 * application being executed.606 *607 * Part of this involves retrieving and XDG activation token. This608 * requires a display roundtrip. The roundtrip will *not* work609 * wl_display_prepare_read() is active.610 *611 * So, we need to cancel the pending read, do our thing, and then612 * re-endter prepare_read().613 *614 * This will *not* work if wl_display_prepare_read() is *not*615 * active, hence the warning above, that this function must not be616 * called while inside an fdm_handler() callchain, since617 * fdm_handler() does read from the wayland socket.618 */619 wl_display_cancel_read(wayl->display);620 bool ret = check_auto_select(seat, true);621 wl_display_prepare_read(wayl->display);622 return ret;623}624625static void626execute_selected(struct seat *seat, bool as_is, int custom_success_exit_code)627{628 struct wayland *wayl = seat->wayl;
367 unmodified lines
996 {997 if (refresh)998 wayl_refresh(wayl);999966 /* Check for auto-select after key binding execution */967 if (refresh && wayl->conf->auto_select) {968 if (matches_get_total_count(wayl->matches) == 1) {969 execute_selected(seat, false, -1);970 goto maybe_repeat;971 }972 }1000 if (check_auto_select(seat, refresh))1001 goto maybe_repeat;10021003 goto maybe_repeat;1004 }1005 }
1475 unmodified lines
2481 goto skip_list;2482 }2483 }2484 render_match_list(wayl->render, buf, wayl->prompt, wayl->matches);24852486skip_list:2487 matches_unlock(wayl->matches);24882489#if defined(FUZZEL_ENABLE_CAIRO)
568 unmodified lines
modified:wayland.h+2 added
104 unmodified lines
105106bool wayl_do_linear_blending(const struct wayland *wayl);107108void wayl_resized(struct wayland *wayl);109110bool wayl_check_auto_select(struct wayland *wayl);