mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-13 05:33:51 -04:00
term: wayland struct is now not a part of the terminal struct
We do however need access to it, so provide a pointer. The difference is that now we can have a *single* wayland instance, but multiple terminal instances.
This commit is contained in:
parent
33e4b8a5b8
commit
1adab32906
8 changed files with 115 additions and 114 deletions
44
render.c
44
render.c
|
|
@ -440,7 +440,7 @@ 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);
|
||||
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;
|
||||
|
||||
|
|
@ -741,7 +741,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(
|
||||
|
|
@ -945,28 +945,28 @@ render_set_title(struct terminal *term, const char *title)
|
|||
bool
|
||||
render_reload_cursor_theme(struct terminal *term)
|
||||
{
|
||||
if (term->wl.pointer.size == 0)
|
||||
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;
|
||||
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_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) {
|
||||
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);
|
||||
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;
|
||||
|
|
@ -975,26 +975,26 @@ render_reload_cursor_theme(struct terminal *term)
|
|||
void
|
||||
render_update_cursor_surface(struct terminal *term)
|
||||
{
|
||||
if (term->wl.pointer.cursor == NULL)
|
||||
if (term->wl->pointer.cursor == NULL)
|
||||
return;
|
||||
|
||||
const int scale = term->scale;
|
||||
wl_surface_set_buffer_scale(term->wl.pointer.surface, scale);
|
||||
wl_surface_set_buffer_scale(term->wl->pointer.surface, scale);
|
||||
|
||||
struct wl_cursor_image *image = term->wl.pointer.cursor->images[0];
|
||||
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);
|
||||
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,
|
||||
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);
|
||||
term->wl->pointer.surface, 0, 0, INT32_MAX, INT32_MAX);
|
||||
|
||||
wl_surface_commit(term->wl.pointer.surface);
|
||||
wl_surface_commit(term->wl->pointer.surface);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue