mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-24 01:40:12 -05:00
Merge branch 'refactor-subsurface-creation'
This commit is contained in:
commit
34f89fbe72
7 changed files with 144 additions and 190 deletions
4
quirks.c
4
quirks.c
|
|
@ -52,7 +52,7 @@ quirk_weston_csd_on(struct terminal *term)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
|
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
|
void
|
||||||
|
|
@ -64,7 +64,7 @@ quirk_weston_csd_off(struct terminal *term)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < ALEN(term->window->csd.surface); i++)
|
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
|
void
|
||||||
|
|
|
||||||
80
render.c
80
render.c
|
|
@ -1409,7 +1409,7 @@ render_csd_title(struct terminal *term)
|
||||||
xassert(term->window->use_csd == CSD_YES);
|
xassert(term->window->use_csd == CSD_YES);
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, CSD_SURF_TITLE);
|
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);
|
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);
|
xassert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM);
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, surf_idx);
|
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)
|
if (info.width == 0 || info.height == 0)
|
||||||
return;
|
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);
|
xassert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE);
|
||||||
|
|
||||||
struct csd_data info = get_csd_data(term, surf_idx);
|
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)
|
if (info.width == 0 || info.height == 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -1696,8 +1696,8 @@ render_csd(struct terminal *term)
|
||||||
const int width = info.width;
|
const int width = info.width;
|
||||||
const int height = info.height;
|
const int height = info.height;
|
||||||
|
|
||||||
struct wl_surface *surf = term->window->csd.surface[i];
|
struct wl_surface *surf = term->window->csd.surface[i].surf;
|
||||||
struct wl_subsurface *sub = term->window->csd.sub_surface[i];
|
struct wl_subsurface *sub = term->window->csd.surface[i].sub;
|
||||||
|
|
||||||
xassert(surf != NULL);
|
xassert(surf != NULL);
|
||||||
xassert(sub != NULL);
|
xassert(sub != NULL);
|
||||||
|
|
@ -1775,49 +1775,23 @@ render_scrollback_position(struct terminal *term)
|
||||||
if (term->conf->scrollback.indicator.position == SCROLLBACK_INDICATOR_POSITION_NONE)
|
if (term->conf->scrollback.indicator.position == SCROLLBACK_INDICATOR_POSITION_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct wayland *wayl = term->wl;
|
|
||||||
struct wl_window *win = term->window;
|
struct wl_window *win = term->window;
|
||||||
|
|
||||||
if (term->grid->view == term->grid->offset) {
|
if (term->grid->view == term->grid->offset) {
|
||||||
if (win->scrollback_indicator_surface != NULL) {
|
if (win->scrollback_indicator.surf != NULL)
|
||||||
wl_subsurface_destroy(win->scrollback_indicator_sub_surface);
|
wayl_win_subsurface_destroy(&win->scrollback_indicator);
|
||||||
wl_surface_destroy(win->scrollback_indicator_surface);
|
|
||||||
|
|
||||||
win->scrollback_indicator_surface = NULL;
|
|
||||||
win->scrollback_indicator_sub_surface = NULL;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win->scrollback_indicator_surface == NULL) {
|
if (win->scrollback_indicator.surf == NULL) {
|
||||||
win->scrollback_indicator_surface
|
if (!wayl_win_subsurface_new(win, &win->scrollback_indicator)) {
|
||||||
= wl_compositor_create_surface(wayl->compositor);
|
|
||||||
|
|
||||||
if (win->scrollback_indicator_surface == NULL) {
|
|
||||||
LOG_ERR("failed to create scrollback indicator surface");
|
LOG_ERR("failed to create scrollback indicator surface");
|
||||||
return;
|
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.surf != NULL);
|
||||||
xassert(win->scrollback_indicator_sub_surface != NULL);
|
xassert(win->scrollback_indicator.sub != NULL);
|
||||||
|
|
||||||
/* Find absolute row number of the scrollback start */
|
/* Find absolute row number of the scrollback start */
|
||||||
int scrollback_start = term->grid->offset + term->rows;
|
int scrollback_start = term->grid->offset + term->rows;
|
||||||
|
|
@ -1905,13 +1879,14 @@ render_scrollback_position(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_subsurface_set_position(
|
wl_subsurface_set_position(
|
||||||
win->scrollback_indicator_sub_surface,
|
win->scrollback_indicator.sub,
|
||||||
(term->width - margin - width) / scale,
|
(term->width - margin - width) / scale,
|
||||||
(term->margins.top + surf_top) / scale);
|
(term->margins.top + surf_top) / scale);
|
||||||
|
|
||||||
render_osd(
|
render_osd(
|
||||||
term,
|
term,
|
||||||
win->scrollback_indicator_surface, win->scrollback_indicator_sub_surface,
|
win->scrollback_indicator.surf,
|
||||||
|
win->scrollback_indicator.sub,
|
||||||
buf, text,
|
buf, text,
|
||||||
term->colors.table[0], term->colors.table[8 + 4],
|
term->colors.table[0], term->colors.table[8 + 4],
|
||||||
width, height, width - margin - wcslen(text) * term->cell_width, margin);
|
width, height, width - margin - wcslen(text) * term->cell_width, margin);
|
||||||
|
|
@ -1937,13 +1912,14 @@ render_render_timer(struct terminal *term, struct timeval render_time)
|
||||||
term->wl->shm, width, height, cookie, false, 1);
|
term->wl->shm, width, height, cookie, false, 1);
|
||||||
|
|
||||||
wl_subsurface_set_position(
|
wl_subsurface_set_position(
|
||||||
win->render_timer_sub_surface,
|
win->render_timer.sub,
|
||||||
margin / term->scale,
|
margin / term->scale,
|
||||||
(term->margins.top + term->cell_height - margin) / term->scale);
|
(term->margins.top + term->cell_height - margin) / term->scale);
|
||||||
|
|
||||||
render_osd(
|
render_osd(
|
||||||
term,
|
term,
|
||||||
win->render_timer_surface, win->render_timer_sub_surface,
|
win->render_timer.surf,
|
||||||
|
win->render_timer.sub,
|
||||||
buf, text,
|
buf, text,
|
||||||
term->colors.table[0], term->colors.table[8 + 1],
|
term->colors.table[0], term->colors.table[8 + 1],
|
||||||
width, height, margin, margin);
|
width, height, margin, margin);
|
||||||
|
|
@ -2232,7 +2208,7 @@ grid_render(struct terminal *term)
|
||||||
static void
|
static void
|
||||||
render_search_box(struct terminal *term)
|
render_search_box(struct terminal *term)
|
||||||
{
|
{
|
||||||
xassert(term->window->search_sub_surface != NULL);
|
xassert(term->window->search.sub != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We treat the search box pretty much like a row of cells. That
|
* We treat the search box pretty much like a row of cells. That
|
||||||
|
|
@ -2505,27 +2481,27 @@ render_search_box(struct terminal *term)
|
||||||
term, WINDOW_X(x), WINDOW_Y(y), 1, term->cell_height);
|
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.sub);
|
||||||
|
|
||||||
/* TODO: this is only necessary on a window resize */
|
/* TODO: this is only necessary on a window resize */
|
||||||
wl_subsurface_set_position(
|
wl_subsurface_set_position(
|
||||||
term->window->search_sub_surface,
|
term->window->search.sub,
|
||||||
margin / scale,
|
margin / scale,
|
||||||
max(0, (int32_t)term->height - height - 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_attach(term->window->search.surf, buf->wl_buf, 0, 0);
|
||||||
wl_surface_damage_buffer(term->window->search_surface, 0, 0, width, height);
|
wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height);
|
||||||
wl_surface_set_buffer_scale(term->window->search_surface, scale);
|
wl_surface_set_buffer_scale(term->window->search.surf, scale);
|
||||||
|
|
||||||
struct wl_region *region = wl_compositor_create_region(term->wl->compositor);
|
struct wl_region *region = wl_compositor_create_region(term->wl->compositor);
|
||||||
if (region != NULL) {
|
if (region != NULL) {
|
||||||
wl_region_add(region, width - visible_width, 0, visible_width, height);
|
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.surf, region);
|
||||||
wl_region_destroy(region);
|
wl_region_destroy(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_commit(term->window->search_surface);
|
wl_surface_commit(term->window->search.surf);
|
||||||
quirk_weston_subsurface_desync_off(term->window->search_sub_surface);
|
quirk_weston_subsurface_desync_off(term->window->search.sub);
|
||||||
|
|
||||||
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
|
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
|
||||||
free(text);
|
free(text);
|
||||||
|
|
@ -2555,8 +2531,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;
|
||||||
|
|
|
||||||
18
search.c
18
search.c
|
|
@ -81,13 +81,7 @@ static void
|
||||||
search_cancel_keep_selection(struct terminal *term)
|
search_cancel_keep_selection(struct terminal *term)
|
||||||
{
|
{
|
||||||
struct wl_window *win = term->window;
|
struct wl_window *win = term->window;
|
||||||
if (win->search_sub_surface != NULL)
|
wayl_win_subsurface_destroy(&win->search);
|
||||||
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;
|
|
||||||
|
|
||||||
free(term->search.buf);
|
free(term->search.buf);
|
||||||
term->search.buf = NULL;
|
term->search.buf = NULL;
|
||||||
|
|
@ -124,14 +118,8 @@ search_begin(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On-demand instantiate wayland surface */
|
/* On-demand instantiate wayland surface */
|
||||||
struct wl_window *win = term->window;
|
bool ret = wayl_win_subsurface_new(term->window, &term->window->search);
|
||||||
struct wayland *wayl = term->wl;
|
xassert(ret);
|
||||||
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);
|
|
||||||
|
|
||||||
term->search.original_view = term->grid->view;
|
term->search.original_view = term->grid->view;
|
||||||
term->search.view_followed_offset = term->grid->view == term->grid->offset;
|
term->search.view_followed_offset = term->grid->view == term->grid->offset;
|
||||||
|
|
|
||||||
24
terminal.c
24
terminal.c
|
|
@ -2821,31 +2821,31 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface)
|
||||||
{
|
{
|
||||||
if (likely(surface == term->window->surface))
|
if (likely(surface == term->window->surface))
|
||||||
return TERM_SURF_GRID;
|
return TERM_SURF_GRID;
|
||||||
else if (surface == term->window->search_surface)
|
else if (surface == term->window->search.surf)
|
||||||
return TERM_SURF_SEARCH;
|
return TERM_SURF_SEARCH;
|
||||||
else if (surface == term->window->scrollback_indicator_surface)
|
else if (surface == term->window->scrollback_indicator.surf)
|
||||||
return TERM_SURF_SCROLLBACK_INDICATOR;
|
return TERM_SURF_SCROLLBACK_INDICATOR;
|
||||||
else if (surface == term->window->render_timer_surface)
|
else if (surface == term->window->render_timer.surf)
|
||||||
return TERM_SURF_RENDER_TIMER;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
136
wayland.c
136
wayland.c
|
|
@ -39,36 +39,23 @@ csd_instantiate(struct wl_window *win)
|
||||||
struct wayland *wayl = win->term->wl;
|
struct wayland *wayl = win->term->wl;
|
||||||
xassert(wayl != NULL);
|
xassert(wayl != NULL);
|
||||||
|
|
||||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
for (size_t i = 0; i < CSD_SURF_MINIMIZE; i++) {
|
||||||
xassert(win->csd.surface[i] == NULL);
|
bool ret = wayl_win_subsurface_new(win, &win->csd.surface[i]);
|
||||||
xassert(win->csd.sub_surface[i] == NULL);
|
xassert(ret);
|
||||||
|
}
|
||||||
|
|
||||||
win->csd.surface[i] = wl_compositor_create_surface(wayl->compositor);
|
for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) {
|
||||||
|
bool ret = wayl_win_subsurface_new_with_custom_parent(
|
||||||
struct wl_surface *parent = i < CSD_SURF_MINIMIZE
|
win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i]);
|
||||||
? win->surface : win->csd.surface[CSD_SURF_TITLE];
|
xassert(ret);
|
||||||
|
|
||||||
win->csd.sub_surface[i] = wl_subcompositor_get_subsurface(
|
|
||||||
wayl->sub_compositor, win->csd.surface[i], parent);
|
|
||||||
|
|
||||||
wl_subsurface_set_sync(win->csd.sub_surface[i]);
|
|
||||||
wl_surface_set_user_data(win->csd.surface[i], win);
|
|
||||||
wl_surface_commit(win->csd.surface[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
csd_destroy(struct wl_window *win)
|
csd_destroy(struct wl_window *win)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
for (size_t i = 0; i < ALEN(win->csd.surface); i++)
|
||||||
if (win->csd.sub_surface[i] != NULL)
|
wayl_win_subsurface_destroy(&win->csd.surface[i]);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -1359,16 +1346,10 @@ wayl_win_init(struct terminal *term)
|
||||||
wl_surface_commit(win->surface);
|
wl_surface_commit(win->surface);
|
||||||
|
|
||||||
if (conf->tweak.render_timer_osd) {
|
if (conf->tweak.render_timer_osd) {
|
||||||
win->render_timer_surface = wl_compositor_create_surface(wayl->compositor);
|
if (!wayl_win_subsurface_new(win, &win->render_timer)) {
|
||||||
if (win->render_timer_surface == NULL) {
|
|
||||||
LOG_ERR("failed to create render timer surface");
|
LOG_ERR("failed to create render timer surface");
|
||||||
goto out;
|
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;
|
return win;
|
||||||
|
|
||||||
|
|
@ -1396,27 +1377,27 @@ wayl_win_destroy(struct wl_window *win)
|
||||||
* nor mouse focus).
|
* nor mouse focus).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (win->render_timer_surface != NULL) {
|
if (win->render_timer.surf != NULL) {
|
||||||
wl_surface_attach(win->render_timer_surface, NULL, 0, 0);
|
wl_surface_attach(win->render_timer.surf, NULL, 0, 0);
|
||||||
wl_surface_commit(win->render_timer_surface);
|
wl_surface_commit(win->render_timer.surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win->scrollback_indicator_surface != NULL) {
|
if (win->scrollback_indicator.surf != NULL) {
|
||||||
wl_surface_attach(win->scrollback_indicator_surface, NULL, 0, 0);
|
wl_surface_attach(win->scrollback_indicator.surf, NULL, 0, 0);
|
||||||
wl_surface_commit(win->scrollback_indicator_surface);
|
wl_surface_commit(win->scrollback_indicator.surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scrollback search */
|
/* Scrollback search */
|
||||||
if (win->search_surface != NULL) {
|
if (win->search.surf != NULL) {
|
||||||
wl_surface_attach(win->search_surface, NULL, 0, 0);
|
wl_surface_attach(win->search.surf, NULL, 0, 0);
|
||||||
wl_surface_commit(win->search_surface);
|
wl_surface_commit(win->search.surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CSD */
|
/* CSD */
|
||||||
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
for (size_t i = 0; i < ALEN(win->csd.surface); i++) {
|
||||||
if (win->csd.surface[i] != NULL) {
|
if (win->csd.surface[i].surf != NULL) {
|
||||||
wl_surface_attach(win->csd.surface[i], NULL, 0, 0);
|
wl_surface_attach(win->csd.surface[i].surf, NULL, 0, 0);
|
||||||
wl_surface_commit(win->csd.surface[i]);
|
wl_surface_commit(win->csd.surface[i].surf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1430,26 +1411,15 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
csd_destroy(win);
|
csd_destroy(win);
|
||||||
if (win->render_timer_sub_surface != NULL)
|
wayl_win_subsurface_destroy(&win->search);
|
||||||
wl_subsurface_destroy(win->render_timer_sub_surface);
|
wayl_win_subsurface_destroy(&win->scrollback_indicator);
|
||||||
if (win->render_timer_surface != NULL)
|
wayl_win_subsurface_destroy(&win->render_timer);
|
||||||
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->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)
|
if (win->frame_callback != NULL)
|
||||||
wl_callback_destroy(win->frame_callback);
|
wl_callback_destroy(win->frame_callback);
|
||||||
if (win->xdg_toplevel_decoration != NULL)
|
if (win->xdg_toplevel_decoration != NULL)
|
||||||
|
|
@ -1570,3 +1540,53 @@ wayl_roundtrip(struct wayland *wayl)
|
||||||
wl_display_dispatch_pending(wayl->display);
|
wl_display_dispatch_pending(wayl->display);
|
||||||
wayl_flush(wayl);
|
wayl_flush(wayl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
wayl_win_subsurface_new_with_custom_parent(
|
||||||
|
struct wl_window *win, struct wl_surface *parent,
|
||||||
|
struct wl_surf_subsurf *surf)
|
||||||
|
{
|
||||||
|
struct wayland *wayl = win->term->wl;
|
||||||
|
|
||||||
|
surf->surf = NULL;
|
||||||
|
surf->sub = NULL;
|
||||||
|
|
||||||
|
struct wl_surface *main = wl_compositor_create_surface(wayl->compositor);
|
||||||
|
if (main == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
struct wl_subsurface *sub = wl_subcompositor_get_subsurface(
|
||||||
|
wayl->sub_compositor, main, parent);
|
||||||
|
|
||||||
|
if (sub == NULL) {
|
||||||
|
wl_surface_destroy(main);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_surface_set_user_data(main, win);
|
||||||
|
wl_subsurface_set_sync(sub);
|
||||||
|
|
||||||
|
surf->surf = main;
|
||||||
|
surf->sub = sub;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
wayl_win_subsurface_new(struct wl_window *win, struct wl_surf_subsurf *surf)
|
||||||
|
{
|
||||||
|
return wayl_win_subsurface_new_with_custom_parent(win, win->surface, surf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf)
|
||||||
|
{
|
||||||
|
if (surf == NULL)
|
||||||
|
return;
|
||||||
|
if (surf->sub != NULL)
|
||||||
|
wl_subsurface_destroy(surf->sub);
|
||||||
|
if (surf->surf != NULL)
|
||||||
|
wl_surface_destroy(surf->surf);
|
||||||
|
|
||||||
|
surf->surf = NULL;
|
||||||
|
surf->sub = NULL;
|
||||||
|
}
|
||||||
|
|
|
||||||
32
wayland.h
32
wayland.h
|
|
@ -350,10 +350,14 @@ struct monitor {
|
||||||
bool use_output_release;
|
bool use_output_release;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wl_surf_subsurf {
|
||||||
|
struct wl_surface *surf;
|
||||||
|
struct wl_subsurface *sub;
|
||||||
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -368,21 +372,14 @@ struct wl_window {
|
||||||
enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd;
|
enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_surface *surface[CSD_SURF_COUNT];
|
struct wl_surf_subsurf surface[CSD_SURF_COUNT];
|
||||||
struct wl_subsurface *sub_surface[CSD_SURF_COUNT];
|
|
||||||
int move_timeout_fd;
|
int move_timeout_fd;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
} csd;
|
} csd;
|
||||||
|
|
||||||
/* Scrollback search */
|
struct wl_surf_subsurf search;
|
||||||
struct wl_surface *search_surface;
|
struct wl_surf_subsurf scrollback_indicator;
|
||||||
struct wl_subsurface *search_sub_surface;
|
struct wl_surf_subsurf render_timer;
|
||||||
|
|
||||||
struct wl_surface *scrollback_indicator_surface;
|
|
||||||
struct wl_subsurface *scrollback_indicator_sub_surface;
|
|
||||||
|
|
||||||
struct wl_surface *render_timer_surface;
|
|
||||||
struct wl_subsurface *render_timer_sub_surface;
|
|
||||||
|
|
||||||
struct wl_callback *frame_callback;
|
struct wl_callback *frame_callback;
|
||||||
|
|
||||||
|
|
@ -453,10 +450,17 @@ struct wayland {
|
||||||
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
||||||
void wayl_destroy(struct wayland *wayl);
|
void wayl_destroy(struct wayland *wayl);
|
||||||
|
|
||||||
|
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
||||||
|
|
||||||
void wayl_flush(struct wayland *wayl);
|
void wayl_flush(struct wayland *wayl);
|
||||||
void wayl_roundtrip(struct wayland *wayl);
|
void wayl_roundtrip(struct wayland *wayl);
|
||||||
|
|
||||||
struct wl_window *wayl_win_init(struct terminal *term);
|
struct wl_window *wayl_win_init(struct terminal *term);
|
||||||
void wayl_win_destroy(struct wl_window *win);
|
void wayl_win_destroy(struct wl_window *win);
|
||||||
|
|
||||||
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
bool wayl_win_subsurface_new(
|
||||||
|
struct wl_window *win, struct wl_surf_subsurf *surf);
|
||||||
|
bool wayl_win_subsurface_new_with_custom_parent(
|
||||||
|
struct wl_window *win, struct wl_surface *parent,
|
||||||
|
struct wl_surf_subsurf *surf);
|
||||||
|
void wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue