mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-31 07:11:09 -04:00
wayland: window: apply all configure changes after acking the event
This commit is contained in:
parent
765fe13aff
commit
46c434d3f1
2 changed files with 25 additions and 22 deletions
41
wayland.c
41
wayland.c
|
|
@ -413,7 +413,8 @@ static void
|
||||||
xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
||||||
int32_t width, int32_t height, struct wl_array *states)
|
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
|
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
|
||||||
char state_str[2048];
|
char state_str[2048];
|
||||||
int state_chars = 0;
|
int state_chars = 0;
|
||||||
|
|
@ -434,7 +435,7 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
||||||
wl_array_for_each(state, states) {
|
wl_array_for_each(state, states) {
|
||||||
switch (*state) {
|
switch (*state) {
|
||||||
case XDG_TOPLEVEL_STATE_ACTIVATED:
|
case XDG_TOPLEVEL_STATE_ACTIVATED:
|
||||||
is_focused = true;
|
is_activated = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||||
|
|
@ -467,15 +468,17 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
|
||||||
width, height, state_str);
|
width, height, state_str);
|
||||||
#endif
|
#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 wl_window *win = data;
|
||||||
struct terminal *term = win->term;
|
win->configure.is_activated = is_activated;
|
||||||
|
win->configure.width = width;
|
||||||
if (is_focused)
|
win->configure.height = height;
|
||||||
term_visual_focus_in(term);
|
|
||||||
else
|
|
||||||
term_visual_focus_out(term);
|
|
||||||
|
|
||||||
render_resize(term, width, height, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -499,21 +502,15 @@ xdg_surface_configure(void *data, struct xdg_surface *xdg_surface,
|
||||||
LOG_DBG("xdg-surface: configure");
|
LOG_DBG("xdg-surface: configure");
|
||||||
xdg_surface_ack_configure(xdg_surface, serial);
|
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 wl_window *win = data;
|
||||||
struct terminal *term = win->term;
|
struct terminal *term = win->term;
|
||||||
|
|
||||||
if (term->width > 0 && term->height > 0)
|
if (win->configure.is_activated)
|
||||||
render_refresh(term);
|
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 = {
|
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,12 @@ struct wl_window {
|
||||||
struct wl_callback *frame_callback;
|
struct wl_callback *frame_callback;
|
||||||
|
|
||||||
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
|
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool is_activated;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
} configure;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct config;
|
struct config;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue