<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 17, 2014 at 12:28 AM, Kristian Høgsberg <span dir="ltr"><<a href="mailto:hoegsberg@gmail.com" target="_blank">hoegsberg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Wed, Apr 16, 2014 at 09:12:10PM -0500, Jason Ekstrand wrote:<br>
> We now carry the shell_client around with each shell_surface. This is much<br>
> more reliable than tacitly assuming that there is only one wl_shell or<br>
> xdg_shell instance bound to a particular wl_client. In particular, weston<br>
> would crash when a client bound to both wl_shell and xdg_shell even if it<br>
> only ever used one of them.<br>
<br>
</div>That makes sense. Is there a bugzilla bug that this fixes or did you just<br>
hit that crasher locally? Patch applied.<br></blockquote><div><br></div><div>Just locally. I started adding xdg_shell support to compositor-wayland last night. For now, it still binds to both wl_shell and xdg_shell so I hit the code-path.<br>
<br></div><div>--Jason Ekstrand<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Kristian<br>
<div><div class="h5"><br>
> Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
> ---<br>
> desktop-shell/shell.c | 54 +++++++++++++++++++++------------------------------<br>
> 1 file changed, 22 insertions(+), 32 deletions(-)<br>
><br>
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c<br>
> index 59fa99c..0e4329b 100644<br>
> --- a/desktop-shell/shell.c<br>
> +++ b/desktop-shell/shell.c<br>
> @@ -63,6 +63,8 @@ enum shell_surface_type {<br>
> SHELL_SURFACE_XWAYLAND<br>
> };<br>
><br>
> +struct shell_client;<br>
> +<br>
> /*<br>
> * Surface stacking and ordering.<br>
> *<br>
> @@ -104,6 +106,7 @@ enum shell_surface_type {<br>
> struct shell_surface {<br>
> struct wl_resource *resource;<br>
> struct wl_signal destroy_signal;<br>
> + struct shell_client *owner;<br>
><br>
> struct weston_surface *surface;<br>
> struct weston_view *view;<br>
> @@ -233,9 +236,6 @@ set_alpha_if_fullscreen(struct shell_surface *shsurf)<br>
> shsurf->fullscreen.black_view->alpha = 0.25;<br>
> }<br>
><br>
> -static struct shell_client *<br>
> -get_shell_client(struct wl_client *client);<br>
> -<br>
> static struct desktop_shell *<br>
> shell_surface_get_shell(struct shell_surface *shsurf);<br>
><br>
> @@ -1859,12 +1859,10 @@ static void<br>
> handle_xdg_ping(struct shell_surface *shsurf, uint32_t serial)<br>
> {<br>
> struct weston_compositor *compositor = shsurf->shell->compositor;<br>
> - struct wl_client *client = wl_resource_get_client(shsurf->resource);<br>
> - struct shell_client *sc;<br>
> + struct shell_client *sc = shsurf->owner;<br>
> struct wl_event_loop *loop;<br>
> static const int ping_timeout = 200;<br>
><br>
> - sc = get_shell_client(client);<br>
> if (sc->unresponsive) {<br>
> xdg_ping_timeout_handler(sc);<br>
> return;<br>
> @@ -1982,19 +1980,6 @@ create_keyboard_focus_listener(struct weston_seat *seat)<br>
> wl_signal_add(&seat->keyboard->focus_signal, listener);<br>
> }<br>
><br>
> -static struct shell_client *<br>
> -get_shell_client(struct wl_client *client)<br>
> -{<br>
> - struct wl_listener *listener;<br>
> -<br>
> - listener = wl_client_get_destroy_listener(client,<br>
> - handle_shell_client_destroy);<br>
> - if (listener == NULL)<br>
> - return NULL;<br>
> -<br>
> - return container_of(listener, struct shell_client, destroy_listener);<br>
> -}<br>
> -<br>
> static void<br>
> shell_client_pong(struct shell_client *sc, uint32_t serial)<br>
> {<br>
> @@ -2015,9 +2000,9 @@ static void<br>
> shell_surface_pong(struct wl_client *client,<br>
> struct wl_resource *resource, uint32_t serial)<br>
> {<br>
> - struct shell_client *sc;<br>
> + struct shell_surface *shsurf = wl_resource_get_user_data(resource);<br>
> + struct shell_client *sc = shsurf->owner;<br>
><br>
> - sc = get_shell_client(client);<br>
> shell_client_pong(sc, serial);<br>
> }<br>
><br>
> @@ -3105,7 +3090,8 @@ get_shell_surface(struct weston_surface *surface)<br>
> }<br>
><br>
> static struct shell_surface *<br>
> -create_common_surface(void *shell, struct weston_surface *surface,<br>
> +create_common_surface(struct shell_client *owner, void *shell,<br>
> + struct weston_surface *surface,<br>
> const struct weston_shell_client *client)<br>
> {<br>
> struct shell_surface *shsurf;<br>
> @@ -3134,6 +3120,7 @@ create_common_surface(void *shell, struct weston_surface *surface,<br>
> shsurf->resource_destroy_listener.notify = handle_resource_destroy;<br>
> wl_resource_add_destroy_listener(surface->resource,<br>
> &shsurf->resource_destroy_listener);<br>
> + shsurf->owner = owner;<br>
><br>
> shsurf->shell = (struct desktop_shell *) shell;<br>
> shsurf->unresponsive = 0;<br>
> @@ -3176,7 +3163,7 @@ static struct shell_surface *<br>
> create_shell_surface(void *shell, struct weston_surface *surface,<br>
> const struct weston_shell_client *client)<br>
> {<br>
> - return create_common_surface(shell, surface, client);<br>
> + return create_common_surface(NULL, shell, surface, client);<br>
> }<br>
><br>
> static struct weston_view *<br>
> @@ -3193,7 +3180,8 @@ shell_get_shell_surface(struct wl_client *client,<br>
> {<br>
> struct weston_surface *surface =<br>
> wl_resource_get_user_data(surface_resource);<br>
> - struct desktop_shell *shell = wl_resource_get_user_data(resource);<br>
> + struct shell_client *sc = wl_resource_get_user_data(resource);<br>
> + struct desktop_shell *shell = sc->shell;<br>
> struct shell_surface *shsurf;<br>
><br>
> if (get_shell_surface(surface)) {<br>
> @@ -3203,7 +3191,7 @@ shell_get_shell_surface(struct wl_client *client,<br>
> return;<br>
> }<br>
><br>
> - shsurf = create_shell_surface(shell, surface, &shell_client);<br>
> + shsurf = create_common_surface(sc, shell, surface, &shell_client);<br>
> if (!shsurf) {<br>
> wl_resource_post_error(surface_resource,<br>
> WL_DISPLAY_ERROR_INVALID_OBJECT,<br>
> @@ -3447,12 +3435,13 @@ xdg_use_unstable_version(struct wl_client *client,<br>
> }<br>
><br>
> static struct shell_surface *<br>
> -create_xdg_surface(void *shell, struct weston_surface *surface,<br>
> +create_xdg_surface(struct shell_client *owner, void *shell,<br>
> + struct weston_surface *surface,<br>
> const struct weston_shell_client *client)<br>
> {<br>
> struct shell_surface *shsurf;<br>
><br>
> - shsurf = create_common_surface(shell, surface, client);<br>
> + shsurf = create_common_surface(owner, shell, surface, client);<br>
> shsurf->type = SHELL_SURFACE_TOPLEVEL;<br>
><br>
> return shsurf;<br>
> @@ -3477,7 +3466,7 @@ xdg_get_xdg_surface(struct wl_client *client,<br>
> return;<br>
> }<br>
><br>
> - shsurf = create_xdg_surface(shell, surface, &xdg_client);<br>
> + shsurf = create_xdg_surface(sc, shell, surface, &xdg_client);<br>
> if (!shsurf) {<br>
> wl_resource_post_error(surface_resource,<br>
> WL_DISPLAY_ERROR_INVALID_OBJECT,<br>
> @@ -3526,7 +3515,8 @@ static const struct weston_shell_client xdg_popup_client = {<br>
> };<br>
><br>
> static struct shell_surface *<br>
> -create_xdg_popup(void *shell, struct weston_surface *surface,<br>
> +create_xdg_popup(struct shell_client *owner, void *shell,<br>
> + struct weston_surface *surface,<br>
> const struct weston_shell_client *client,<br>
> struct weston_surface *parent,<br>
> struct shell_seat *seat,<br>
> @@ -3535,7 +3525,7 @@ create_xdg_popup(void *shell, struct weston_surface *surface,<br>
> {<br>
> struct shell_surface *shsurf;<br>
><br>
> - shsurf = create_common_surface(shell, surface, client);<br>
> + shsurf = create_common_surface(owner, shell, surface, client);<br>
> shsurf->type = SHELL_SURFACE_POPUP;<br>
> shsurf->popup.shseat = seat;<br>
> shsurf->popup.serial = serial;<br>
> @@ -3580,7 +3570,7 @@ xdg_get_xdg_popup(struct wl_client *client,<br>
> parent = wl_resource_get_user_data(parent_resource);<br>
> seat = get_shell_seat(wl_resource_get_user_data(seat_resource));;<br>
><br>
> - shsurf = create_xdg_popup(shell, surface, &xdg_popup_client,<br>
> + shsurf = create_xdg_popup(sc, shell, surface, &xdg_popup_client,<br>
> parent, seat, serial, x, y);<br>
> if (!shsurf) {<br>
> wl_resource_post_error(surface_resource,<br>
> @@ -5070,7 +5060,7 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)<br>
> if (sc)<br>
> wl_resource_set_implementation(sc->resource,<br>
> &shell_implementation,<br>
> - shell, NULL);<br>
> + sc, NULL);<br>
> }<br>
><br>
> static void<br>
> --<br>
> 1.9.0<br>
><br>
</div></div>> _______________________________________________<br>
> wayland-devel mailing list<br>
> <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div><br></div></div>