<p dir="ltr">As Guilio said, we don't want shells to be randomly resizing surfaces that come from clients. If it comes from a client, then the surface size comes from the buffer size. If it comes from a shell, then it is free to resize as it sees fit. I the reason for two functions is precicely that weston_surface_set_size is only for non-client surfaces and therefore has the assert.<br>
--Jason Ekstrand</p>
<div class="gmail_quote">On Dec 9, 2013 2:16 PM, "Giulio Camuffo" <<a href="mailto:giuliocamuffo@gmail.com">giuliocamuffo@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2013/12/9 Bryce W. Harrington <<a href="mailto:b.harrington@samsung.com">b.harrington@samsung.com</a>>:<br>
> On Wed, Dec 04, 2013 at 08:32:03PM -0600, Jason Ekstrand wrote:<br>
>> Surfaces that are created by clients get their size automatically updated<br>
>> by the attach/commit. Surfaces created directly by shells (such as black<br>
>> surfaces) sometimes need to be manually resized. This function allows you<br>
>> to do that while being somewhat less messy than messing with the internals<br>
>> of weston_surface manually.<br>
>><br>
>> Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
>> ---<br>
>> desktop-shell/shell.c | 9 +++------<br>
>> src/compositor.c | 15 +++++++++++----<br>
>> src/compositor.h | 4 ++++<br>
>> 3 files changed, 18 insertions(+), 10 deletions(-)<br>
>><br>
>> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c<br>
>> index de54e37..56e0338 100644<br>
>> --- a/desktop-shell/shell.c<br>
>> +++ b/desktop-shell/shell.c<br>
>> @@ -504,8 +504,7 @@ create_focus_surface(struct weston_compositor *ec,<br>
>> fsurf->view = weston_view_create (surface);<br>
>> fsurf->view->output = output;<br>
>><br>
>> - surface->width = output->width;<br>
>> - surface->height = output->height;<br>
>> + weston_surface_set_size(surface, output->width, output->height);<br>
>> weston_view_set_position(fsurf->view, output->x, output->y);<br>
>> weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);<br>
>> pixman_region32_fini(&surface->opaque);<br>
>> @@ -2452,8 +2451,7 @@ create_black_surface(struct weston_compositor *ec,<br>
>> pixman_region32_fini(&surface->input);<br>
>> pixman_region32_init_rect(&surface->input, 0, 0, w, h);<br>
>><br>
>> - surface->width = w;<br>
>> - surface->height = h;<br>
>> + weston_surface_set_size(surface, w, y);<br>
>> weston_view_set_position(view, x, y);<br>
>><br>
>> return view;<br>
>> @@ -4585,8 +4583,7 @@ shell_fade_create_surface(struct desktop_shell *shell)<br>
>> return NULL;<br>
>> }<br>
>><br>
>> - surface->width = 8192;<br>
>> - surface->height = 8192;<br>
>> + weston_surface_set_size(surface, 8192, 8192);<br>
>> weston_view_set_position(view, 0, 0);<br>
>> weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);<br>
>> wl_list_insert(&compositor->fade_layer.view_list,<br>
>> diff --git a/src/compositor.c b/src/compositor.c<br>
>> index 8f4bdef..97c42b3 100644<br>
>> --- a/src/compositor.c<br>
>> +++ b/src/compositor.c<br>
>> @@ -1133,8 +1133,7 @@ weston_surface_is_mapped(struct weston_surface *surface)<br>
>> }<br>
>><br>
>> static void<br>
>> -weston_surface_set_size(struct weston_surface *surface,<br>
>> - int32_t width, int32_t height)<br>
>> +surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)<br>
><br>
> This is probably a stupid question so I'll apologize upfront. But is it<br>
> actually necessary to have a separate surface_set_size() routine from<br>
> weston_surface_set_size()? Couldn't the existing routine just be<br>
> exported for the desktop shell to use?<br>
><br>
>> {<br>
>> struct weston_view *view;<br>
>><br>
>> @@ -1148,13 +1147,21 @@ weston_surface_set_size(struct weston_surface *surface,<br>
>> weston_view_geometry_dirty(view);<br>
>> }<br>
>><br>
>> +WL_EXPORT void<br>
>> +weston_surface_set_size(struct weston_surface *surface,<br>
>> + int32_t width, int32_t height)<br>
>> +{<br>
>> + assert(!surface->resource);<br>
><br>
> I'm also confused why this assert is here; there isn't a deref of<br>
> surface->resource here or in surface_set_size(). If surface->resource<br>
> surface->is undefined does it trigger problems further down the stack?<br>
<br>
The thing is that surfaces which have a client side and then have a<br>
resource have their size set by their buffer size, and manually<br>
changing the width or height on them produces artifacts.<br>
This function is for surfaces without a client side, usually created<br>
by the shell.<br>
<br>
><br>
>> + surface_set_size(surface, width, height);<br>
>> +}<br>
>> +<br>
>> static void<br>
>> weston_surface_set_size_from_buffer(struct weston_surface *surface)<br>
>> {<br>
>> int32_t width, height;<br>
>><br>
>> if (!surface->buffer_ref.buffer) {<br>
>> - weston_surface_set_size(surface, 0, 0);<br>
>> + surface_set_size(surface, 0, 0);<br>
>> return;<br>
>> }<br>
>><br>
>> @@ -1174,7 +1181,7 @@ weston_surface_set_size_from_buffer(struct weston_surface *surface)<br>
>><br>
>> width = width / surface->buffer_viewport.scale;<br>
>> height = height / surface->buffer_viewport.scale;<br>
>> - weston_surface_set_size(surface, width, height);<br>
>> + surface_set_size(surface, width, height);<br>
>> }<br>
>><br>
>> WL_EXPORT uint32_t<br>
>> diff --git a/src/compositor.h b/src/compositor.h<br>
>> index 6bd637e..9f89d00 100644<br>
>> --- a/src/compositor.h<br>
>> +++ b/src/compositor.h<br>
>> @@ -1138,6 +1138,10 @@ weston_view_schedule_repaint(struct weston_view *view);<br>
>> int<br>
>> weston_surface_is_mapped(struct weston_surface *surface);<br>
>><br>
>> +WL_EXPORT void<br>
>> +weston_surface_set_size(struct weston_surface *surface,<br>
>> + int32_t width, int32_t height);<br>
>> +<br>
>> void<br>
>> weston_surface_schedule_repaint(struct weston_surface *surface);<br>
>><br>
>> --<br>
>> 1.8.4.2<br>
>><br>
>> _______________________________________________<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>
> _______________________________________________<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>