mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-06 07:15:30 -04:00
wayland: throttle xdg activation token requests for window urgency
When XDG activation support was added to URL mode, we introduced a regression, where it is possible to flood the Wayland socket with XDG activation token requests. Start foot with “foot -o bell.urgency=yes”, then run: while true; do echo -en ‘\a’; done Finally, switch keyboard focus to another window. Foot crashes. Throttle the token requests by limiting the number of outstanding urgency token requests to 1. Closes #1065
This commit is contained in:
parent
fc67bff9c0
commit
200c5cbc79
2 changed files with 16 additions and 3 deletions
18
wayland.c
18
wayland.c
|
|
@ -1715,6 +1715,7 @@ activation_token_for_urgency_done(const char *token, void *data)
|
||||||
struct wl_window *win = data;
|
struct wl_window *win = data;
|
||||||
struct wayland *wayl = win->term->wl;
|
struct wayland *wayl = win->term->wl;
|
||||||
|
|
||||||
|
win->urgency_token_is_pending = false;
|
||||||
xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface);
|
xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XDG_ACTIVATION */
|
#endif /* HAVE_XDG_ACTIVATION */
|
||||||
|
|
@ -1723,11 +1724,22 @@ bool
|
||||||
wayl_win_set_urgent(struct wl_window *win)
|
wayl_win_set_urgent(struct wl_window *win)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_XDG_ACTIVATION)
|
#if defined(HAVE_XDG_ACTIVATION)
|
||||||
return wayl_get_activation_token(
|
if (win->urgency_token_is_pending) {
|
||||||
|
/* We already have a pending token. Don’t request another one,
|
||||||
|
* to avoid flooding the Wayland socket */
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success = wayl_get_activation_token(
|
||||||
win->term->wl, NULL, 0, win, &activation_token_for_urgency_done, win);
|
win->term->wl, NULL, 0, win, &activation_token_for_urgency_done, win);
|
||||||
#else
|
|
||||||
return false;
|
if (success) {
|
||||||
|
win->urgency_token_is_pending = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ struct wl_window {
|
||||||
struct xdg_toplevel *xdg_toplevel;
|
struct xdg_toplevel *xdg_toplevel;
|
||||||
#if defined(HAVE_XDG_ACTIVATION)
|
#if defined(HAVE_XDG_ACTIVATION)
|
||||||
tll(struct xdg_activation_token_context *) xdg_tokens;
|
tll(struct xdg_activation_token_context *) xdg_tokens;
|
||||||
|
bool urgency_token_is_pending;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue