aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-10-27 11:57:37 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-10-27 11:57:37 +0000
commitf63458ef3387eac67a402e6ce7bedd91eb49d9bc (patch)
tree44d2c73d0adc6b0d5e06e40298d10ecfa0a94f21 /render.c
parentfdm: use the FDM's poll loop (diff)
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.
Diffstat (limited to 'render.c')
-rw-r--r--render.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/render.c b/render.c
index ff05d501..9f9d720c 100644
--- a/render.c
+++ b/render.c
@@ -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