From 5ec447697c7548fc7930031077e821fd1e26b2f9 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 4 Jan 2020 22:01:19 +0100 Subject: render: throttle xcursor updates With a bad behaving client (e.g. 'less' with mouse support enabled), we can end up with a *lot* of xcursor updates (so much, that we flooded the wayland socket before we implemented a blocking wayl_flush()). Since there's little point in updating the cursor more than once per frame interval, use frame callbacks to throttle the updates. This works more or lesslike normal terminal refreshes: render_xcursor_set() stores the last terminal (window) that had (and updated) the cursor. The renderer's FDM hook checks if we have such a pending terminal set, and if so, tries to refresh the cursor. This is done by first checking if we're already waiting for a callback from a previous cursor update, and if so we do nothing; the callback will update the cursor for the next frame. If we're *not* already waiting for a callback, we update the cursor immediately. --- wayland.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'wayland.h') diff --git a/wayland.h b/wayland.h index ad352797..83a84273 100644 --- a/wayland.h +++ b/wayland.h @@ -152,6 +152,9 @@ struct wayland { int size; char *theme_name; const char *xcursor; + + const struct terminal *pending_terminal; + struct wl_callback *xcursor_callback; } pointer; struct { @@ -184,8 +187,5 @@ void wayl_roundtrip(struct wayland *wayl); struct terminal *wayl_terminal_from_surface( struct wayland *wayl, struct wl_surface *surface); -/* TODO: pass something other than 'term'? Need scale... */ -bool wayl_cursor_set(struct wayland *wayl, const struct terminal *term); - struct wl_window *wayl_win_init(struct terminal *term); void wayl_win_destroy(struct wl_window *win); -- cgit v1.3