[RFC weston] Change weston_surface.resource to a wl_resource pointer.

Kristian Høgsberg hoegsberg at gmail.com
Thu Jun 6 22:05:09 PDT 2013


On Thu, Jun 06, 2013 at 10:34:41PM -0500, Jason Ekstrand wrote:
> This is the first in what will be a series of weston patches to convert
> instances of wl_resource to pointers so we can make wl_resource opaque.
> This patch handles weston_surface and should be the most invasive of the
> entire series.  I am sending this one out ahead of the rest for review.
> 
> Specifically, my machine is not set up to build XWayland so I have no
> ability to test it fully.  Could someone please test with XWayland and let
> me know if this causes problems?
> 
> Because a surface may be created from XWayland, the resource may not always
> exist.  Therefore, a destroy signal was added to weston_surface and
> everything used to listen to surface->resource.destroy_signal now listens
> to surface->destroy_signal.

Very nice, I like how the weston_surface->resource pointer now becomes
an indicator of whether or not there's a protocol object for the
surface, and life-cycle management for non-protocol surface is clearer.

I think we should introduce ref-counts for weston_surface at this
point.  The idea is that the wl_resource (if it exists) has a
ref-count to weston_surface.  For most protocol surfaces, that's the
only ref-count there'll be and the resource destructor unrefs the
weston_surface, which then triggers the destroy as it does now.  But I
want to be able to add a resource destroy listener, that takes a ref
on the weston_surface and this delays destruction.  The surface goes
away as a protocol object (and from the clients point of view) but we
can still run a destroy animation, which then drops the last ref when
it's done.

I compiled and tested it and the xwayland part works fine, but I had
to add wl_resource_get_id() (which I committed and pushed) and I fixed
these compile errors:

diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index d42ff16..3ef756c 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -186,7 +186,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
 	shell->lockscreen_surface = es;
 	shell->lockscreen_surface->configure = tablet_shell_surface_configure;
 	shell->lockscreen_listener.notify = handle_lockscreen_surface_destroy;
-	wl_signal_add(es->destroy_signal, &shell->lockscreen_listener);
+	wl_signal_add(&es->destroy_signal, &shell->lockscreen_listener);
 }
 
 static void
@@ -217,7 +217,7 @@ tablet_shell_set_switcher(struct wl_client *client,
 	weston_surface_set_position(shell->switcher_surface, 0, 0);
 
 	shell->switcher_listener.notify = handle_switcher_surface_destroy;
-	wl_signal_add(es->destroy_signal, &shell->switcher_listener);
+	wl_signal_add(&es->destroy_signal, &shell->switcher_listener);
 }
 
 static void
diff --git a/src/text-backend.c b/src/text-backend.c
index 3d36527..da0d275 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -197,7 +197,7 @@ text_input_activate(struct wl_client *client,
 		wl_signal_emit(&ec->update_input_panel_signal, &text_input->cursor_rectangle);
 	}
 
-	wl_text_input_send_enter(&text_input->resource, &text_input->surface->resource);
+	wl_text_input_send_enter(&text_input->resource, text_input->surface->resource);
 }
 
 static void

but other than those and with the ref-count and a real commit message,
I think this is ready to go.

Kristian


> ---
>  src/animation.c               |  2 +-
>  src/compositor.c              | 65 ++++++++++++++++++++++---------------------
>  src/compositor.h              |  3 +-
>  src/data-device.c             |  9 +++---
>  src/input.c                   | 24 ++++++++--------
>  src/shell.c                   | 13 ++++-----
>  src/tablet-shell.c            |  7 ++---
>  src/xwayland/window-manager.c | 12 ++++----
>  src/zoom.c                    |  5 +++-
>  9 files changed, 72 insertions(+), 68 deletions(-)
> 
> diff --git a/src/animation.c b/src/animation.c
> index b9d0f8a..10ab583 100644
> --- a/src/animation.c
> +++ b/src/animation.c
> @@ -188,7 +188,7 @@ weston_surface_animation_run(struct weston_surface *surface,
>  	weston_surface_animation_frame(&animation->animation, NULL, 0);
>  
>  	animation->listener.notify = handle_animation_surface_destroy;
> -	wl_signal_add(&surface->resource.destroy_signal, &animation->listener);
> +	wl_signal_add(&surface->destroy_signal, &animation->listener);
>  
>  	wl_list_insert(&surface->output->animation_list,
>  		       &animation->animation.link);
> diff --git a/src/compositor.c b/src/compositor.c
> index 099600d..42011f5 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -276,13 +276,13 @@ weston_surface_create(struct weston_compositor *compositor)
>  	if (surface == NULL)
>  		return NULL;
>  
> -	wl_signal_init(&surface->resource.destroy_signal);
> +	wl_signal_init(&surface->destroy_signal);
> +
> +	surface->resource = NULL;
>  
>  	wl_list_init(&surface->link);
>  	wl_list_init(&surface->layer_link);
>  
> -	surface->resource.client = NULL;
> -
>  	surface->compositor = compositor;
>  	surface->alpha = 1.0;
>  
> @@ -523,14 +523,16 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
>  	uint32_t left = es->output_mask & different;
>  	struct weston_output *output;
>  	struct wl_resource *resource = NULL;
> -	struct wl_client *client = es->resource.client;
> +	struct wl_client *client;
>  
>  	es->output_mask = mask;
> -	if (es->resource.client == NULL)
> +	if (es->resource == NULL)
>  		return;
>  	if (different == 0)
>  		return;
>  
> +	client = wl_resource_get_client(es->resource);
> +
>  	wl_list_for_each(output, &es->compositor->output_list, link) {
>  		if (1 << output->id & different)
>  			resource =
> @@ -539,9 +541,9 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
>  		if (resource == NULL)
>  			continue;
>  		if (1 << output->id & entered)
> -			wl_surface_send_enter(&es->resource, resource);
> +			wl_surface_send_enter(es->resource, resource);
>  		if (1 << output->id & left)
> -			wl_surface_send_leave(&es->resource, resource);
> +			wl_surface_send_leave(es->resource, resource);
>  	}
>  }
>  
> @@ -882,7 +884,7 @@ weston_surface_set_transform_parent(struct weston_surface *surface,
>  	surface->geometry.parent_destroy_listener.notify =
>  		transform_parent_handle_parent_destroy;
>  	if (parent) {
> -		wl_signal_add(&parent->resource.destroy_signal,
> +		wl_signal_add(&parent->destroy_signal,
>  			      &surface->geometry.parent_destroy_listener);
>  		wl_list_insert(&parent->geometry.child_list,
>  			       &surface->geometry.parent_link);
> @@ -1004,11 +1006,15 @@ struct weston_frame_callback {
>  	struct wl_list link;
>  };
>  
> -static void
> -destroy_surface(struct wl_resource *resource)
> +
> +WL_EXPORT void
> +weston_surface_destroy(struct weston_surface *surface)
>  {
> -	struct weston_surface *surface =
> -		container_of(resource, struct weston_surface, resource);
> +	/* Not a valid way to destroy a client surface */
> +	assert(surface->resource == NULL);
> +
> +	wl_signal_emit(&surface->destroy_signal, &surface->resource);
> +
>  	struct weston_compositor *compositor = surface->compositor;
>  	struct weston_frame_callback *cb, *next;
>  
> @@ -1048,14 +1054,13 @@ destroy_surface(struct wl_resource *resource)
>  	free(surface);
>  }
>  
> -WL_EXPORT void
> -weston_surface_destroy(struct weston_surface *surface)
> +static void
> +destroy_surface(struct wl_resource *resource)
>  {
> -	/* Not a valid way to destroy a client surface */
> -	assert(surface->resource.client == NULL);
> +	struct weston_surface *surface = wl_resource_get_user_data(resource);
>  
> -	wl_signal_emit(&surface->resource.destroy_signal, &surface->resource);
> -	destroy_surface(&surface->resource);
> +	surface->resource = NULL;
> +	weston_surface_destroy(surface);
>  }
>  
>  static void
> @@ -1660,15 +1665,10 @@ compositor_create_surface(struct wl_client *client,
>  		return;
>  	}
>  
> -	surface->resource.destroy = destroy_surface;
> -
> -	surface->resource.object.id = id;
> -	surface->resource.object.interface = &wl_surface_interface;
> -	surface->resource.object.implementation =
> -		(void (**)(void)) &surface_interface;
> -	surface->resource.data = surface;
> -
> -	wl_client_add_resource(client, &surface->resource);
> +	surface->resource = wl_client_add_object(client, &wl_surface_interface,
> +						 &surface_interface,
> +						 id, surface);
> +	wl_resource_set_destructor(surface->resource, destroy_surface);
>  }
>  
>  static void
> @@ -2035,7 +2035,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
>  		wl_resource_post_error(sub->resource,
>  			WL_SUBSURFACE_ERROR_BAD_SURFACE,
>  			"%s: wl_surface@%d is not a parent or sibling",
> -			request, surface->resource.object.id);
> +			request, wl_resource_get_id(surface->resource));
>  		return NULL;
>  	}
>  
> @@ -2043,7 +2043,7 @@ subsurface_sibling_check(struct weston_subsurface *sub,
>  		wl_resource_post_error(sub->resource,
>  			WL_SUBSURFACE_ERROR_BAD_SURFACE,
>  			"%s: wl_surface@%d has a different parent",
> -			request, surface->resource.object.id);
> +			request, wl_resource_get_id(surface->resource));
>  		return NULL;
>  	}
>  
> @@ -2204,7 +2204,7 @@ weston_subsurface_link_parent(struct weston_subsurface *sub,
>  {
>  	sub->parent = parent;
>  	sub->parent_destroy_listener.notify = subsurface_handle_parent_destroy;
> -	wl_signal_add(&parent->resource.destroy_signal,
> +	wl_signal_add(&parent->destroy_signal,
>  		      &sub->parent_destroy_listener);
>  
>  	wl_list_insert(&parent->subsurface_list, &sub->parent_link);
> @@ -2219,7 +2219,7 @@ weston_subsurface_link_surface(struct weston_subsurface *sub,
>  	sub->surface = surface;
>  	sub->surface_destroy_listener.notify =
>  		subsurface_handle_surface_destroy;
> -	wl_signal_add(&surface->resource.destroy_signal,
> +	wl_signal_add(&surface->destroy_signal,
>  		      &sub->surface_destroy_listener);
>  }
>  
> @@ -2266,12 +2266,13 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface,
>  			 struct weston_surface *parent)
>  {
>  	struct weston_subsurface *sub;
> +	struct wl_client *client = wl_resource_get_client(surface->resource);
>  
>  	sub = calloc(1, sizeof *sub);
>  	if (!sub)
>  		return NULL;
>  
> -	sub->resource = wl_client_add_object(surface->resource.client,
> +	sub->resource = wl_client_add_object(client,
>  					     &wl_subsurface_interface,
>  					     &subsurface_implementation,
>  					     id, sub);
> diff --git a/src/compositor.h b/src/compositor.h
> index 22700b7..c87d9f1 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -651,7 +651,8 @@ struct weston_subsurface {
>   */
>  
>  struct weston_surface {
> -	struct wl_resource resource;
> +	struct wl_resource *resource;
> +	struct wl_signal destroy_signal;
>  	struct weston_compositor *compositor;
>  	pixman_region32_t clip;
>  	pixman_region32_t damage;
> diff --git a/src/data-device.c b/src/data-device.c
> index 0decbb9..06d24f1 100644
> --- a/src/data-device.c
> +++ b/src/data-device.c
> @@ -230,11 +230,12 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
>  	if (!surface)
>  		return;
>  
> -	if (!drag->data_source && surface->resource.client != drag->client)
> +	if (!drag->data_source &&
> +	    wl_resource_get_client(surface->resource) != drag->client)
>  		return;
>  
>  	resource = find_resource(&pointer->seat->drag_resource_list,
> -				 surface->resource.client);
> +				 wl_resource_get_client(surface->resource));
>  	if (!resource)
>  		return;
>  
> @@ -244,7 +245,7 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
>  	if (drag->data_source)
>  		offer = wl_data_source_send_offer(drag->data_source, resource);
>  
> -	wl_data_device_send_enter(resource, serial, &surface->resource,
> +	wl_data_device_send_enter(resource, serial, surface->resource,
>  				  sx, sy, offer);
>  
>  	drag->focus = surface;
> @@ -405,7 +406,7 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
>  	if (icon) {
>  		drag->icon = icon;
>  		drag->icon_destroy_listener.notify = handle_drag_icon_destroy;
> -		wl_signal_add(&icon->resource.destroy_signal,
> +		wl_signal_add(&icon->destroy_signal,
>  			      &drag->icon_destroy_listener);
>  
>  		icon->configure = drag_surface_configure;
> diff --git a/src/input.c b/src/input.c
> index d299d98..5463d78 100644
> --- a/src/input.c
> +++ b/src/input.c
> @@ -178,7 +178,7 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
>  		display = wl_client_get_display(touch->focus_resource->client);
>  		serial = wl_display_next_serial(display);
>  		wl_touch_send_down(touch->focus_resource, serial, time,
> -				   &touch->focus->resource,
> +				   touch->focus->resource,
>  				   touch_id, sx, sy);
>  	}
>  }
> @@ -242,7 +242,7 @@ find_resource_for_surface(struct wl_list *list, struct weston_surface *surface)
>  		return NULL;
>  
>  	wl_list_for_each(r, list, link) {
> -		if (r->client == surface->resource.client)
> +		if (r->client == wl_resource_get_client(surface->resource))
>  			return r;
>  	}
>  
> @@ -437,7 +437,7 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
>  		display = wl_client_get_display(resource->client);
>  		serial = wl_display_next_serial(display);
>  		wl_pointer_send_leave(resource, serial,
> -				      &pointer->focus->resource);
> +				      pointer->focus->resource);
>  		wl_list_remove(&pointer->focus_listener.link);
>  	}
>  
> @@ -460,7 +460,7 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
>  							   kbd->modifiers.group);
>  			}
>  		}
> -		wl_pointer_send_enter(resource, serial, &surface->resource,
> +		wl_pointer_send_enter(resource, serial, surface->resource,
>  				      sx, sy);
>  		wl_signal_add(&resource->destroy_signal,
>  			      &pointer->focus_listener);
> @@ -485,7 +485,7 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
>  		display = wl_client_get_display(resource->client);
>  		serial = wl_display_next_serial(display);
>  		wl_keyboard_send_leave(resource, serial,
> -				       &keyboard->focus->resource);
> +				       keyboard->focus->resource);
>  		wl_list_remove(&keyboard->focus_listener.link);
>  	}
>  
> @@ -501,7 +501,7 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
>  					   keyboard->modifiers.mods_latched,
>  					   keyboard->modifiers.mods_locked,
>  					   keyboard->modifiers.group);
> -		wl_keyboard_send_enter(resource, serial, &surface->resource,
> +		wl_keyboard_send_enter(resource, serial, surface->resource,
>  				       &keyboard->keys);
>  		wl_signal_add(&resource->destroy_signal,
>  			      &keyboard->focus_listener);
> @@ -963,7 +963,7 @@ notify_keyboard_focus_out(struct weston_seat *seat)
>  		seat->saved_kbd_focus = keyboard->focus;
>  		seat->saved_kbd_focus_listener.notify =
>  			destroy_device_saved_kbd_focus;
> -		wl_signal_add(&keyboard->focus->resource.destroy_signal,
> +		wl_signal_add(&keyboard->focus->destroy_signal,
>  			      &seat->saved_kbd_focus_listener);
>  	}
>  
> @@ -1112,14 +1112,14 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
>  
>  	if (pointer->focus == NULL)
>  		return;
> -	if (pointer->focus->resource.client != client)
> +	if (wl_resource_get_client(pointer->focus->resource) != client)
>  		return;
>  	if (pointer->focus_serial - serial > UINT32_MAX / 2)
>  		return;
>  
>  	if (surface && surface != pointer->sprite) {
>  		if (surface->configure) {
> -			wl_resource_post_error(&surface->resource,
> +			wl_resource_post_error(surface->resource,
>  					       WL_DISPLAY_ERROR_INVALID_OBJECT,
>  					       "surface->configure already "
>  					       "set");
> @@ -1133,7 +1133,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
>  	if (!surface)
>  		return;
>  
> -	wl_signal_add(&surface->resource.destroy_signal,
> +	wl_signal_add(&surface->destroy_signal,
>  		      &pointer->sprite_destroy_listener);
>  
>  	surface->configure = pointer_cursor_surface_configure;
> @@ -1167,7 +1167,7 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
>  	cr->destroy = unbind_resource;
>  
>  	if (seat->pointer->focus &&
> -	    seat->pointer->focus->resource.client == client) {
> +	    wl_resource_get_client(seat->pointer->focus->resource) == client) {
>  		struct weston_surface *surface;
>  		wl_fixed_t sx, sy;
>  
> @@ -1204,7 +1204,7 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource,
>  				seat->xkb_info.keymap_size);
>  
>  	if (seat->keyboard->focus &&
> -	    seat->keyboard->focus->resource.client == client) {
> +	    wl_resource_get_client(seat->keyboard->focus->resource) == client) {
>  		weston_keyboard_set_focus(seat->keyboard,
>  					  seat->keyboard->focus);
>  		wl_data_device_set_keyboard_focus(seat);
> diff --git a/src/shell.c b/src/shell.c
> index 3d10eef..57dbb0a 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -2001,7 +2001,7 @@ popup_grab_focus(struct weston_pointer_grab *grab)
>  						 pointer->x, pointer->y,
>  						 &sx, &sy);
>  
> -	if (surface && surface->resource.client == client) {
> +	if (surface && wl_resource_get_client(surface->resource) == client) {
>  		weston_pointer_set_focus(pointer, surface, sx, sy);
>  	} else {
>  		weston_pointer_set_focus(pointer, NULL,
> @@ -2263,7 +2263,7 @@ create_shell_surface(void *shell, struct weston_surface *surface,
>  
>  	wl_signal_init(&shsurf->resource.destroy_signal);
>  	shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
> -	wl_signal_add(&surface->resource.destroy_signal,
> +	wl_signal_add(&surface->destroy_signal,
>  		      &shsurf->surface_destroy_listener);
>  
>  	/* init link so its safe to always remove it in destroy_shell_surface */
> @@ -2937,8 +2937,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
>  
>  	state->keyboard_focus = es;
>  	wl_list_remove(&state->surface_destroy_listener.link);
> -	wl_signal_add(&es->resource.destroy_signal,
> -		      &state->surface_destroy_listener);
> +	wl_signal_add(&es->destroy_signal, &state->surface_destroy_listener);
>  
>  	switch (get_shell_surface_type(main_surface)) {
>  	case SHELL_SURFACE_FULLSCREEN:
> @@ -3789,7 +3788,7 @@ create_input_panel_surface(struct desktop_shell *shell,
>  
>  	wl_signal_init(&input_panel_surface->resource.destroy_signal);
>  	input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
> -	wl_signal_add(&surface->resource.destroy_signal,
> +	wl_signal_add(&surface->destroy_signal,
>  		      &input_panel_surface->surface_destroy_listener);
>  
>  	wl_list_init(&input_panel_surface->link);
> @@ -3956,7 +3955,7 @@ switcher_next(struct switcher *switcher)
>  		return;
>  
>  	wl_list_remove(&switcher->listener.link);
> -	wl_signal_add(&next->resource.destroy_signal, &switcher->listener);
> +	wl_signal_add(&next->destroy_signal, &switcher->listener);
>  
>  	switcher->current = next;
>  	next->alpha = 1.0;
> @@ -4213,7 +4212,7 @@ force_kill_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
>  
>  	wl_signal_emit(&compositor->kill_signal, focus_surface);
>  
> -	client = focus_surface->resource.client;
> +	client = wl_resource_get_client(focus_surface->resource);
>  	wl_client_get_credentials(client, &pid, NULL, NULL);
>  
>  	/* Skip clients that we launched ourselves (the credentials of
> diff --git a/src/tablet-shell.c b/src/tablet-shell.c
> index 91fbaed..d42ff16 100644
> --- a/src/tablet-shell.c
> +++ b/src/tablet-shell.c
> @@ -152,7 +152,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
>  		}
>  	} else if (shell->current_client &&
>  		   shell->current_client->surface != surface &&
> -		   shell->current_client->client == surface->resource.client) {
> +		   shell->current_client->client == wl_resource_get_client(surface->resource)) {
>  		tablet_shell_set_state(shell, STATE_TASK);
>  		shell->current_client->surface = surface;
>  		weston_zoom_run(surface, 0.3, 1.0, NULL, NULL);
> @@ -186,8 +186,7 @@ tablet_shell_set_lockscreen(struct wl_client *client,
>  	shell->lockscreen_surface = es;
>  	shell->lockscreen_surface->configure = tablet_shell_surface_configure;
>  	shell->lockscreen_listener.notify = handle_lockscreen_surface_destroy;
> -	wl_signal_add(&es->resource.destroy_signal,
> -		      &shell->lockscreen_listener);
> +	wl_signal_add(es->destroy_signal, &shell->lockscreen_listener);
>  }
>  
>  static void
> @@ -218,7 +217,7 @@ tablet_shell_set_switcher(struct wl_client *client,
>  	weston_surface_set_position(shell->switcher_surface, 0, 0);
>  
>  	shell->switcher_listener.notify = handle_switcher_surface_destroy;
> -	wl_signal_add(&es->resource.destroy_signal, &shell->switcher_listener);
> +	wl_signal_add(es->destroy_signal, &shell->switcher_listener);
>  }
>  
>  static void
> diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
> index 366f2e0..5d003a9 100644
> --- a/src/xwayland/window-manager.c
> +++ b/src/xwayland/window-manager.c
> @@ -1621,7 +1621,7 @@ weston_wm_create(struct weston_xserver *wxs)
>  	}
>  
>  	xserver_send_client(wxs->resource, sv[1]);
> -	wl_client_flush(wxs->resource->client);
> +	wl_client_flush(wl_resource_get_client(wxs->resource));
>  	close(sv[1]);
>  	
>  	/* xcb_connect_to_fd takes ownership of the fd. */
> @@ -1715,10 +1715,9 @@ surface_destroy(struct wl_listener *listener, void *data)
>  static struct weston_wm_window *
>  get_wm_window(struct weston_surface *surface)
>  {
> -	struct wl_resource *resource = &surface->resource;
>  	struct wl_listener *listener;
>  
> -	listener = wl_signal_get(&resource->destroy_signal, surface_destroy);
> +	listener = wl_signal_get(&surface->destroy_signal, surface_destroy);
>  	if (listener)
>  		return container_of(listener, struct weston_wm_window,
>  				    surface_destroy_listener);
> @@ -1850,9 +1849,10 @@ static void
>  xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
>  		      struct wl_resource *surface_resource, uint32_t id)
>  {
> -	struct weston_xserver *wxs = resource->data;
> +	struct weston_xserver *wxs = wl_resource_get_user_data(resource);
>  	struct weston_wm *wm = wxs->wm;
> -	struct weston_surface *surface = surface_resource->data;
> +	struct weston_surface *surface =
> +		wl_resource_get_user_data(surface_resource);
>  	struct weston_wm_window *window;
>  
>  	if (client != wxs->client)
> @@ -1870,7 +1870,7 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
>  
>  	window->surface = (struct weston_surface *) surface;
>  	window->surface_destroy_listener.notify = surface_destroy;
> -	wl_signal_add(&surface->resource.destroy_signal,
> +	wl_signal_add(&surface->destroy_signal,
>  		      &window->surface_destroy_listener);
>  
>  	weston_wm_window_schedule_repaint(window);
> diff --git a/src/zoom.c b/src/zoom.c
> index 292aed6..ec9db98 100644
> --- a/src/zoom.c
> +++ b/src/zoom.c
> @@ -40,7 +40,10 @@ text_cursor_position_notify(struct wl_client *client,
>  			    struct wl_resource *surface_resource,
>  			    wl_fixed_t x, wl_fixed_t y)
>  {
> -	weston_text_cursor_position_notify((struct weston_surface *) surface_resource, x, y);
> +	struct weston_surface *surface =
> +		wl_resource_get_user_data(surface_resource);
> +
> +	weston_text_cursor_position_notify(surface, x, y);
>  }
>  
>  struct text_cursor_position_interface text_cursor_position_implementation = {
> -- 
> 1.8.1.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list