[PATCH weston 1/2] desktop-shell: Generate serials for pings in the function that sends them

Derek Foreman derekf at osg.samsung.com
Fri Jul 8 17:42:17 UTC 2016


Currently we generate a serial and pass it through a couple of functions.

In a future commit I'm going to throttle pings in the leaf function, so
generating them there prevents consuming them needlessly.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 desktop-shell/shell.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c72f801..4945bc1 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2112,18 +2112,20 @@ xdg_ping_timeout_handler(void *data)
 }
 
 static void
-handle_xdg_ping(struct shell_surface *shsurf, uint32_t serial)
+handle_xdg_ping(struct shell_surface *shsurf)
 {
 	struct weston_compositor *compositor = shsurf->shell->compositor;
 	struct shell_client *sc = shsurf->owner;
 	struct wl_event_loop *loop;
 	static const int ping_timeout = 200;
+	uint32_t serial;
 
 	if (sc->unresponsive) {
 		xdg_ping_timeout_handler(sc);
 		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)
@@ -2144,7 +2146,7 @@ handle_xdg_ping(struct shell_surface *shsurf, uint32_t serial)
 }
 
 static void
-ping_handler(struct weston_surface *surface, uint32_t serial)
+ping_handler(struct weston_surface *surface)
 {
 	struct shell_surface *shsurf = get_shell_surface(surface);
 
@@ -2157,7 +2159,7 @@ ping_handler(struct weston_surface *surface, uint32_t serial)
 	if (!shsurf->owner)
 		return;
 
-	handle_xdg_ping(shsurf, serial);
+	handle_xdg_ping(shsurf);
 }
 
 static void
@@ -2165,15 +2167,11 @@ handle_pointer_focus(struct wl_listener *listener, void *data)
 {
 	struct weston_pointer *pointer = data;
 	struct weston_view *view = pointer->focus;
-	struct weston_compositor *compositor;
-	uint32_t serial;
 
 	if (!view)
 		return;
 
-	compositor = view->surface->compositor;
-	serial = wl_display_next_serial(compositor->wl_display);
-	ping_handler(view->surface, serial);
+	ping_handler(view->surface);
 }
 
 static void
-- 
2.8.1



More information about the wayland-devel mailing list