mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-18 05:34:02 -04:00
url-mode: convert struct wl_url to use wayl_win_subsurface_new()
This commit is contained in:
parent
bb4d9a5fd3
commit
9d362158e3
5 changed files with 8 additions and 46 deletions
4
render.c
4
render.c
|
|
@ -2555,8 +2555,8 @@ render_urls(struct terminal *term)
|
||||||
const wchar_t *key = url->key;
|
const wchar_t *key = url->key;
|
||||||
const size_t entered_key_len = wcslen(term->url_keys);
|
const size_t entered_key_len = wcslen(term->url_keys);
|
||||||
|
|
||||||
struct wl_surface *surf = it->item.surf;
|
struct wl_surface *surf = it->item.surf.surf;
|
||||||
struct wl_subsurface *sub_surf = it->item.sub_surf;
|
struct wl_subsurface *sub_surf = it->item.surf.sub;
|
||||||
|
|
||||||
if (surf == NULL || sub_surf == NULL)
|
if (surf == NULL || sub_surf == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -2845,7 +2845,7 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
|
||||||
return TERM_SURF_BUTTON_CLOSE;
|
return TERM_SURF_BUTTON_CLOSE;
|
||||||
else {
|
else {
|
||||||
tll_foreach(term->window->urls, it) {
|
tll_foreach(term->window->urls, it) {
|
||||||
if (surface == it->item.surf)
|
if (surface == it->item.surf.surf)
|
||||||
return TERM_SURF_JUMP_LABEL;
|
return TERM_SURF_JUMP_LABEL;
|
||||||
}
|
}
|
||||||
return TERM_SURF_NONE;
|
return TERM_SURF_NONE;
|
||||||
|
|
|
||||||
40
url-mode.c
40
url-mode.c
|
|
@ -472,45 +472,14 @@ void
|
||||||
urls_render(struct terminal *term)
|
urls_render(struct terminal *term)
|
||||||
{
|
{
|
||||||
struct wl_window *win = term->window;
|
struct wl_window *win = term->window;
|
||||||
struct wayland *wayl = term->wl;
|
|
||||||
|
|
||||||
if (tll_length(win->term->urls) == 0)
|
if (tll_length(win->term->urls) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xassert(tll_length(win->urls) == 0);
|
xassert(tll_length(win->urls) == 0);
|
||||||
tll_foreach(win->term->urls, it) {
|
tll_foreach(win->term->urls, it) {
|
||||||
struct wl_surface *surf = wl_compositor_create_surface(wayl->compositor);
|
struct wl_url url = {.url = &it->item};
|
||||||
wl_surface_set_user_data(surf, win);
|
wayl_win_subsurface_new(win, &url.surf);
|
||||||
|
|
||||||
struct wl_subsurface *sub_surf = NULL;
|
|
||||||
|
|
||||||
if (surf != NULL) {
|
|
||||||
sub_surf = wl_subcompositor_get_subsurface(
|
|
||||||
wayl->sub_compositor, surf, win->surface);
|
|
||||||
|
|
||||||
if (sub_surf != NULL)
|
|
||||||
wl_subsurface_set_sync(sub_surf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surf == NULL || sub_surf == NULL) {
|
|
||||||
LOG_WARN("failed to create URL (sub)-surface");
|
|
||||||
|
|
||||||
if (surf != NULL) {
|
|
||||||
wl_surface_destroy(surf);
|
|
||||||
surf = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sub_surf != NULL) {
|
|
||||||
wl_subsurface_destroy(sub_surf);
|
|
||||||
sub_surf = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wl_url url = {
|
|
||||||
.url = &it->item,
|
|
||||||
.surf = surf,
|
|
||||||
.sub_surf = sub_surf,
|
|
||||||
};
|
|
||||||
|
|
||||||
tll_push_back(win->urls, url);
|
tll_push_back(win->urls, url);
|
||||||
tag_cells_for_url(term, &it->item, true);
|
tag_cells_for_url(term, &it->item, true);
|
||||||
|
|
@ -536,10 +505,7 @@ urls_reset(struct terminal *term)
|
||||||
|
|
||||||
if (term->window != NULL) {
|
if (term->window != NULL) {
|
||||||
tll_foreach(term->window->urls, it) {
|
tll_foreach(term->window->urls, it) {
|
||||||
if (it->item.sub_surf != NULL)
|
wayl_win_subsurface_destroy(&it->item.surf);
|
||||||
wl_subsurface_destroy(it->item.sub_surf);
|
|
||||||
if (it->item.surf != NULL)
|
|
||||||
wl_surface_destroy(it->item.surf);
|
|
||||||
tll_remove(term->window->urls, it);
|
tll_remove(term->window->urls, it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1430,10 +1430,7 @@ wayl_win_destroy(struct wl_window *win)
|
||||||
tll_free(win->on_outputs);
|
tll_free(win->on_outputs);
|
||||||
|
|
||||||
tll_foreach(win->urls, it) {
|
tll_foreach(win->urls, it) {
|
||||||
if (it->item.sub_surf != NULL)
|
wayl_win_subsurface_destroy(&it->item.surf);
|
||||||
wl_subsurface_destroy(it->item.sub_surf);
|
|
||||||
if (it->item.surf != NULL)
|
|
||||||
wl_surface_destroy(it->item.surf);
|
|
||||||
tll_remove(win->urls, it);
|
tll_remove(win->urls, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -357,8 +357,7 @@ struct wl_surf_subsurf {
|
||||||
|
|
||||||
struct wl_url {
|
struct wl_url {
|
||||||
const struct url *url;
|
const struct url *url;
|
||||||
struct wl_surface *surf;
|
struct wl_surf_subsurf surf;
|
||||||
struct wl_subsurface *sub_surf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wayland;
|
struct wayland;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue