[PATCH] Remove the weston_view.geometry.width/height fields

Kristian Høgsberg hoegsberg at gmail.com
Mon Dec 2 22:19:38 PST 2013


On Mon, Dec 02, 2013 at 09:01:53PM -0600, Jason Ekstrand wrote:
> This has a couple of additional implications for the internal weston API:
>  1) weston_view_configure no longer exists.  Use weston_view_set_position
>     instead.
>  2) The weston_surface.configure callback no longer takes a width and
>     height.  If you need these, surface.width/height are set before
>     configure is called.  If you need to know when the width/height
>     changes, you must track that yourself.

I like it, it's pretty clean and it simplifies things here and there
by removing redundant width/height args.  And even if it didn't, clearly,
the surface width/height is not a per-view thing. Committed, thanks.

Kristian

> ---
>  src/animation.c             |   8 +--
>  src/compositor-drm.c        |  24 +++----
>  src/compositor.c            |  70 ++++++++++---------
>  src/compositor.h            |   7 +-
>  src/data-device.c           |   2 +-
>  src/gl-renderer.c           |   2 +-
>  src/input.c                 |   9 ++-
>  src/pixman-renderer.c       |   6 +-
>  src/rpi-renderer.c          |   4 +-
>  src/shell.c                 | 164 ++++++++++++++++++++------------------------
>  src/tablet-shell.c          |   6 +-
>  tests/surface-global-test.c |   4 +-
>  tests/surface-test.c        |   4 +-
>  tests/weston-test.c         |   7 +-
>  14 files changed, 150 insertions(+), 167 deletions(-)
> 
> diff --git a/src/animation.c b/src/animation.c
> index f717b33..ee12036 100644
> --- a/src/animation.c
> +++ b/src/animation.c
> @@ -240,12 +240,12 @@ zoom_frame(struct weston_view_animation *animation)
>  		animation->spring.current;
>  	weston_matrix_init(&animation->transform.matrix);
>  	weston_matrix_translate(&animation->transform.matrix,
> -				-0.5f * es->geometry.width,
> -				-0.5f * es->geometry.height, 0);
> +				-0.5f * es->surface->width,
> +				-0.5f * es->surface->height, 0);
>  	weston_matrix_scale(&animation->transform.matrix, scale, scale, scale);
>  	weston_matrix_translate(&animation->transform.matrix,
> -				0.5f * es->geometry.width,
> -				0.5f * es->geometry.height, 0);
> +				0.5f * es->surface->width,
> +				0.5f * es->surface->height, 0);
>  
>  	es->alpha = animation->spring.current;
>  	if (es->alpha > 1.0)
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index c34fc1c..fbf6e49 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -777,8 +777,8 @@ drm_output_check_sprite_format(struct drm_sprite *s,
>  		pixman_region32_t r;
>  
>  		pixman_region32_init_rect(&r, 0, 0,
> -					  ev->geometry.width,
> -					  ev->geometry.height);
> +					  ev->surface->width,
> +					  ev->surface->height);
>  		pixman_region32_subtract(&r, &r, &ev->surface->opaque);
>  
>  		if (!pixman_region32_not_empty(&r))
> @@ -919,18 +919,18 @@ drm_output_prepare_overlay_view(struct weston_output *output_base,
>  		sx1 = 0;
>  	if (sy1 < 0)
>  		sy1 = 0;
> -	if (sx2 > wl_fixed_from_int(ev->geometry.width))
> -		sx2 = wl_fixed_from_int(ev->geometry.width);
> -	if (sy2 > wl_fixed_from_int(ev->geometry.height))
> -		sy2 = wl_fixed_from_int(ev->geometry.height);
> +	if (sx2 > wl_fixed_from_int(ev->surface->width))
> +		sx2 = wl_fixed_from_int(ev->surface->width);
> +	if (sy2 > wl_fixed_from_int(ev->surface->height))
> +		sy2 = wl_fixed_from_int(ev->surface->height);
>  
>  	tbox.x1 = sx1;
>  	tbox.y1 = sy1;
>  	tbox.x2 = sx2;
>  	tbox.y2 = sy2;
>  
> -	tbox = weston_transformed_rect(wl_fixed_from_int(ev->geometry.width),
> -				       wl_fixed_from_int(ev->geometry.height),
> +	tbox = weston_transformed_rect(wl_fixed_from_int(ev->surface->width),
> +				       wl_fixed_from_int(ev->surface->height),
>  				       ev->surface->buffer_viewport.transform,
>  				       ev->surface->buffer_viewport.scale,
>  				       tbox);
> @@ -964,7 +964,7 @@ drm_output_prepare_cursor_view(struct weston_output *output_base,
>  		return NULL;
>  	if (ev->surface->buffer_ref.buffer == NULL ||
>  	    !wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource) ||
> -	    ev->geometry.width > 64 || ev->geometry.height > 64)
> +	    ev->surface->width > 64 || ev->surface->height > 64)
>  		return NULL;
>  
>  	output->cursor_view = ev;
> @@ -1003,9 +1003,9 @@ drm_output_set_cursor(struct drm_output *output)
>  		stride = wl_shm_buffer_get_stride(buffer->shm_buffer);
>  		s = wl_shm_buffer_get_data(buffer->shm_buffer);
>  		wl_shm_buffer_begin_access(buffer->shm_buffer);
> -		for (i = 0; i < ev->geometry.height; i++)
> +		for (i = 0; i < ev->surface->height; i++)
>  			memcpy(buf + i * 64, s + i * stride,
> -			       ev->geometry.width * 4);
> +			       ev->surface->width * 4);
>  		wl_shm_buffer_end_access(buffer->shm_buffer);
>  
>  		if (gbm_bo_write(bo, buf, sizeof buf) < 0)
> @@ -1071,7 +1071,7 @@ drm_assign_planes(struct weston_output *output)
>  		if (c->use_pixman ||
>  		    (es->buffer_ref.buffer &&
>  		    (!wl_shm_buffer_get(es->buffer_ref.buffer->resource) ||
> -		     (ev->geometry.width <= 64 && ev->geometry.height <= 64))))
> +		     (ev->surface->width <= 64 && ev->surface->height <= 64))))
>  			es->keep_buffer = 1;
>  		else
>  			es->keep_buffer = 0;
> diff --git a/src/compositor.c b/src/compositor.c
> index 32e72b1..e844cc5 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -863,8 +863,8 @@ weston_view_update_transform_disable(struct weston_view *view)
>  	pixman_region32_init_rect(&view->transform.boundingbox,
>  				  view->geometry.x,
>  				  view->geometry.y,
> -				  view->geometry.width,
> -				  view->geometry.height);
> +				  view->surface->width,
> +				  view->surface->height);
>  
>  	if (view->alpha == 1.0) {
>  		pixman_region32_copy(&view->transform.opaque,
> @@ -904,8 +904,8 @@ weston_view_update_transform_enable(struct weston_view *view)
>  		return -1;
>  	}
>  
> -	view_compute_bbox(view, 0, 0, view->geometry.width,
> -			  view->geometry.height,
> +	view_compute_bbox(view, 0, 0,
> +			  view->surface->width, view->surface->height,
>  			  &view->transform.boundingbox);
>  
>  	return 0;
> @@ -1070,19 +1070,11 @@ weston_surface_damage(struct weston_surface *surface)
>  }
>  
>  WL_EXPORT void
> -weston_view_configure(struct weston_view *view,
> -		      float x, float y, int width, int height)
> -{
> -	view->geometry.x = x;
> -	view->geometry.y = y;
> -	view->geometry.width = width;
> -	view->geometry.height = height;
> -	weston_view_geometry_dirty(view);
> -}
> -
> -WL_EXPORT void
>  weston_view_set_position(struct weston_view *view, float x, float y)
>  {
> +	if (view->geometry.x == x && view->geometry.y == y)
> +		return;
> +
>  	view->geometry.x = x;
>  	view->geometry.y = y;
>  	weston_view_geometry_dirty(view);
> @@ -1141,13 +1133,28 @@ weston_surface_is_mapped(struct weston_surface *surface)
>  }
>  
>  static void
> +weston_surface_set_size(struct weston_surface *surface,
> +			int32_t width, int32_t height)
> +{
> +	struct weston_view *view;
> +
> +	if (surface->width == width && surface->height == height)
> +		return;
> +	
> +	surface->width = width;
> +	surface->height = height;
> +
> +	wl_list_for_each(view, &surface->views, surface_link)
> +		weston_view_geometry_dirty(view);
> +}
> +
> +static void
>  weston_surface_set_size_from_buffer(struct weston_surface *surface)
>  {
>  	int32_t width, height;
>  
>  	if (!surface->buffer_ref.buffer) {
> -		surface->width = 0;
> -		surface->height = 0;
> +		weston_surface_set_size(surface, 0, 0);
>  		return;
>  	}
>  
> @@ -1165,8 +1172,9 @@ weston_surface_set_size_from_buffer(struct weston_surface *surface)
>  		break;
>  	}
>  
> -	surface->width = width / surface->buffer_viewport.scale;
> -	surface->height = height / surface->buffer_viewport.scale;
> +	width = width / surface->buffer_viewport.scale;
> +	height = height / surface->buffer_viewport.scale;
> +	weston_surface_set_size(surface, width, height);
>  }
>  
>  WL_EXPORT uint32_t
> @@ -1589,11 +1597,9 @@ view_list_add_subsurface_view(struct weston_compositor *compositor,
>  		wl_list_insert(&sub->surface->views, &view->surface_link);
>  	} else {
>  		view = weston_view_create(sub->surface);
> -		weston_view_configure(view,
> -				      sub->position.x,
> -				      sub->position.y,
> -				      sub->surface->width,
> -				      sub->surface->height);
> +		weston_view_set_position(view,
> +					 sub->position.x,
> +					 sub->position.y);
>  		weston_view_set_transform_parent(view, parent);
>  	}
>  
> @@ -1957,8 +1963,7 @@ weston_surface_commit(struct weston_surface *surface)
>  
>  	if (surface->configure && surface->pending.newly_attached)
>  		surface->configure(surface,
> -				   surface->pending.sx, surface->pending.sy,
> -				   surface->width, surface->height);
> +				   surface->pending.sx, surface->pending.sy);
>  
>  	if (surface->pending.buffer)
>  		wl_list_remove(&surface->pending.buffer_destroy_listener.link);
> @@ -2183,8 +2188,7 @@ weston_subsurface_commit_from_cache(struct weston_subsurface *sub)
>  	weston_surface_set_size_from_buffer(surface);
>  
>  	if (surface->configure && sub->cached.newly_attached)
> -		surface->configure(surface, sub->cached.sx, sub->cached.sy,
> -				   surface->width, surface->height);
> +		surface->configure(surface, sub->cached.sx, sub->cached.sy);
>  	sub->cached.sx = 0;
>  	sub->cached.sy = 0;
>  	sub->cached.newly_attached = 0;
> @@ -2355,17 +2359,15 @@ weston_subsurface_parent_commit(struct weston_subsurface *sub,
>  }
>  
>  static void
> -subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy,
> -		     int32_t width, int32_t height)
> +subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy)
>  {
>  	struct weston_compositor *compositor = surface->compositor;
>  	struct weston_view *view;
>  
>  	wl_list_for_each(view, &surface->views, surface_link)
> -		weston_view_configure(view,
> -				      view->geometry.x + dx,
> -				      view->geometry.y + dy,
> -				      width, height);
> +		weston_view_set_position(view,
> +					 view->geometry.x + dx,
> +					 view->geometry.y + dy);
>  
>  	/* No need to check parent mappedness, because if parent is not
>  	 * mapped, parent is not in a visible layer, so this sub-surface
> diff --git a/src/compositor.h b/src/compositor.h
> index 9e1a825..62716d1 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -761,7 +761,6 @@ struct weston_view {
>  	 */
>  	struct {
>  		float x, y; /* surface translation on display */
> -		int32_t width, height;
>  
>  		/* struct weston_transform */
>  		struct wl_list transformation_list;
> @@ -875,7 +874,7 @@ struct weston_surface {
>  	 * a new buffer has been set up for this surface. The integer params
>  	 * are the sx and sy paramerters supplied to surface::attach .
>  	 */
> -	void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
> +	void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy);
>  	void *configure_private;
>  
>  	/* Parent's list of its sub-surfaces, weston_subsurface:parent_link.
> @@ -1123,10 +1122,6 @@ void
>  weston_view_destroy(struct weston_view *view);
>  
>  void
> -weston_view_configure(struct weston_view *view,
> -		      float x, float y, int width, int height);
> -
> -void
>  weston_view_set_position(struct weston_view *view,
>  			 float x, float y);
>  
> diff --git a/src/data-device.c b/src/data-device.c
> index 5ef69d1..2af04de 100644
> --- a/src/data-device.c
> +++ b/src/data-device.c
> @@ -218,7 +218,7 @@ drag_surface_configure(struct weston_drag *drag,
>  		fx = wl_fixed_to_double(touch->grab_x) + drag->dx;
>  		fy = wl_fixed_to_double(touch->grab_y) + drag->dy;
>  	}
> -	weston_view_configure(drag->icon, fx, fy, width, height);
> +	weston_view_set_position(drag->icon, fx, fy);
>  }
>  
>  static void
> diff --git a/src/gl-renderer.c b/src/gl-renderer.c
> index a74aef5..0e5afbe 100644
> --- a/src/gl-renderer.c
> +++ b/src/gl-renderer.c
> @@ -550,7 +550,7 @@ draw_view(struct weston_view *ev, struct weston_output *output,
>  
>  	/* blended region is whole surface minus opaque region: */
>  	pixman_region32_init_rect(&surface_blend, 0, 0,
> -				  ev->geometry.width, ev->geometry.height);
> +				  ev->surface->width, ev->surface->height);
>  	pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
>  
>  	/* XXX: Should we be using ev->transform.opaque here? */
> diff --git a/src/input.c b/src/input.c
> index f965ba1..dd95eff 100644
> --- a/src/input.c
> +++ b/src/input.c
> @@ -1419,12 +1419,12 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
>  
>  static void
>  pointer_cursor_surface_configure(struct weston_surface *es,
> -				 int32_t dx, int32_t dy, int32_t width, int32_t height)
> +				 int32_t dx, int32_t dy)
>  {
>  	struct weston_pointer *pointer = es->configure_private;
>  	int x, y;
>  
> -	if (width == 0)
> +	if (es->width == 0)
>  		return;
>  
>  	assert(es == pointer->sprite->surface);
> @@ -1435,7 +1435,7 @@ pointer_cursor_surface_configure(struct weston_surface *es,
>  	x = wl_fixed_to_int(pointer->x) - pointer->hotspot_x;
>  	y = wl_fixed_to_int(pointer->y) - pointer->hotspot_y;
>  
> -	weston_view_configure(pointer->sprite, x, y, width, height);
> +	weston_view_set_position(pointer->sprite, x, y);
>  
>  	empty_region(&es->pending.input);
>  
> @@ -1495,8 +1495,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
>  	pointer->hotspot_y = y;
>  
>  	if (surface->buffer_ref.buffer)
> -		pointer_cursor_surface_configure(surface, 0, 0, surface->width,
> -								surface->height);
> +		pointer_cursor_surface_configure(surface, 0, 0);
>  }
>  
>  static void
> diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
> index 5961965..e854e2a 100644
> --- a/src/pixman-renderer.c
> +++ b/src/pixman-renderer.c
> @@ -257,8 +257,8 @@ repaint_region(struct weston_view *ev, struct weston_output *output,
>  	}
>  
>  
> -	fw = pixman_int_to_fixed(ev->geometry.width);
> -	fh = pixman_int_to_fixed(ev->geometry.height);
> +	fw = pixman_int_to_fixed(ev->surface->width);
> +	fh = pixman_int_to_fixed(ev->surface->height);
>  
>  	switch (ev->surface->buffer_viewport.transform) {
>  	case WL_OUTPUT_TRANSFORM_FLIPPED:
> @@ -371,7 +371,7 @@ draw_view(struct weston_view *ev, struct weston_output *output,
>  	} else {
>  		/* blended region is whole surface minus opaque region: */
>  		pixman_region32_init_rect(&surface_blend, 0, 0,
> -					  ev->geometry.width, ev->geometry.height);
> +					  ev->surface->width, ev->surface->height);
>  		pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
>  
>  		if (pixman_region32_not_empty(&ev->surface->opaque)) {
> diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
> index 4140622..c6b924c 100644
> --- a/src/rpi-renderer.c
> +++ b/src/rpi-renderer.c
> @@ -732,8 +732,8 @@ rpir_view_compute_rects(struct rpir_view *view,
>  		}
>  	}
>  
> -	p2.f[0] = view->view->geometry.width;
> -	p2.f[1] = view->view->geometry.height;
> +	p2.f[0] = view->view->surface->width;
> +	p2.f[1] = view->view->surface->height;
>  
>  	/* transform top-left and bot-right corner into screen coordinates */
>  	weston_matrix_transform(&matrix, &p1);
> diff --git a/src/shell.c b/src/shell.c
> index dfcb525..d074ffa 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -295,6 +295,7 @@ struct shell_surface {
>  
>  	struct weston_surface *surface;
>  	struct weston_view *view;
> +	int32_t last_width, last_height;
>  	struct wl_listener surface_destroy_listener;
>  	struct weston_surface *parent;
>  	struct wl_list children_list;  /* child surfaces of this one */
> @@ -620,8 +621,7 @@ get_default_output(struct weston_compositor *compositor)
>  
>  /* no-op func for checking focus surface */
>  static void
> -focus_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy,
> -			int32_t width, int32_t height)
> +focus_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
>  {
>  }
>  
> @@ -671,8 +671,9 @@ create_focus_surface(struct weston_compositor *ec,
>  	fsurf->view = weston_view_create (surface);
>  	fsurf->view->output = output;
>  
> -	weston_view_configure(fsurf->view, output->x, output->y,
> -				 output->width, output->height);
> +	surface->width = output->width;
> +	surface->height = output->height;
> +	weston_view_set_position(fsurf->view, output->x, output->y);
>  	weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
>  	pixman_region32_fini(&surface->opaque);
>  	pixman_region32_init_rect(&surface->opaque, output->x, output->y,
> @@ -1478,9 +1479,7 @@ touch_move_grab_motion(struct weston_touch_grab *grab, uint32_t time,
>  
>  	es = shsurf->surface;
>  
> -	weston_view_configure(shsurf->view, dx, dy,
> -			      shsurf->view->geometry.width,
> -			      shsurf->view->geometry.height);
> +	weston_view_set_position(shsurf->view, dx, dy);
>  
>  	weston_compositor_schedule_repaint(es->compositor);
>  }
> @@ -1552,9 +1551,7 @@ move_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
>  	if (!shsurf)
>  		return;
>  
> -	weston_view_configure(shsurf->view, dx, dy,
> -			      shsurf->view->geometry.width,
> -			      shsurf->view->geometry.height);
> +	weston_view_set_position(shsurf->view, dx, dy);
>  
>  	weston_compositor_schedule_repaint(shsurf->surface->compositor);
>  }
> @@ -2080,7 +2077,7 @@ get_output_panel_height(struct desktop_shell *shell,
>  
>  	wl_list_for_each(view, &shell->panel_layer.view_list, layer_link) {
>  		if (view->surface->output == output) {
> -			panel_height = view->geometry.height;
> +			panel_height = view->surface->height;
>  			break;
>  		}
>  	}
> @@ -2537,7 +2534,7 @@ shell_surface_get_shell(struct shell_surface *shsurf)
>  }
>  
>  static void
> -black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height);
> +black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
>  
>  static struct weston_view *
>  create_black_surface(struct weston_compositor *ec,
> @@ -2566,10 +2563,10 @@ create_black_surface(struct weston_compositor *ec,
>  	pixman_region32_init_rect(&surface->opaque, 0, 0, w, h);
>  	pixman_region32_fini(&surface->input);
>  	pixman_region32_init_rect(&surface->input, 0, 0, w, h);
> +
>  	surface->width = w;
>  	surface->height = h;
> -
> -	weston_view_configure(view, x, y, w, h);
> +	weston_view_set_position(view, x, y);
>  
>  	return view;
>  }
> @@ -2667,11 +2664,11 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
>  				weston_view_set_position(shsurf->view,
>  							 output->x - surf_x,
>  							 output->y - surf_y);
> -				weston_view_configure(shsurf->fullscreen.black_view,
> -						      output->x - surf_x,
> -						      output->y - surf_y,
> -						      output->width,
> -						      output->height);
> +				shsurf->fullscreen.black_view->surface->width = output->width;
> +				shsurf->fullscreen.black_view->surface->height = output->height;
> +				weston_view_set_position(shsurf->fullscreen.black_view,
> +							 output->x - surf_x,
> +							 output->y - surf_y);
>  				break;
>  			} else {
>  				restore_output_mode(output);
> @@ -3002,7 +2999,7 @@ shell_handle_surface_destroy(struct wl_listener *listener, void *data)
>  }
>  
>  static void
> -shell_surface_configure(struct weston_surface *, int32_t, int32_t, int32_t, int32_t);
> +shell_surface_configure(struct weston_surface *, int32_t, int32_t);
>  
>  static struct shell_surface *
>  get_shell_surface(struct weston_surface *surface)
> @@ -3179,13 +3176,10 @@ terminate_screensaver(struct desktop_shell *shell)
>  }
>  
>  static void
> -configure_static_view(struct weston_view *ev, struct weston_layer *layer, int32_t width, int32_t height)
> +configure_static_view(struct weston_view *ev, struct weston_layer *layer)
>  {
>  	struct weston_view *v, *next;
>  
> -	if (width == 0)
> -		return;
> -
>  	wl_list_for_each_safe(v, next, &layer->view_list, layer_link) {
>  		if (v->output == ev->output && v != ev) {
>  			weston_view_unmap(v);
> @@ -3193,7 +3187,7 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int32_
>  		}
>  	}
>  
> -	weston_view_configure(ev, ev->output->x, ev->output->y, width, height);
> +	weston_view_set_position(ev, ev->output->x, ev->output->y);
>  
>  	if (wl_list_empty(&ev->layer_link)) {
>  		wl_list_insert(&layer->view_list, &ev->layer_link);
> @@ -3202,14 +3196,14 @@ configure_static_view(struct weston_view *ev, struct weston_layer *layer, int32_
>  }
>  
>  static void
> -background_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
>  {
>  	struct desktop_shell *shell = es->configure_private;
>  	struct weston_view *view;
>  
>  	view = container_of(es->views.next, struct weston_view, surface_link);
>  
> -	configure_static_view(view, &shell->background_layer, width, height);
> +	configure_static_view(view, &shell->background_layer);
>  }
>  
>  static void
> @@ -3245,14 +3239,14 @@ desktop_shell_set_background(struct wl_client *client,
>  }
>  
>  static void
> -panel_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +panel_configure(struct weston_surface *es, int32_t sx, int32_t sy)
>  {
>  	struct desktop_shell *shell = es->configure_private;
>  	struct weston_view *view;
>  
>  	view = container_of(es->views.next, struct weston_view, surface_link);
>  
> -	configure_static_view(view, &shell->panel_layer, width, height);
> +	configure_static_view(view, &shell->panel_layer);
>  }
>  
>  static void
> @@ -3288,20 +3282,16 @@ desktop_shell_set_panel(struct wl_client *client,
>  }
>  
>  static void
> -lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +lock_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
>  {
>  	struct desktop_shell *shell = surface->configure_private;
>  	struct weston_view *view;
>  
>  	view = container_of(surface->views.next, struct weston_view, surface_link);
>  
> -	if (width == 0)
> +	if (surface->width == 0)
>  		return;
>  
> -	surface->width = width;
> -	surface->height = height;
> -	view->geometry.width = width;
> -	view->geometry.height = height;
>  	center_on_output(view, get_default_output(shell->compositor));
>  
>  	if (!weston_surface_is_mapped(surface)) {
> @@ -3488,16 +3478,16 @@ resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *d
>  				wl_fixed_to_int(seat->pointer->grab_y),
>  				&x, &y);
>  
> -	if (x < shsurf->view->geometry.width / 3)
> +	if (x < shsurf->surface->width / 3)
>  		edges |= WL_SHELL_SURFACE_RESIZE_LEFT;
> -	else if (x < 2 * shsurf->view->geometry.width / 3)
> +	else if (x < 2 * shsurf->surface->width / 3)
>  		edges |= 0;
>  	else
>  		edges |= WL_SHELL_SURFACE_RESIZE_RIGHT;
>  
> -	if (y < shsurf->view->geometry.height / 3)
> +	if (y < shsurf->surface->height / 3)
>  		edges |= WL_SHELL_SURFACE_RESIZE_TOP;
> -	else if (y < 2 * shsurf->view->geometry.height / 3)
> +	else if (y < 2 * shsurf->surface->height / 3)
>  		edges |= 0;
>  	else
>  		edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
> @@ -3817,15 +3807,15 @@ alt_tab_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
>  		weston_view_damage_below(v);
>  		weston_surface_damage(v->surface);
>  
> -		weston_view_configure(v, x, y, view->geometry.width, view->geometry.height);
> +		weston_view_set_position(v, x, y);
>  
>  		preview->listener.notify = alt_tab_handle_surface_destroy;
>  		wl_signal_add(&v->destroy_signal, &preview->listener);
>  
> -		if (view->geometry.width > view->geometry.height)
> -			scale = side / (float) view->geometry.width;
> +		if (view->surface->width > view->surface->height)
> +			scale = side / (float) view->surface->width;
>  		else
> -			scale = side / (float) view->geometry.height;
> +			scale = side / (float) view->surface->height;
>  
>  		wl_list_insert(&v->geometry.transformation_list,
>  			       &preview->transform.link);
> @@ -3864,8 +3854,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
>  	if (!shsurf)
>  		return;
>  
> -	cx = 0.5f * shsurf->view->geometry.width;
> -	cy = 0.5f * shsurf->view->geometry.height;
> +	cx = 0.5f * shsurf->surface->width;
> +	cy = 0.5f * shsurf->surface->height;
>  
>  	dx = wl_fixed_to_double(pointer->x) - rotate->center.x;
>  	dy = wl_fixed_to_double(pointer->y) - rotate->center.y;
> @@ -3963,8 +3953,8 @@ surface_rotate(struct shell_surface *surface, struct weston_seat *seat)
>  		return;
>  
>  	weston_view_to_global_float(surface->view,
> -				    surface->view->geometry.width * 0.5f,
> -				    surface->view->geometry.height * 0.5f,
> +				    surface->surface->width * 0.5f,
> +				    surface->surface->height * 0.5f,
>  				    &rotate->center.x, &rotate->center.y);
>  
>  	dx = wl_fixed_to_double(seat->pointer->x) - rotate->center.x;
> @@ -4078,7 +4068,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
>  
>  /* no-op func for checking black surface */
>  static void
> -black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
>  {
>  }
>  
> @@ -4221,7 +4211,9 @@ shell_fade_create_surface(struct desktop_shell *shell)
>  		return NULL;
>  	}
>  
> -	weston_view_configure(view, 0, 0, 8192, 8192);
> +	surface->width = 8192;
> +	surface->height = 8192;
> +	weston_view_set_position(view, 0, 0);
>  	weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
>  	wl_list_insert(&compositor->fade_layer.view_list,
>  		       &view->layer_link);
> @@ -4380,7 +4372,7 @@ show_input_panels(struct wl_listener *listener, void *data)
>  		weston_view_geometry_dirty(ipsurf->view);
>  		weston_view_update_transform(ipsurf->view);
>  		weston_surface_damage(ipsurf->surface);
> -		weston_slide_run(ipsurf->view, ipsurf->view->geometry.height,
> +		weston_slide_run(ipsurf->view, ipsurf->surface->height,
>  				 0, NULL, NULL);
>  	}
>  }
> @@ -4427,7 +4419,7 @@ center_on_output(struct weston_view *view, struct weston_output *output)
>  	x = output->x + (output->width - width) / 2 - surf_x / 2;
>  	y = output->y + (output->height - height) / 2 - surf_y / 2;
>  
> -	weston_view_configure(view, x, y, width, height);
> +	weston_view_set_position(view, x, y);
>  }
>  
>  static void
> @@ -4472,9 +4464,9 @@ weston_view_set_initial_position(struct weston_view *view,
>  	 * output.
>  	 */
>  	panel_height = get_output_panel_height(shell, target_output);
> -	range_x = target_output->width - view->geometry.width;
> +	range_x = target_output->width - view->surface->width;
>  	range_y = (target_output->height - panel_height) -
> -		  view->geometry.height;
> +		  view->surface->height;
>  
>  	if (range_x > 0)
>  		dx = random() % range_x;
> @@ -4494,17 +4486,13 @@ weston_view_set_initial_position(struct weston_view *view,
>  
>  static void
>  map(struct desktop_shell *shell, struct shell_surface *shsurf,
> -    int32_t width, int32_t height, int32_t sx, int32_t sy)
> +    int32_t sx, int32_t sy)
>  {
>  	struct weston_compositor *compositor = shell->compositor;
>  	struct weston_seat *seat;
>  	int panel_height = 0;
>  	int32_t surf_x, surf_y;
>  
> -	shsurf->view->geometry.width = width;
> -	shsurf->view->geometry.height = height;
> -	weston_view_geometry_dirty(shsurf->view);
> -
>  	/* initial positioning, see also configure() */
>  	switch (shsurf->type) {
>  	case SHELL_SURFACE_TOPLEVEL:
> @@ -4587,24 +4575,17 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf,
>  
>  static void
>  configure(struct desktop_shell *shell, struct weston_surface *surface,
> -	  float x, float y, int32_t width, int32_t height)
> +	  float x, float y)
>  {
>  	enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
>  	struct shell_surface *shsurf;
>  	struct weston_view *view;
> -	int32_t surf_x, surf_y;
> +	int32_t mx, my, surf_x, surf_y;
>  
>  	shsurf = get_shell_surface(surface);
>  	if (shsurf)
>  		surface_type = shsurf->type;
>  
> -	/* TODO:
> -	 * This should probably be changed to be more shell_surface
> -	 * dependent
> -	 */
> -	wl_list_for_each(view, &surface->views, surface_link)
> -		weston_view_configure(view, x, y, width, height);
> -
>  	switch (surface_type) {
>  	case SHELL_SURFACE_FULLSCREEN:
>  		shell_configure_fullscreen(shsurf);
> @@ -4613,9 +4594,10 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
>  		/* setting x, y and using configure to change that geometry */
>  		surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y,
>  		                                                 NULL, NULL);
> -		shsurf->view->geometry.x = shsurf->output->x - surf_x;
> -		shsurf->view->geometry.y = shsurf->output->y +
> -			get_output_panel_height(shell,shsurf->output) - surf_y;
> +		mx = shsurf->output->x - surf_x;
> +		my = shsurf->output->y +
> +		     get_output_panel_height(shell,shsurf->output) - surf_y;
> +		weston_view_set_position(shsurf->view, mx, my);
>  		break;
>  	case SHELL_SURFACE_TOPLEVEL:
>  	case SHELL_SURFACE_TRANSIENT:
> @@ -4623,6 +4605,7 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
>  	case SHELL_SURFACE_XWAYLAND:
>  	case SHELL_SURFACE_NONE:
>  	default:
> +		weston_view_set_position(shsurf->view, x, y);
>  		break;
>  	}
>  
> @@ -4637,7 +4620,7 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
>  }
>  
>  static void
> -shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
>  {
>  	struct shell_surface *shsurf = get_shell_surface(es);
>  	struct desktop_shell *shell = shsurf->shell;
> @@ -4649,7 +4632,7 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32
>  		remove_popup_grab(shsurf);
>  	}
>  
> -	if (width == 0)
> +	if (es->width == 0)
>  		return;
>  
>  	if (shsurf->next_type != SHELL_SURFACE_NONE &&
> @@ -4659,10 +4642,12 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32
>  	}
>  
>  	if (!weston_surface_is_mapped(es)) {
> -		map(shell, shsurf, width, height, sx, sy);
> +		map(shell, shsurf, sx, sy);
>  	} else if (type_changed || sx != 0 || sy != 0 ||
> -		   shsurf->view->geometry.width != width ||
> -		   shsurf->view->geometry.height != height) {
> +		   shsurf->last_width != es->width ||
> +		   shsurf->last_height != es->height) {
> +		shsurf->last_width = es->width;
> +		shsurf->last_height = es->height;
>  		float from_x, from_y;
>  		float to_x, to_y;
>  
> @@ -4670,8 +4655,7 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32
>  		weston_view_to_global_float(shsurf->view, sx, sy, &to_x, &to_y);
>  		configure(shell, es,
>  			  shsurf->view->geometry.x + to_x - from_x,
> -			  shsurf->view->geometry.y + to_y - from_y,
> -			  width, height);
> +			  shsurf->view->geometry.y + to_y - from_y);
>  	}
>  }
>  
> @@ -4771,12 +4755,12 @@ bind_desktop_shell(struct wl_client *client,
>  }
>  
>  static void
> -screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +screensaver_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
>  {
>  	struct desktop_shell *shell = surface->configure_private;
>  	struct weston_view *view;
>  
> -	if (width == 0)
> +	if (surface->width == 0)
>  		return;
>  
>  	/* XXX: starting weston-screensaver beforehand does not work */
> @@ -4853,14 +4837,14 @@ bind_screensaver(struct wl_client *client,
>  }
>  
>  static void
> -input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
>  {
>  	struct input_panel_surface *ip_surface = surface->configure_private;
>  	struct desktop_shell *shell = ip_surface->shell;
>  	float x, y;
>  	uint32_t show_surface = 0;
>  
> -	if (width == 0)
> +	if (surface->width == 0)
>  		return;
>  
>  	if (!weston_surface_is_mapped(surface)) {
> @@ -4876,18 +4860,18 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in
>  		x = get_default_view(shell->text_input.surface)->geometry.x + shell->text_input.cursor_rectangle.x2;
>  		y = get_default_view(shell->text_input.surface)->geometry.y + shell->text_input.cursor_rectangle.y2;
>  	} else {
> -		x = ip_surface->output->x + (ip_surface->output->width - width) / 2;
> -		y = ip_surface->output->y + ip_surface->output->height - height;
> +		x = ip_surface->output->x + (ip_surface->output->width - surface->width) / 2;
> +		y = ip_surface->output->y + ip_surface->output->height - surface->height;
>  	}
>  
> -	weston_view_configure(ip_surface->view, x, y, width, height);
> +	weston_view_set_position(ip_surface->view, x, y);
>  
>  	if (show_surface) {
>  		wl_list_insert(&shell->input_panel_layer.view_list,
>  			       &ip_surface->view->layer_link);
>  		weston_view_update_transform(ip_surface->view);
>  		weston_surface_damage(surface);
> -		weston_slide_run(ip_surface->view, ip_surface->view->geometry.height, 0, NULL, NULL);
> +		weston_slide_run(ip_surface->view, ip_surface->view->surface->height, 0, NULL, NULL);
>  	}
>  }
>  
> @@ -5474,12 +5458,12 @@ exposay_layout(struct desktop_shell *shell)
>  		if (esurface->row == shell->exposay.grid_size - 1)
>  			esurface->x += (shell->exposay.surface_size + shell->exposay.padding_inner) * last_row_removed / 2;
>  
> -		if (view->geometry.width > view->geometry.height)
> -			esurface->scale = shell->exposay.surface_size / (float) view->geometry.width;
> +		if (view->surface->width > view->surface->height)
> +			esurface->scale = shell->exposay.surface_size / (float) view->surface->width;
>  		else
> -			esurface->scale = shell->exposay.surface_size / (float) view->geometry.height;
> -		esurface->width = view->geometry.width * esurface->scale;
> -		esurface->height = view->geometry.height * esurface->scale;
> +			esurface->scale = shell->exposay.surface_size / (float) view->surface->height;
> +		esurface->width = view->surface->width * esurface->scale;
> +		esurface->height = view->surface->height * esurface->scale;
>  
>  		if (shell->exposay.focus_current == esurface->view)
>  			exposay_highlight_surface(shell, esurface);
> diff --git a/src/tablet-shell.c b/src/tablet-shell.c
> index 5e92678..b14174b 100644
> --- a/src/tablet-shell.c
> +++ b/src/tablet-shell.c
> @@ -143,13 +143,13 @@ get_surface_view(struct weston_surface *surface, int create)
>  
>  static void
>  tablet_shell_surface_configure(struct weston_surface *surface,
> -			       int32_t sx, int32_t sy, int32_t width, int32_t height)
> +			       int32_t sx, int32_t sy)
>  {
>  	struct tablet_shell *shell = get_shell(surface->compositor);
>  	struct weston_view *view = get_surface_view(surface, 0);
>  	assert(view);
>  
> -	if (weston_surface_is_mapped(surface) || width == 0)
> +	if (weston_surface_is_mapped(surface) || surface->width == 0)
>  		return;
>  
>  	if (surface == shell->lockscreen_surface) {
> @@ -178,7 +178,7 @@ tablet_shell_surface_configure(struct weston_surface *surface,
>  	}
>  
>  	if (view) {
> -		weston_view_configure(view, 0, 0, width, height);
> +		weston_view_set_position(view, 0, 0);
>  		weston_view_update_transform(view);
>  	}
>  }
> diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
> index 788e694..b496635 100644
> --- a/tests/surface-global-test.c
> +++ b/tests/surface-global-test.c
> @@ -38,7 +38,9 @@ surface_to_from_global(void *data)
>  	assert(surface);
>  	view = weston_view_create(surface);
>  	assert(view);
> -	weston_view_configure(view, 5, 10, 50, 50);
> +	surface->width = 50;
> +	surface->height = 50;
> +	weston_view_set_position(view, 5, 10);
>  	weston_view_update_transform(view);
>  
>  	weston_view_to_global_float(view, 33, 22, &x, &y);
> diff --git a/tests/surface-test.c b/tests/surface-test.c
> index 4a8b2b2..80dce81 100644
> --- a/tests/surface-test.c
> +++ b/tests/surface-test.c
> @@ -38,7 +38,9 @@ surface_transform(void *data)
>  	assert(surface);
>  	view = weston_view_create(surface);
>  	assert(view);
> -	weston_view_configure(view, 100, 100, 200, 200);
> +	surface->width = 200;
> +	surface->height = 200;
> +	weston_view_set_position(view, 100, 100);
>  	weston_view_update_transform(view);
>  	weston_view_to_global_float(view, 20, 20, &x, &y);
>  
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index aebe57d..fc025fa 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -75,7 +75,7 @@ notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
>  }
>  
>  static void
> -test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
> +test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
>  {
>  	struct weston_test_surface *test_surface = surface->configure_private;
>  	struct weston_test *test = test_surface->test;
> @@ -84,9 +84,8 @@ test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy, i
>  		wl_list_insert(&test->layer.view_list,
>  			       &test_surface->view->layer_link);
>  
> -	weston_view_configure(test_surface->view,
> -			      test_surface->x, test_surface->y,
> -			      width, height);
> +	weston_view_set_position(test_surface->view,
> +				 test_surface->x, test_surface->y);
>  
>  	weston_view_update_transform(test_surface->view);
>  }
> -- 
> 1.8.3.1
> 
> _______________________________________________
> 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