mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-07 04:06:07 -05:00
render: store frame callback pointer in terminal struct
This allows us to free it when exiting
This commit is contained in:
parent
d7bb83022d
commit
0d24fcafd0
3 changed files with 11 additions and 7 deletions
4
main.c
4
main.c
|
|
@ -496,7 +496,7 @@ main(int argc, char *const *argv)
|
|||
|
||||
if (ret == 0 || !(timeout_ms != -1 && fds[1].revents & POLLIN)) {
|
||||
/* Delayed rendering */
|
||||
if (!term.frame_is_scheduled)
|
||||
if (term.frame_callback == NULL)
|
||||
grid_render(&term);
|
||||
}
|
||||
|
||||
|
|
@ -584,6 +584,8 @@ out:
|
|||
mtx_unlock(&term.kbd.repeat.mutex);
|
||||
|
||||
shm_fini();
|
||||
if (term.frame_callback != NULL)
|
||||
wl_callback_destroy(term.frame_callback);
|
||||
if (term.wl.xdg_toplevel != NULL)
|
||||
xdg_toplevel_destroy(term.wl.xdg_toplevel);
|
||||
if (term.wl.xdg_surface != NULL)
|
||||
|
|
|
|||
11
render.c
11
render.c
|
|
@ -308,9 +308,9 @@ grid_render(struct terminal *term)
|
|||
cairo_surface_flush(buf->cairo_surface);
|
||||
wl_surface_attach(term->wl.surface, buf->wl_buf, 0, 0);
|
||||
|
||||
struct wl_callback *cb = wl_surface_frame(term->wl.surface);
|
||||
wl_callback_add_listener(cb, &frame_listener, term);
|
||||
term->frame_is_scheduled = true;
|
||||
assert(term->frame_callback == NULL);
|
||||
term->frame_callback = wl_surface_frame(term->wl.surface);
|
||||
wl_callback_add_listener(term->frame_callback, &frame_listener, term);
|
||||
|
||||
wl_surface_commit(term->wl.surface);
|
||||
}
|
||||
|
|
@ -320,8 +320,9 @@ frame_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_da
|
|||
{
|
||||
struct terminal *term = data;
|
||||
|
||||
term->frame_is_scheduled = false;
|
||||
assert(term->frame_callback == wl_callback);
|
||||
wl_callback_destroy(wl_callback);
|
||||
term->frame_callback = NULL;
|
||||
grid_render(term);
|
||||
}
|
||||
|
||||
|
|
@ -435,7 +436,7 @@ render_resize(struct terminal *term, int width, int height)
|
|||
min(term->cursor.col, term->cols - 1));
|
||||
term_damage_all(term);
|
||||
|
||||
if (!term->frame_is_scheduled)
|
||||
if (term->frame_callback == NULL)
|
||||
grid_render(term);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <threads.h>
|
||||
|
||||
#include <cairo.h>
|
||||
#include <wayland-client.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <xkbcommon/xkbcommon-keysyms.h>
|
||||
|
||||
|
|
@ -241,7 +242,7 @@ struct terminal {
|
|||
cairo_font_extents_t fextents;
|
||||
|
||||
struct wayland wl;
|
||||
bool frame_is_scheduled;
|
||||
struct wl_callback *frame_callback;
|
||||
};
|
||||
|
||||
void term_damage_all(struct terminal *term);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue