From c94da979fbe3d0267373717fc87654caa0bcfa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 3 Jan 2020 12:45:58 +0100 Subject: [PATCH] wayland: xdg-surface-configure: refresh terminal Any changes done in any of the configure events are ignored before we've ack:ed the configure event. In particular, this means the resize done in xdg-toplevel-configure isn't displayed until the next time we call render_refresh(). Unless we do something ourselves, this can take quite some time, since we're basically need the slave to write something. So, in xdg-surface-configure, *after* having ack:ed the configure event, call render_refresh() to make the changes done in xdg-toplevel-configure visible as soon as possible. --- wayland.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/wayland.c b/wayland.c index ea4b2d40..76c2f5d3 100644 --- a/wayland.c +++ b/wayland.c @@ -453,8 +453,23 @@ static void xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) { - //LOG_DBG("xdg-surface: configure"); + LOG_DBG("xdg-surface: configure"); xdg_surface_ack_configure(xdg_surface, serial); + + /* + * Changes done in e.g. xdg-toplevel-configure will be ignored + * since the 'configure' event hasn't been ack:ed yet. + * + * Unfortunately, *this* function is called *last*, meaning we + * have no way of acking the configure before we resize the + * terminal in xdg-toplevel-configure. + * + * So, refresh here, to ensure changes take effect as soon as possible. + */ + struct wayland *wayl = data; + struct terminal *term = wayl_terminal_from_xdg_surface(wayl, xdg_surface); + if (term->width > 0 && term->height > 0) + render_refresh(term); } static const struct xdg_surface_listener xdg_surface_listener = { @@ -946,6 +961,19 @@ wayl_terminal_from_surface(struct wayland *wayl, struct wl_surface *surface) return NULL; } +struct terminal * +wayl_terminal_from_xdg_surface(struct wayland *wayl, + struct xdg_surface *surface) +{ + tll_foreach(wayl->terms, it) { + if (it->item->window->xdg_surface == surface) + return it->item; + } + + assert(false); + return NULL; +} + struct terminal * wayl_terminal_from_xdg_toplevel(struct wayland *wayl, struct xdg_toplevel *toplevel)