search: use wayl_win_subsurface_new/destroy()

This commit is contained in:
Daniel Eklöf 2021-02-12 11:47:49 +01:00
parent 587f04f2e1
commit e049124f6d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 20 additions and 34 deletions

View file

@ -2232,7 +2232,7 @@ grid_render(struct terminal *term)
static void
render_search_box(struct terminal *term)
{
xassert(term->window->search_sub_surface != NULL);
xassert(term->window->search_surface.sub != NULL);
/*
* We treat the search box pretty much like a row of cells. That
@ -2505,27 +2505,27 @@ render_search_box(struct terminal *term)
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
}
quirk_weston_subsurface_desync_on(term->window->search_sub_surface);
quirk_weston_subsurface_desync_on(term->window->search_surface.sub);
/* TODO: this is only necessary on a window resize */
wl_subsurface_set_position(
term->window->search_sub_surface,
term->window->search_surface.sub,
margin / scale,
max(0, (int32_t)term->height - height - margin) / scale);
wl_surface_attach(term->window->search_surface, buf->wl_buf, 0, 0);
wl_surface_damage_buffer(term->window->search_surface, 0, 0, width, height);
wl_surface_set_buffer_scale(term->window->search_surface, scale);
wl_surface_attach(term->window->search_surface.surf, buf->wl_buf, 0, 0);
wl_surface_damage_buffer(term->window->search_surface.surf, 0, 0, width, height);
wl_surface_set_buffer_scale(term->window->search_surface.surf, scale);
struct wl_region *region = wl_compositor_create_region(term->wl->compositor);
if (region != NULL) {
wl_region_add(region, width - visible_width, 0, visible_width, height);
wl_surface_set_opaque_region(term->window->search_surface, region);
wl_surface_set_opaque_region(term->window->search_surface.surf, region);
wl_region_destroy(region);
}
wl_surface_commit(term->window->search_surface);
quirk_weston_subsurface_desync_off(term->window->search_sub_surface);
wl_surface_commit(term->window->search_surface.surf);
quirk_weston_subsurface_desync_off(term->window->search_surface.sub);
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
free(text);

View file

@ -81,13 +81,7 @@ static void
search_cancel_keep_selection(struct terminal *term)
{
struct wl_window *win = term->window;
if (win->search_sub_surface != NULL)
wl_subsurface_destroy(win->search_sub_surface);
if (win->search_surface != NULL)
wl_surface_destroy(win->search_surface);
win->search_surface = NULL;
win->search_sub_surface = NULL;
wayl_win_subsurface_destroy(&win->search_surface);
free(term->search.buf);
term->search.buf = NULL;
@ -124,14 +118,9 @@ search_begin(struct terminal *term)
}
/* On-demand instantiate wayland surface */
struct wl_window *win = term->window;
struct wayland *wayl = term->wl;
win->search_surface = wl_compositor_create_surface(wayl->compositor);
wl_surface_set_user_data(win->search_surface, term->window);
win->search_sub_surface = wl_subcompositor_get_subsurface(
wayl->sub_compositor, win->search_surface, win->surface);
wl_subsurface_set_sync(win->search_sub_surface);
bool ret = wayl_win_subsurface_new(
term->window, &term->window->search_surface);
xassert(ret);
term->search.original_view = term->grid->view;
term->search.view_followed_offset = term->grid->view == term->grid->offset;

View file

@ -2821,7 +2821,7 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
{
if (likely(surface == term->window->surface))
return TERM_SURF_GRID;
else if (surface == term->window->search_surface)
else if (surface == term->window->search_surface.surf)
return TERM_SURF_SEARCH;
else if (surface == term->window->scrollback_indicator_surface)
return TERM_SURF_SCROLLBACK_INDICATOR;

View file

@ -1415,9 +1415,9 @@ wayl_win_destroy(struct wl_window *win)
}
/* Scrollback search */
if (win->search_surface != NULL) {
wl_surface_attach(win->search_surface, NULL, 0, 0);
wl_surface_commit(win->search_surface);
if (win->search_surface.surf != NULL) {
wl_surface_attach(win->search_surface.surf, NULL, 0, 0);
wl_surface_commit(win->search_surface.surf);
}
/* CSD */
@ -1443,6 +1443,8 @@ wayl_win_destroy(struct wl_window *win)
}
csd_destroy(win);
wayl_win_subsurface_destroy(&win->search_surface);
if (win->render_timer_sub_surface != NULL)
wl_subsurface_destroy(win->render_timer_sub_surface);
if (win->render_timer_surface != NULL)
@ -1451,10 +1453,6 @@ wayl_win_destroy(struct wl_window *win)
wl_subsurface_destroy(win->scrollback_indicator_sub_surface);
if (win->scrollback_indicator_surface != NULL)
wl_surface_destroy(win->scrollback_indicator_surface);
if (win->search_sub_surface != NULL)
wl_subsurface_destroy(win->search_sub_surface);
if (win->search_surface != NULL)
wl_surface_destroy(win->search_surface);
if (win->frame_callback != NULL)
wl_callback_destroy(win->frame_callback);
if (win->xdg_toplevel_decoration != NULL)

View file

@ -378,8 +378,7 @@ struct wl_window {
} csd;
/* Scrollback search */
struct wl_surface *search_surface;
struct wl_subsurface *search_sub_surface;
struct wl_surf_subsurf search_surface;
struct wl_surface *scrollback_indicator_surface;
struct wl_subsurface *scrollback_indicator_sub_surface;