aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-10-30 16:31:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-10-30 16:31:44 +0000
commitad0f8a02d56709bd59211ff6a5d485a380d708f0 (patch)
treecfabf659cbb1cf2219b982842f5d7b1249034f78 /render.c
parentscrollback: regression: fix rendering of scrollback diffs less than a screen (diff)
parentslave: rename slave_spawn() -> slave_exec() (diff)
Merge branch 'fdm'
Diffstat (limited to 'render.c')
-rw-r--r--render.c118
1 files changed, 33 insertions, 85 deletions
diff --git a/render.c b/render.c
index ca127389..29f2ebf0 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);
}
}
@@ -372,6 +374,7 @@ render_worker_thread(void *_ctx)
struct render_worker_context *ctx = _ctx;
struct terminal *term = ctx->term;
const int my_id = ctx->my_id;
+ free(ctx);
char proc_title[16];
snprintf(proc_title, sizeof(proc_title), "foot:render:%d", my_id);
@@ -438,8 +441,8 @@ grid_render(struct terminal *term)
assert(term->width > 0);
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);
+ struct buffer *buf = shm_get_buffer(term->wl->shm, term->width, term->height, 1 + term->render.workers.count);
+ 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 +490,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 +517,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);
@@ -577,7 +580,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);
}
@@ -600,7 +603,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);
}
@@ -682,7 +685,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);
@@ -702,18 +705,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);
- wl_callback_add_listener(term->render.frame_callback, &frame_listener, term);
+ assert(term->window->frame_callback == NULL);
+ term->window->frame_callback = wl_surface_frame(term->window->surface);
+ wl_callback_add_listener(term->window->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;
@@ -731,16 +734,16 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
{
struct terminal *term = data;
- assert(term->render.frame_callback == wl_callback);
+ assert(term->window->frame_callback == wl_callback);
wl_callback_destroy(wl_callback);
- term->render.frame_callback = NULL;
+ term->window->frame_callback = NULL;
grid_render(term);
}
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? */
@@ -749,7 +752,7 @@ render_search_box(struct terminal *term)
const int width = 2 * margin + max(20, term->search.len) * term->cell_width;
const int height = 2 * margin + 1 * term->cell_height;
- struct buffer *buf = shm_get_buffer(term->wl.shm, width, height, 1);
+ struct buffer *buf = shm_get_buffer(term->wl->shm, width, height, 1);
/* Background - yellow on empty/match, red on mismatch */
pixman_color_t color = color_hex_to_pixman(
@@ -788,13 +791,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
@@ -826,7 +829,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;
}
@@ -947,67 +950,12 @@ 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);
-}
-
-bool
-render_reload_cursor_theme(struct terminal *term)
-{
- if (term->wl.pointer.size == 0)
- return true;
-
- if (term->wl.pointer.theme != NULL) {
- wl_cursor_theme_destroy(term->wl.pointer.theme);
- term->wl.pointer.theme = NULL;
- term->wl.pointer.cursor = NULL;
- }
-
- LOG_DBG("reloading cursor theme: %s@%d",
- term->wl.pointer.theme_name, term->wl.pointer.size);
-
- term->wl.pointer.theme = wl_cursor_theme_load(
- term->wl.pointer.theme_name, term->wl.pointer.size * term->scale, term->wl.shm);
- if (term->wl.pointer.theme == NULL) {
- LOG_ERR("failed to load cursor theme");
- return false;
- }
-
- term->wl.pointer.cursor = wl_cursor_theme_get_cursor(
- term->wl.pointer.theme, "left_ptr");
- assert(term->wl.pointer.cursor != NULL);
- render_update_cursor_surface(term);
-
- return true;
-}
-
-void
-render_update_cursor_surface(struct terminal *term)
-{
- if (term->wl.pointer.cursor == NULL)
- return;
-
- const int scale = term->scale;
- wl_surface_set_buffer_scale(term->wl.pointer.surface, scale);
-
- struct wl_cursor_image *image = term->wl.pointer.cursor->images[0];
-
- wl_surface_attach(
- term->wl.pointer.surface, wl_cursor_image_get_buffer(image), 0, 0);
-
- wl_pointer_set_cursor(
- term->wl.pointer.pointer, term->wl.pointer.serial,
- term->wl.pointer.surface,
- image->hotspot_x / scale, image->hotspot_y / scale);
-
- wl_surface_damage_buffer(
- term->wl.pointer.surface, 0, 0, INT32_MAX, INT32_MAX);
-
- wl_surface_commit(term->wl.pointer.surface);
+ xdg_toplevel_set_title(term->window->xdg_toplevel, title);
}
void
render_refresh(struct terminal *term)
{
- if (term->render.frame_callback == NULL)
+ if (term->window->frame_callback == NULL)
grid_render(term);
}