aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-03 12:54:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-03 12:54:44 +0000
commit46c434d3f10f0312211c2dc1360aed3e2ad0001b (patch)
tree4b4074549ee01f9e250c1547bc8ae971bf2016b5
parentwayland: remove wayl_terminal_from_xdg_{surface,toplevel} (diff)
wayland: window: apply all configure changes after acking the event
-rw-r--r--wayland.c41
-rw-r--r--wayland.h6
2 files changed, 25 insertions, 22 deletions
diff --git a/wayland.c b/wayland.c
index a015fdb6..033670df 100644
--- a/wayland.c
+++ b/wayland.c
@@ -413,7 +413,8 @@ static void
xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
int32_t width, int32_t height, struct wl_array *states)
{
- bool is_focused = false;
+ bool is_activated = false;
+
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
char state_str[2048];
int state_chars = 0;
@@ -434,7 +435,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
wl_array_for_each(state, states) {
switch (*state) {
case XDG_TOPLEVEL_STATE_ACTIVATED:
- is_focused = true;
+ is_activated = true;
break;
case XDG_TOPLEVEL_STATE_MAXIMIZED:
@@ -467,15 +468,17 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
width, height, state_str);
#endif
+ /*
+ * Changes done here are ignored until the configure event has
+ * been ack:ed in xdg_surface_configure().
+ *
+ * So, just store the config data and apply it later, in
+ * xdg_surface_configure() after we've ack:ed the event.
+ */
struct wl_window *win = data;
- struct terminal *term = win->term;
-
- if (is_focused)
- term_visual_focus_in(term);
- else
- term_visual_focus_out(term);
-
- render_resize(term, width, height, false);
+ win->configure.is_activated = is_activated;
+ win->configure.width = width;
+ win->configure.height = height;
}
static void
@@ -499,21 +502,15 @@ xdg_surface_configure(void *data, struct xdg_surface *xdg_surface,
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 wl_window *win = data;
struct terminal *term = win->term;
- if (term->width > 0 && term->height > 0)
- render_refresh(term);
+ if (win->configure.is_activated)
+ term_visual_focus_in(term);
+ else
+ term_visual_focus_out(term);
+
+ render_resize(term, win->configure.width, win->configure.height, true);
}
static const struct xdg_surface_listener xdg_surface_listener = {
diff --git a/wayland.h b/wayland.h
index 99b678fb..f802bcc7 100644
--- a/wayland.h
+++ b/wayland.h
@@ -98,6 +98,12 @@ struct wl_window {
struct wl_callback *frame_callback;
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
+
+ struct {
+ bool is_activated;
+ int width;
+ int height;
+ } configure;
};
struct config;