From 9d362158e3810bc0cbfe1990238e2abd3786e4c1 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 11:31:31 +0100 Subject: url-mode: convert struct wl_url to use wayl_win_subsurface_new() --- render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 58a93a33..4e5ec60f 100644 --- a/render.c +++ b/render.c @@ -2555,8 +2555,8 @@ render_urls(struct terminal *term) const wchar_t *key = url->key; const size_t entered_key_len = wcslen(term->url_keys); - struct wl_surface *surf = it->item.surf; - struct wl_subsurface *sub_surf = it->item.sub_surf; + struct wl_surface *surf = it->item.surf.surf; + struct wl_subsurface *sub_surf = it->item.surf.sub; if (surf == NULL || sub_surf == NULL) continue; -- cgit v1.3 From 587f04f2e1fd432993cecf75fe4ffd23c9b2b243 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 11:39:25 +0100 Subject: csd: use wayl_win_subsurface_new/destroy() --- quirks.c | 4 ++-- render.c | 10 +++++----- terminal.c | 16 ++++++++-------- wayland.c | 35 +++++++++++++++++++++++------------ wayland.h | 3 +-- 5 files changed, 39 insertions(+), 29 deletions(-) (limited to 'render.c') diff --git a/quirks.c b/quirks.c index f77b111d..539ad9d4 100644 --- a/quirks.c +++ b/quirks.c @@ -52,7 +52,7 @@ quirk_weston_csd_on(struct terminal *term) return; for (int i = 0; i < ALEN(term->window->csd.surface); i++) - quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[i]); + quirk_weston_subsurface_desync_on(term->window->csd.surface[i].sub); } void @@ -64,7 +64,7 @@ quirk_weston_csd_off(struct terminal *term) return; for (int i = 0; i < ALEN(term->window->csd.surface); i++) - quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[i]); + quirk_weston_subsurface_desync_off(term->window->csd.surface[i].sub); } void diff --git a/render.c b/render.c index 4e5ec60f..c1a600ed 100644 --- a/render.c +++ b/render.c @@ -1409,7 +1409,7 @@ render_csd_title(struct terminal *term) xassert(term->window->use_csd == CSD_YES); struct csd_data info = get_csd_data(term, CSD_SURF_TITLE); - struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE]; + struct wl_surface *surf = term->window->csd.surface[CSD_SURF_TITLE].surf; xassert(info.width > 0 && info.height > 0); @@ -1440,7 +1440,7 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx) xassert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM); struct csd_data info = get_csd_data(term, surf_idx); - struct wl_surface *surf = term->window->csd.surface[surf_idx]; + struct wl_surface *surf = term->window->csd.surface[surf_idx].surf; if (info.width == 0 || info.height == 0) return; @@ -1609,7 +1609,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) xassert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE); struct csd_data info = get_csd_data(term, surf_idx); - struct wl_surface *surf = term->window->csd.surface[surf_idx]; + struct wl_surface *surf = term->window->csd.surface[surf_idx].surf; if (info.width == 0 || info.height == 0) return; @@ -1696,8 +1696,8 @@ render_csd(struct terminal *term) const int width = info.width; const int height = info.height; - struct wl_surface *surf = term->window->csd.surface[i]; - struct wl_subsurface *sub = term->window->csd.sub_surface[i]; + struct wl_surface *surf = term->window->csd.surface[i].surf; + struct wl_subsurface *sub = term->window->csd.surface[i].sub; xassert(surf != NULL); xassert(sub != NULL); diff --git a/terminal.c b/terminal.c index 6c0827c6..42a5416e 100644 --- a/terminal.c +++ b/terminal.c @@ -2827,21 +2827,21 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface) return TERM_SURF_SCROLLBACK_INDICATOR; else if (surface == term->window->render_timer_surface) return TERM_SURF_RENDER_TIMER; - else if (surface == term->window->csd.surface[CSD_SURF_TITLE]) + else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf) return TERM_SURF_TITLE; - else if (surface == term->window->csd.surface[CSD_SURF_LEFT]) + else if (surface == term->window->csd.surface[CSD_SURF_LEFT].surf) return TERM_SURF_BORDER_LEFT; - else if (surface == term->window->csd.surface[CSD_SURF_RIGHT]) + else if (surface == term->window->csd.surface[CSD_SURF_RIGHT].surf) return TERM_SURF_BORDER_RIGHT; - else if (surface == term->window->csd.surface[CSD_SURF_TOP]) + else if (surface == term->window->csd.surface[CSD_SURF_TOP].surf) return TERM_SURF_BORDER_TOP; - else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM]) + else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM].surf) return TERM_SURF_BORDER_BOTTOM; - else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE]) + else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE].surf) return TERM_SURF_BUTTON_MINIMIZE; - else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE]) + else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE].surf) return TERM_SURF_BUTTON_MAXIMIZE; - else if (surface == term->window->csd.surface[CSD_SURF_CLOSE]) + else if (surface == term->window->csd.surface[CSD_SURF_CLOSE].surf) return TERM_SURF_BUTTON_CLOSE; else { tll_foreach(term->window->urls, it) { diff --git a/wayland.c b/wayland.c index 14cd0c85..6c74282a 100644 --- a/wayland.c +++ b/wayland.c @@ -39,6 +39,20 @@ csd_instantiate(struct wl_window *win) struct wayland *wayl = win->term->wl; xassert(wayl != NULL); + for (size_t i = 0; i < CSD_SURF_MINIMIZE; i++) { + bool ret = wayl_win_subsurface_new(win, &win->csd.surface[i]); + xassert(ret); + } + + for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) { + bool ret = wayl_win_subsurface_new_with_custom_parent( + win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i]); + xassert(ret); + } + + /* TODO: we need the to commit? */ + +#if 0 for (size_t i = 0; i < ALEN(win->csd.surface); i++) { xassert(win->csd.surface[i] == NULL); xassert(win->csd.sub_surface[i] == NULL); @@ -55,20 +69,14 @@ csd_instantiate(struct wl_window *win) wl_surface_set_user_data(win->csd.surface[i], win); wl_surface_commit(win->csd.surface[i]); } +#endif } static void csd_destroy(struct wl_window *win) { - for (size_t i = 0; i < ALEN(win->csd.surface); i++) { - if (win->csd.sub_surface[i] != NULL) - wl_subsurface_destroy(win->csd.sub_surface[i]); - if (win->csd.surface[i] != NULL) - wl_surface_destroy(win->csd.surface[i]); - - win->csd.surface[i] = NULL; - win->csd.sub_surface[i] = NULL; - } + for (size_t i = 0; i < ALEN(win->csd.surface); i++) + wayl_win_subsurface_destroy(&win->csd.surface[i]); } static void @@ -1414,9 +1422,9 @@ wayl_win_destroy(struct wl_window *win) /* CSD */ for (size_t i = 0; i < ALEN(win->csd.surface); i++) { - if (win->csd.surface[i] != NULL) { - wl_surface_attach(win->csd.surface[i], NULL, 0, 0); - wl_surface_commit(win->csd.surface[i]); + if (win->csd.surface[i].surf != NULL) { + wl_surface_attach(win->csd.surface[i].surf, NULL, 0, 0); + wl_surface_commit(win->csd.surface[i].surf); } } @@ -1613,4 +1621,7 @@ wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf) wl_subsurface_destroy(surf->sub); if (surf->surf != NULL) wl_surface_destroy(surf->surf); + + surf->surf = NULL; + surf->sub = NULL; } diff --git a/wayland.h b/wayland.h index 5f4d8b76..15c9c3d9 100644 --- a/wayland.h +++ b/wayland.h @@ -372,8 +372,7 @@ struct wl_window { enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd; struct { - struct wl_surface *surface[CSD_SURF_COUNT]; - struct wl_subsurface *sub_surface[CSD_SURF_COUNT]; + struct wl_surf_subsurf surface[CSD_SURF_COUNT]; int move_timeout_fd; uint32_t serial; } csd; -- cgit v1.3 From e049124f6d57fb2fd444138ec588b5b3cab80ecc Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 11:47:49 +0100 Subject: search: use wayl_win_subsurface_new/destroy() --- render.c | 18 +++++++++--------- search.c | 19 ++++--------------- terminal.c | 2 +- wayland.c | 12 +++++------- wayland.h | 3 +-- 5 files changed, 20 insertions(+), 34 deletions(-) (limited to 'render.c') 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; -- cgit v1.3 From c8324943de5cb56f480e2a3477f6b129054ff2b4 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 11:50:43 +0100 Subject: scrollback-indicator: use wayl_win_subsurface_new/destroy() --- render.c | 43 +++++++++---------------------------------- terminal.c | 2 +- wayland.c | 11 ++++------- wayland.h | 5 +---- 4 files changed, 15 insertions(+), 46 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index dec944c3..a8fd5f2e 100644 --- a/render.c +++ b/render.c @@ -1775,49 +1775,23 @@ render_scrollback_position(struct terminal *term) if (term->conf->scrollback.indicator.position == SCROLLBACK_INDICATOR_POSITION_NONE) return; - struct wayland *wayl = term->wl; struct wl_window *win = term->window; if (term->grid->view == term->grid->offset) { - if (win->scrollback_indicator_surface != NULL) { - wl_subsurface_destroy(win->scrollback_indicator_sub_surface); - wl_surface_destroy(win->scrollback_indicator_surface); - - win->scrollback_indicator_surface = NULL; - win->scrollback_indicator_sub_surface = NULL; - } + if (win->scrollback_indicator_surface.surf != NULL) + wayl_win_subsurface_destroy(&win->scrollback_indicator_surface); return; } - if (win->scrollback_indicator_surface == NULL) { - win->scrollback_indicator_surface - = wl_compositor_create_surface(wayl->compositor); - - if (win->scrollback_indicator_surface == NULL) { + if (win->scrollback_indicator_surface.surf == NULL) { + if (!wayl_win_subsurface_new(win, &win->scrollback_indicator_surface)) { LOG_ERR("failed to create scrollback indicator surface"); return; } - - wl_surface_set_user_data(win->scrollback_indicator_surface, win); - - term->window->scrollback_indicator_sub_surface - = wl_subcompositor_get_subsurface( - wayl->sub_compositor, - win->scrollback_indicator_surface, - win->surface); - - if (win->scrollback_indicator_sub_surface == NULL) { - LOG_ERR("failed to create scrollback indicator sub-surface"); - wl_surface_destroy(win->scrollback_indicator_surface); - win->scrollback_indicator_surface = NULL; - return; - } - - wl_subsurface_set_sync(win->scrollback_indicator_sub_surface); } - xassert(win->scrollback_indicator_surface != NULL); - xassert(win->scrollback_indicator_sub_surface != NULL); + xassert(win->scrollback_indicator_surface.surf != NULL); + xassert(win->scrollback_indicator_surface.sub != NULL); /* Find absolute row number of the scrollback start */ int scrollback_start = term->grid->offset + term->rows; @@ -1905,13 +1879,14 @@ render_scrollback_position(struct terminal *term) } wl_subsurface_set_position( - win->scrollback_indicator_sub_surface, + win->scrollback_indicator_surface.sub, (term->width - margin - width) / scale, (term->margins.top + surf_top) / scale); render_osd( term, - win->scrollback_indicator_surface, win->scrollback_indicator_sub_surface, + win->scrollback_indicator_surface.surf, + win->scrollback_indicator_surface.sub, buf, text, term->colors.table[0], term->colors.table[8 + 4], width, height, width - margin - wcslen(text) * term->cell_width, margin); diff --git a/terminal.c b/terminal.c index 872955fb..0aab462b 100644 --- a/terminal.c +++ b/terminal.c @@ -2823,7 +2823,7 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface) return TERM_SURF_GRID; else if (surface == term->window->search_surface.surf) return TERM_SURF_SEARCH; - else if (surface == term->window->scrollback_indicator_surface) + else if (surface == term->window->scrollback_indicator_surface.surf) return TERM_SURF_SCROLLBACK_INDICATOR; else if (surface == term->window->render_timer_surface) return TERM_SURF_RENDER_TIMER; diff --git a/wayland.c b/wayland.c index 88a8f14c..ca95663e 100644 --- a/wayland.c +++ b/wayland.c @@ -1409,9 +1409,9 @@ wayl_win_destroy(struct wl_window *win) wl_surface_commit(win->render_timer_surface); } - if (win->scrollback_indicator_surface != NULL) { - wl_surface_attach(win->scrollback_indicator_surface, NULL, 0, 0); - wl_surface_commit(win->scrollback_indicator_surface); + if (win->scrollback_indicator_surface.surf != NULL) { + wl_surface_attach(win->scrollback_indicator_surface.surf, NULL, 0, 0); + wl_surface_commit(win->scrollback_indicator_surface.surf); } /* Scrollback search */ @@ -1444,15 +1444,12 @@ wayl_win_destroy(struct wl_window *win) csd_destroy(win); wayl_win_subsurface_destroy(&win->search_surface); + wayl_win_subsurface_destroy(&win->scrollback_indicator_surface); if (win->render_timer_sub_surface != NULL) wl_subsurface_destroy(win->render_timer_sub_surface); if (win->render_timer_surface != NULL) wl_surface_destroy(win->render_timer_surface); - if (win->scrollback_indicator_sub_surface != NULL) - wl_subsurface_destroy(win->scrollback_indicator_sub_surface); - if (win->scrollback_indicator_surface != NULL) - wl_surface_destroy(win->scrollback_indicator_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 64a0c8c8..31ae3b82 100644 --- a/wayland.h +++ b/wayland.h @@ -377,11 +377,8 @@ struct wl_window { uint32_t serial; } csd; - /* Scrollback search */ struct wl_surf_subsurf search_surface; - - struct wl_surface *scrollback_indicator_surface; - struct wl_subsurface *scrollback_indicator_sub_surface; + struct wl_surf_subsurf scrollback_indicator_surface; struct wl_surface *render_timer_surface; struct wl_subsurface *render_timer_sub_surface; -- cgit v1.3 From 438853a2d8b6479a2fbbd82d9ef59dbefbc9d297 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 11:53:22 +0100 Subject: render-timer: use wayl_win_subsurface_new/destroy() --- render.c | 5 +++-- terminal.c | 2 +- wayland.c | 19 +++++-------------- wayland.h | 4 +--- 4 files changed, 10 insertions(+), 20 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index a8fd5f2e..09c1b87f 100644 --- a/render.c +++ b/render.c @@ -1912,13 +1912,14 @@ render_render_timer(struct terminal *term, struct timeval render_time) term->wl->shm, width, height, cookie, false, 1); wl_subsurface_set_position( - win->render_timer_sub_surface, + win->render_timer_surface.sub, margin / term->scale, (term->margins.top + term->cell_height - margin) / term->scale); render_osd( term, - win->render_timer_surface, win->render_timer_sub_surface, + win->render_timer_surface.surf, + win->render_timer_surface.sub, buf, text, term->colors.table[0], term->colors.table[8 + 1], width, height, margin, margin); diff --git a/terminal.c b/terminal.c index 0aab462b..2ff02783 100644 --- a/terminal.c +++ b/terminal.c @@ -2825,7 +2825,7 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface) return TERM_SURF_SEARCH; else if (surface == term->window->scrollback_indicator_surface.surf) return TERM_SURF_SCROLLBACK_INDICATOR; - else if (surface == term->window->render_timer_surface) + else if (surface == term->window->render_timer_surface.surf) return TERM_SURF_RENDER_TIMER; else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf) return TERM_SURF_TITLE; diff --git a/wayland.c b/wayland.c index ca95663e..d8968ab6 100644 --- a/wayland.c +++ b/wayland.c @@ -1367,16 +1367,10 @@ wayl_win_init(struct terminal *term) wl_surface_commit(win->surface); if (conf->tweak.render_timer_osd) { - win->render_timer_surface = wl_compositor_create_surface(wayl->compositor); - if (win->render_timer_surface == NULL) { + if (!wayl_win_subsurface_new(win, &win->render_timer_surface)) { LOG_ERR("failed to create render timer surface"); goto out; } - win->render_timer_sub_surface = wl_subcompositor_get_subsurface( - wayl->sub_compositor, win->render_timer_surface, win->surface); - wl_subsurface_set_sync(win->render_timer_sub_surface); - wl_surface_set_user_data(win->render_timer_surface, win); - wl_surface_commit(win->render_timer_surface); } return win; @@ -1404,9 +1398,9 @@ wayl_win_destroy(struct wl_window *win) * nor mouse focus). */ - if (win->render_timer_surface != NULL) { - wl_surface_attach(win->render_timer_surface, NULL, 0, 0); - wl_surface_commit(win->render_timer_surface); + if (win->render_timer_surface.surf != NULL) { + wl_surface_attach(win->render_timer_surface.surf, NULL, 0, 0); + wl_surface_commit(win->render_timer_surface.surf); } if (win->scrollback_indicator_surface.surf != NULL) { @@ -1445,11 +1439,8 @@ wayl_win_destroy(struct wl_window *win) csd_destroy(win); wayl_win_subsurface_destroy(&win->search_surface); wayl_win_subsurface_destroy(&win->scrollback_indicator_surface); + wayl_win_subsurface_destroy(&win->render_timer_surface); - if (win->render_timer_sub_surface != NULL) - wl_subsurface_destroy(win->render_timer_sub_surface); - if (win->render_timer_surface != NULL) - wl_surface_destroy(win->render_timer_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 31ae3b82..4b146d57 100644 --- a/wayland.h +++ b/wayland.h @@ -379,9 +379,7 @@ struct wl_window { struct wl_surf_subsurf search_surface; struct wl_surf_subsurf scrollback_indicator_surface; - - struct wl_surface *render_timer_surface; - struct wl_subsurface *render_timer_sub_surface; + struct wl_surf_subsurf render_timer_surface; struct wl_callback *frame_callback; -- cgit v1.3 From 5c8579043dd22a08e872d90a20011f5d6d8d3dc1 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 12 Feb 2021 12:00:40 +0100 Subject: wayland: drop ‘_surface’ suffix from subsurface struct instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 42 +++++++++++++++++++++--------------------- search.c | 5 ++--- terminal.c | 6 +++--- wayland.c | 26 +++++++++++++------------- wayland.h | 6 +++--- 5 files changed, 42 insertions(+), 43 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 09c1b87f..aaa106a3 100644 --- a/render.c +++ b/render.c @@ -1778,20 +1778,20 @@ render_scrollback_position(struct terminal *term) struct wl_window *win = term->window; if (term->grid->view == term->grid->offset) { - if (win->scrollback_indicator_surface.surf != NULL) - wayl_win_subsurface_destroy(&win->scrollback_indicator_surface); + if (win->scrollback_indicator.surf != NULL) + wayl_win_subsurface_destroy(&win->scrollback_indicator); return; } - if (win->scrollback_indicator_surface.surf == NULL) { - if (!wayl_win_subsurface_new(win, &win->scrollback_indicator_surface)) { + if (win->scrollback_indicator.surf == NULL) { + if (!wayl_win_subsurface_new(win, &win->scrollback_indicator)) { LOG_ERR("failed to create scrollback indicator surface"); return; } } - xassert(win->scrollback_indicator_surface.surf != NULL); - xassert(win->scrollback_indicator_surface.sub != NULL); + xassert(win->scrollback_indicator.surf != NULL); + xassert(win->scrollback_indicator.sub != NULL); /* Find absolute row number of the scrollback start */ int scrollback_start = term->grid->offset + term->rows; @@ -1879,14 +1879,14 @@ render_scrollback_position(struct terminal *term) } wl_subsurface_set_position( - win->scrollback_indicator_surface.sub, + win->scrollback_indicator.sub, (term->width - margin - width) / scale, (term->margins.top + surf_top) / scale); render_osd( term, - win->scrollback_indicator_surface.surf, - win->scrollback_indicator_surface.sub, + win->scrollback_indicator.surf, + win->scrollback_indicator.sub, buf, text, term->colors.table[0], term->colors.table[8 + 4], width, height, width - margin - wcslen(text) * term->cell_width, margin); @@ -1912,14 +1912,14 @@ render_render_timer(struct terminal *term, struct timeval render_time) term->wl->shm, width, height, cookie, false, 1); wl_subsurface_set_position( - win->render_timer_surface.sub, + win->render_timer.sub, margin / term->scale, (term->margins.top + term->cell_height - margin) / term->scale); render_osd( term, - win->render_timer_surface.surf, - win->render_timer_surface.sub, + win->render_timer.surf, + win->render_timer.sub, buf, text, term->colors.table[0], term->colors.table[8 + 1], width, height, margin, margin); @@ -2208,7 +2208,7 @@ grid_render(struct terminal *term) static void render_search_box(struct terminal *term) { - xassert(term->window->search_surface.sub != NULL); + xassert(term->window->search.sub != NULL); /* * We treat the search box pretty much like a row of cells. That @@ -2481,27 +2481,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_surface.sub); + quirk_weston_subsurface_desync_on(term->window->search.sub); /* TODO: this is only necessary on a window resize */ wl_subsurface_set_position( - term->window->search_surface.sub, + term->window->search.sub, margin / scale, max(0, (int32_t)term->height - height - margin) / 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); + wl_surface_attach(term->window->search.surf, buf->wl_buf, 0, 0); + wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height); + wl_surface_set_buffer_scale(term->window->search.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.surf, region); + wl_surface_set_opaque_region(term->window->search.surf, region); wl_region_destroy(region); } - wl_surface_commit(term->window->search_surface.surf); - quirk_weston_subsurface_desync_off(term->window->search_surface.sub); + wl_surface_commit(term->window->search.surf); + quirk_weston_subsurface_desync_off(term->window->search.sub); #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED free(text); diff --git a/search.c b/search.c index 75a083d5..5dfa7b58 100644 --- a/search.c +++ b/search.c @@ -81,7 +81,7 @@ static void search_cancel_keep_selection(struct terminal *term) { struct wl_window *win = term->window; - wayl_win_subsurface_destroy(&win->search_surface); + wayl_win_subsurface_destroy(&win->search); free(term->search.buf); term->search.buf = NULL; @@ -118,8 +118,7 @@ search_begin(struct terminal *term) } /* On-demand instantiate wayland surface */ - bool ret = wayl_win_subsurface_new( - term->window, &term->window->search_surface); + bool ret = wayl_win_subsurface_new(term->window, &term->window->search); xassert(ret); term->search.original_view = term->grid->view; diff --git a/terminal.c b/terminal.c index 2ff02783..0051ca6d 100644 --- a/terminal.c +++ b/terminal.c @@ -2821,11 +2821,11 @@ 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.surf) + else if (surface == term->window->search.surf) return TERM_SURF_SEARCH; - else if (surface == term->window->scrollback_indicator_surface.surf) + else if (surface == term->window->scrollback_indicator.surf) return TERM_SURF_SCROLLBACK_INDICATOR; - else if (surface == term->window->render_timer_surface.surf) + else if (surface == term->window->render_timer.surf) return TERM_SURF_RENDER_TIMER; else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf) return TERM_SURF_TITLE; diff --git a/wayland.c b/wayland.c index d8968ab6..85dc08e6 100644 --- a/wayland.c +++ b/wayland.c @@ -1367,7 +1367,7 @@ wayl_win_init(struct terminal *term) wl_surface_commit(win->surface); if (conf->tweak.render_timer_osd) { - if (!wayl_win_subsurface_new(win, &win->render_timer_surface)) { + if (!wayl_win_subsurface_new(win, &win->render_timer)) { LOG_ERR("failed to create render timer surface"); goto out; } @@ -1398,20 +1398,20 @@ wayl_win_destroy(struct wl_window *win) * nor mouse focus). */ - if (win->render_timer_surface.surf != NULL) { - wl_surface_attach(win->render_timer_surface.surf, NULL, 0, 0); - wl_surface_commit(win->render_timer_surface.surf); + if (win->render_timer.surf != NULL) { + wl_surface_attach(win->render_timer.surf, NULL, 0, 0); + wl_surface_commit(win->render_timer.surf); } - if (win->scrollback_indicator_surface.surf != NULL) { - wl_surface_attach(win->scrollback_indicator_surface.surf, NULL, 0, 0); - wl_surface_commit(win->scrollback_indicator_surface.surf); + if (win->scrollback_indicator.surf != NULL) { + wl_surface_attach(win->scrollback_indicator.surf, NULL, 0, 0); + wl_surface_commit(win->scrollback_indicator.surf); } /* Scrollback search */ - if (win->search_surface.surf != NULL) { - wl_surface_attach(win->search_surface.surf, NULL, 0, 0); - wl_surface_commit(win->search_surface.surf); + if (win->search.surf != NULL) { + wl_surface_attach(win->search.surf, NULL, 0, 0); + wl_surface_commit(win->search.surf); } /* CSD */ @@ -1437,9 +1437,9 @@ wayl_win_destroy(struct wl_window *win) } csd_destroy(win); - wayl_win_subsurface_destroy(&win->search_surface); - wayl_win_subsurface_destroy(&win->scrollback_indicator_surface); - wayl_win_subsurface_destroy(&win->render_timer_surface); + wayl_win_subsurface_destroy(&win->search); + wayl_win_subsurface_destroy(&win->scrollback_indicator); + wayl_win_subsurface_destroy(&win->render_timer); if (win->frame_callback != NULL) wl_callback_destroy(win->frame_callback); diff --git a/wayland.h b/wayland.h index 4b146d57..b2d7c64f 100644 --- a/wayland.h +++ b/wayland.h @@ -377,9 +377,9 @@ struct wl_window { uint32_t serial; } csd; - struct wl_surf_subsurf search_surface; - struct wl_surf_subsurf scrollback_indicator_surface; - struct wl_surf_subsurf render_timer_surface; + struct wl_surf_subsurf search; + struct wl_surf_subsurf scrollback_indicator; + struct wl_surf_subsurf render_timer; struct wl_callback *frame_callback; -- cgit v1.3