aboutsummaryrefslogtreecommitdiff
path: root/search.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-29 18:22:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-29 18:22:07 +0000
commit1e4b11b0fa73d4fa9e4f124fa04173f92f645d1f (patch)
treec5ba9b87c704c22de014b846a3e3386e23e49df9 /search.c
parentsearch: move render() function to the 'render' module (diff)
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).
Diffstat (limited to 'search.c')
-rw-r--r--search.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/search.c b/search.c
index 81bdf8f3..051a32db 100644
--- a/search.c
+++ b/search.c
@@ -18,14 +18,8 @@
static void
search_cancel_keep_selection(struct terminal *term)
{
- if (term->wl.search_sub_surface != NULL) {
- wl_subsurface_destroy(term->wl.search_sub_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;
- }
+ wl_surface_attach(term->wl.search_surface, NULL, 0, 0);
+ wl_surface_commit(term->wl.search_surface);
free(term->search.buf);
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->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_refresh(term);
}