term: move per-window wayland objects from wayland struct to terminal struct

Short term, we want to break out the wayland backend from the terminal
struct. Long term, we might want to support multiple windows.

One step towards both the above is separating global wayland objects
from per-window objects.
This commit is contained in:
Daniel Eklöf 2019-10-27 12:57:37 +01:00
parent 5fefb950b3
commit f63458ef33
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 84 additions and 80 deletions

View file

@ -330,7 +330,8 @@ grid_render_scroll(struct terminal *term, struct buffer *buf,
raw + src_y * buf->stride,
height * buf->stride);
wl_surface_damage_buffer(term->wl.surface, term->x_margin, dst_y, term->width - term->x_margin, height);
wl_surface_damage_buffer(
term->window.surface, term->x_margin, dst_y, term->width - term->x_margin, height);
}
}
@ -355,7 +356,8 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
raw + src_y * buf->stride,
height * buf->stride);
wl_surface_damage_buffer(term->wl.surface, term->x_margin, dst_y, term->width - term->x_margin, height);
wl_surface_damage_buffer(
term->window.surface, term->x_margin, dst_y, term->width - term->x_margin, height);
}
}
@ -439,7 +441,7 @@ grid_render(struct terminal *term)
assert(term->height > 0);
struct buffer *buf = shm_get_buffer(term->wl.shm, term->width, term->height, 1 + term->render.workers.count);
wl_surface_attach(term->wl.surface, buf->wl_buf, 0, 0);
wl_surface_attach(term->window.surface, buf->wl_buf, 0, 0);
pixman_image_t *pix = buf->pix;
bool all_clean = tll_length(term->grid->scroll_damage) == 0;
@ -487,13 +489,13 @@ grid_render(struct terminal *term)
{0, bmargin, term->width, bmargin_height}}); /* Bottom */
wl_surface_damage_buffer(
term->wl.surface, 0, 0, term->width, term->y_margin);
term->window.surface, 0, 0, term->width, term->y_margin);
wl_surface_damage_buffer(
term->wl.surface, 0, 0, term->x_margin, term->height);
term->window.surface, 0, 0, term->x_margin, term->height);
wl_surface_damage_buffer(
term->wl.surface, rmargin, 0, rmargin_width, term->height);
term->window.surface, rmargin, 0, rmargin_width, term->height);
wl_surface_damage_buffer(
term->wl.surface, 0, bmargin, term->width, bmargin_height);
term->window.surface, 0, bmargin, term->width, bmargin_height);
/* Force a full grid refresh */
term_damage_view(term);
@ -514,7 +516,7 @@ grid_render(struct terminal *term)
render_cell(term, pix, cell, at.col, at.row, false);
wl_surface_damage_buffer(
term->wl.surface,
term->window.surface,
term->x_margin + at.col * term->cell_width,
term->y_margin + at.row * term->cell_height,
term->cell_width, term->cell_height);
@ -567,7 +569,7 @@ grid_render(struct terminal *term)
all_clean = false;
wl_surface_damage_buffer(
term->wl.surface,
term->window.surface,
term->x_margin, term->y_margin + r * term->cell_height,
term->width - term->x_margin, term->cell_height);
}
@ -590,7 +592,7 @@ grid_render(struct terminal *term)
all_clean = false;
wl_surface_damage_buffer(
term->wl.surface,
term->window.surface,
term->x_margin, term->y_margin + r * term->cell_height,
term->width - term->x_margin, term->cell_height);
}
@ -672,7 +674,7 @@ grid_render(struct terminal *term)
term, pix, cell, term->cursor.col, view_aligned_row, true);
wl_surface_damage_buffer(
term->wl.surface,
term->window.surface,
term->x_margin + term->cursor.col * term->cell_width,
term->y_margin + view_aligned_row * term->cell_height,
cols_updated * term->cell_width, term->cell_height);
@ -692,18 +694,18 @@ grid_render(struct terminal *term)
1, &(pixman_rectangle16_t){0, 0, term->width, term->height});
wl_surface_damage_buffer(
term->wl.surface, 0, 0, term->width, term->height);
term->window.surface, 0, 0, term->width, term->height);
}
assert(term->grid->offset >= 0 && term->grid->offset < term->grid->num_rows);
assert(term->grid->view >= 0 && term->grid->view < term->grid->num_rows);
assert(term->render.frame_callback == NULL);
term->render.frame_callback = wl_surface_frame(term->wl.surface);
term->render.frame_callback = wl_surface_frame(term->window.surface);
wl_callback_add_listener(term->render.frame_callback, &frame_listener, term);
wl_surface_set_buffer_scale(term->wl.surface, term->scale);
wl_surface_commit(term->wl.surface);
wl_surface_set_buffer_scale(term->window.surface, term->scale);
wl_surface_commit(term->window.surface);
#if TIME_FRAME_RENDERING
struct timeval end_time;
@ -730,7 +732,7 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
void
render_search_box(struct terminal *term)
{
assert(term->wl.search_sub_surface != NULL);
assert(term->window.search_sub_surface != NULL);
/* TODO: at least sway allows the subsurface to extend outside the
* main window. Do we want that? */
@ -778,13 +780,13 @@ render_search_box(struct terminal *term)
draw_bar(term, buf->pix, font, &fg, x, y);
wl_subsurface_set_position(
term->wl.search_sub_surface,
term->window.search_sub_surface,
term->width - width - margin, term->height - height - margin);
wl_surface_damage_buffer(term->wl.search_surface, 0, 0, width, height);
wl_surface_attach(term->wl.search_surface, buf->wl_buf, 0, 0);
wl_surface_set_buffer_scale(term->wl.search_surface, scale);
wl_surface_commit(term->wl.search_surface);
wl_surface_damage_buffer(term->window.search_surface, 0, 0, width, height);
wl_surface_attach(term->window.search_surface, buf->wl_buf, 0, 0);
wl_surface_set_buffer_scale(term->window.search_surface, scale);
wl_surface_commit(term->window.search_surface);
}
static void
@ -816,7 +818,7 @@ void
render_resize(struct terminal *term, int width, int height)
{
int scale = -1;
tll_foreach(term->wl.on_outputs, it) {
tll_foreach(term->window.on_outputs, it) {
if (it->item->scale > scale)
scale = it->item->scale;
}
@ -937,7 +939,7 @@ render_resize(struct terminal *term, int width, int height)
void
render_set_title(struct terminal *term, const char *title)
{
xdg_toplevel_set_title(term->wl.xdg_toplevel, title);
xdg_toplevel_set_title(term->window.xdg_toplevel, title);
}
bool