Currently we can end up sending pings to popups every screen redraw and every pointer move when they're focused. Instead let's send a maximum of 1 every 200ms by letting the ping timer expire before we send another ping.
With the old code I've logged 400+ pings per second on the right click pop-up. This is easily reproducible with a high refresh rate mouse. Signed-off-by: Derek Foreman <[email protected]> --- desktop-shell/shell.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 4945bc1..e2a903a 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -243,6 +243,7 @@ struct shell_client { uint32_t ping_serial; int unresponsive; struct wl_list surface_list; + bool ponged; }; static struct desktop_shell * @@ -2092,6 +2093,11 @@ xdg_ping_timeout_handler(void *data) struct weston_seat *seat; struct shell_surface *shsurf; + if (sc->ponged) { + wl_event_source_remove(sc->ping_timer); + sc->ping_timer = NULL; + return 1; + } /* Client is not responding */ sc->unresponsive = 1; wl_list_for_each(seat, &sc->shell->compositor->seat_list, link) { @@ -2125,13 +2131,18 @@ handle_xdg_ping(struct shell_surface *shsurf) return; } + if (sc->ping_timer) + return; + serial = wl_display_next_serial(compositor->wl_display); sc->ping_serial = serial; loop = wl_display_get_event_loop(compositor->wl_display); - if (sc->ping_timer == NULL) + if (sc->ping_timer == NULL) { + sc->ponged = false; sc->ping_timer = wl_event_loop_add_timer(loop, xdg_ping_timeout_handler, sc); + } if (sc->ping_timer == NULL) return; @@ -2218,11 +2229,7 @@ shell_client_pong(struct shell_client *sc, uint32_t serial) sc->unresponsive = 0; end_busy_cursor(sc->shell->compositor, sc->client); - if (sc->ping_timer) { - wl_event_source_remove(sc->ping_timer); - sc->ping_timer = NULL; - } - + sc->ponged = true; } static void -- 2.8.1 _______________________________________________ wayland-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/wayland-devel
