aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--render.c18
-rw-r--r--search.c19
-rw-r--r--terminal.c2
-rw-r--r--wayland.c12
-rw-r--r--wayland.h3
5 files changed, 20 insertions, 34 deletions
diff --git a/render.c b/render.c
index c1a600ed..dec944c3 100644
--- a/render.c
+++ b/render.c
@@ -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);
diff --git a/search.c b/search.c
index d7939219..75a083d5 100644
--- a/search.c
+++ b/search.c
@@ -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;
diff --git a/terminal.c b/terminal.c
index 42a5416e..872955fb 100644
--- a/terminal.c
+++ b/terminal.c
@@ -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;
diff --git a/wayland.c b/wayland.c
index 6c74282a..88a8f14c 100644
--- a/wayland.c
+++ b/wayland.c
@@ -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)
diff --git a/wayland.h b/wayland.h
index 15c9c3d9..64a0c8c8 100644
--- a/wayland.h
+++ b/wayland.h
@@ -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;