aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c23
-rw-r--r--render.c12
-rw-r--r--terminal.h1
-rw-r--r--wayland.c24
-rw-r--r--wayland.h4
5 files changed, 37 insertions, 27 deletions
diff --git a/main.c b/main.c
index 7487705f..267bd89f 100644
--- a/main.c
+++ b/main.c
@@ -463,7 +463,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
* ourselves we just received keyboard input, and in
* this case *not* delay rendering?
*/
- if (term->render.frame_callback == NULL) {
+ if (term->window.frame_callback == NULL) {
/* First timeout - reset each time we receive input. */
timerfd_settime(
term->delayed_render_timer.lower_fd, 0,
@@ -1151,7 +1151,6 @@ out:
shm_fini();
- tll_free(term.window.on_outputs);
if (term.selection.clipboard.data_source != NULL)
wl_data_source_destroy(term.selection.clipboard.data_source);
if (term.selection.clipboard.data_offer != NULL)
@@ -1172,24 +1171,8 @@ out:
xkb_state_unref(term.kbd.xkb_state);
if (term.kbd.xkb != NULL)
xkb_context_unref(term.kbd.xkb);
- if (term.window.search_sub_surface != NULL)
- wl_subsurface_destroy(term.window.search_sub_surface);
- if (term.window.search_surface != NULL)
- wl_surface_destroy(term.window.search_surface);
- if (term.render.frame_callback != NULL)
- wl_callback_destroy(term.render.frame_callback);
- if (term.window.xdg_toplevel_decoration != NULL)
- zxdg_toplevel_decoration_v1_destroy(term.window.xdg_toplevel_decoration);
- if (term.window.xdg_decoration_manager != NULL)
- zxdg_decoration_manager_v1_destroy(term.window.xdg_decoration_manager);
- if (term.window.xdg_toplevel != NULL)
- xdg_toplevel_destroy(term.window.xdg_toplevel);
- if (term.window.xdg_surface != NULL)
- xdg_surface_destroy(term.window.xdg_surface);
- if (term.window.shell != NULL)
- xdg_wm_base_destroy(term.window.shell);
- if (term.window.surface != NULL)
- wl_surface_destroy(term.window.surface);
+
+ wayl_win_destroy(&term.window);
wayl_destroy(&term.wl);
free(term.vt.osc.data);
diff --git a/render.c b/render.c
index 9f9d720c..c2840eb8 100644
--- a/render.c
+++ b/render.c
@@ -700,9 +700,9 @@ grid_render(struct terminal *term)
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->window.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->window.surface, term->scale);
wl_surface_commit(term->window.surface);
@@ -723,9 +723,9 @@ 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);
}
@@ -1000,6 +1000,6 @@ render_update_cursor_surface(struct terminal *term)
void
render_refresh(struct terminal *term)
{
- if (term->render.frame_callback == NULL)
+ if (term->window.frame_callback == NULL)
grid_render(term);
}
diff --git a/terminal.h b/terminal.h
index e1756632..df70347d 100644
--- a/terminal.h
+++ b/terminal.h
@@ -314,7 +314,6 @@ struct terminal {
struct {
int scrollback_lines;
- struct wl_callback *frame_callback;
struct {
size_t count;
diff --git a/wayland.c b/wayland.c
index 4a8ad23f..9b00f5bb 100644
--- a/wayland.c
+++ b/wayland.c
@@ -64,3 +64,27 @@ wayl_destroy(struct wayland *wayl)
if (wayl->display != NULL)
wl_display_disconnect(wayl->display);
}
+
+void
+wayl_win_destroy(struct wl_window *win)
+{
+ tll_free(win->on_outputs);
+ if (win->search_sub_surface != NULL)
+ wl_subsurface_destroy(win->search_sub_surface);
+ if (win->search_surface != NULL)
+ wl_surface_destroy(win->search_surface);
+ if (win->frame_callback != NULL)
+ wl_callback_destroy(win->frame_callback);
+ if (win->xdg_toplevel_decoration != NULL)
+ zxdg_toplevel_decoration_v1_destroy(win->xdg_toplevel_decoration);
+ if (win->xdg_decoration_manager != NULL)
+ zxdg_decoration_manager_v1_destroy(win->xdg_decoration_manager);
+ if (win->xdg_toplevel != NULL)
+ xdg_toplevel_destroy(win->xdg_toplevel);
+ if (win->xdg_surface != NULL)
+ xdg_surface_destroy(win->xdg_surface);
+ if (win->shell != NULL)
+ xdg_wm_base_destroy(win->shell);
+ if (win->surface != NULL)
+ wl_surface_destroy(win->surface);
+}
diff --git a/wayland.h b/wayland.h
index 81d622fe..cbd0392c 100644
--- a/wayland.h
+++ b/wayland.h
@@ -40,6 +40,8 @@ struct wl_window {
struct wl_surface *search_surface;
struct wl_subsurface *search_sub_surface;
+ struct wl_callback *frame_callback;
+
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
};
@@ -79,3 +81,5 @@ struct wayland {
/* TODO: return allocated pointer */
void wayl_init(struct wayland *wayl);
void wayl_destroy(struct wayland *wayl);
+
+void wayl_win_destroy(struct wl_window *win);