mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-06 01:40:22 -05:00
search: don't destroy/recreate search (sub)surface
Create the sub-surface once, at startup. Then, instead of destroying it when committing/cancelling a search, unmap it (by attaching a NULL buffer to it).
This commit is contained in:
parent
2c3ab701e7
commit
1e4b11b0fa
2 changed files with 9 additions and 27 deletions
7
main.c
7
main.c
|
|
@ -723,6 +723,7 @@ main(int argc, char *const *argv)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Main window */
|
||||||
term.wl.surface = wl_compositor_create_surface(term.wl.compositor);
|
term.wl.surface = wl_compositor_create_surface(term.wl.compositor);
|
||||||
if (term.wl.surface == NULL) {
|
if (term.wl.surface == NULL) {
|
||||||
LOG_ERR("failed to create wayland surface");
|
LOG_ERR("failed to create wayland surface");
|
||||||
|
|
@ -740,6 +741,12 @@ main(int argc, char *const *argv)
|
||||||
xdg_toplevel_set_app_id(term.wl.xdg_toplevel, "foot");
|
xdg_toplevel_set_app_id(term.wl.xdg_toplevel, "foot");
|
||||||
term_set_window_title(&term, "foot");
|
term_set_window_title(&term, "foot");
|
||||||
|
|
||||||
|
/* Scrollback search box */
|
||||||
|
term.wl.search_surface = wl_compositor_create_surface(term.wl.compositor);
|
||||||
|
term.wl.search_sub_surface = wl_subcompositor_get_subsurface(
|
||||||
|
term.wl.sub_compositor, term.wl.search_surface, term.wl.surface);
|
||||||
|
wl_subsurface_set_desync(term.wl.search_sub_surface);
|
||||||
|
|
||||||
wl_surface_commit(term.wl.surface);
|
wl_surface_commit(term.wl.surface);
|
||||||
wl_display_roundtrip(term.wl.display);
|
wl_display_roundtrip(term.wl.display);
|
||||||
|
|
||||||
|
|
|
||||||
29
search.c
29
search.c
|
|
@ -18,14 +18,8 @@
|
||||||
static void
|
static void
|
||||||
search_cancel_keep_selection(struct terminal *term)
|
search_cancel_keep_selection(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->wl.search_sub_surface != NULL) {
|
wl_surface_attach(term->wl.search_surface, NULL, 0, 0);
|
||||||
wl_subsurface_destroy(term->wl.search_sub_surface);
|
wl_surface_commit(term->wl.search_surface);
|
||||||
term->wl.search_sub_surface = NULL;
|
|
||||||
}
|
|
||||||
if (term->wl.search_surface != NULL) {
|
|
||||||
wl_surface_destroy(term->wl.search_surface);
|
|
||||||
term->wl.search_surface = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(term->search.buf);
|
free(term->search.buf);
|
||||||
term->search.buf = NULL;
|
term->search.buf = NULL;
|
||||||
|
|
@ -50,25 +44,6 @@ search_begin(struct terminal *term)
|
||||||
term->search.view_followed_offset = term->grid->view == term->grid->offset;
|
term->search.view_followed_offset = term->grid->view == term->grid->offset;
|
||||||
term->is_searching = true;
|
term->is_searching = true;
|
||||||
|
|
||||||
term->wl.search_surface = wl_compositor_create_surface(term->wl.compositor);
|
|
||||||
if (term->wl.search_surface != NULL) {
|
|
||||||
term->wl.search_sub_surface = wl_subcompositor_get_subsurface(
|
|
||||||
term->wl.sub_compositor, term->wl.search_surface, term->wl.surface);
|
|
||||||
|
|
||||||
if (term->wl.search_sub_surface != NULL) {
|
|
||||||
/* Sub-surface updates may occur without updating the main
|
|
||||||
* window */
|
|
||||||
wl_subsurface_set_desync(term->wl.search_sub_surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (term->wl.search_surface == NULL || term->wl.search_sub_surface == NULL) {
|
|
||||||
LOG_ERR("failed to create sub-surface for search box");
|
|
||||||
if (term->wl.search_surface != NULL)
|
|
||||||
wl_surface_destroy(term->wl.search_surface);
|
|
||||||
assert(term->wl.search_sub_surface == NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
render_search_box(term);
|
render_search_box(term);
|
||||||
render_refresh(term);
|
render_refresh(term);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue