Add a weston_surface_set_size function

Surfaces that are created by clients get their size automatically updated
by the attach/commit.  Surfaces created directly by shells (such as black
surfaces) sometimes need to be manually resized.  This function allows you
to do that while being somewhat less messy than messing with the internals
of weston_surface manually.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c962d26..3d586ec 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -508,8 +508,7 @@
 	fsurf->view = weston_view_create (surface);
 	fsurf->view->output = output;
 
-	surface->width = output->width;
-	surface->height = output->height;
+	weston_surface_set_size(surface, output->width, 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);
@@ -2471,8 +2470,7 @@
 	pixman_region32_fini(&surface->input);
 	pixman_region32_init_rect(&surface->input, 0, 0, w, h);
 
-	surface->width = w;
-	surface->height = h;
+	weston_surface_set_size(surface, w, y);
 	weston_view_set_position(view, x, y);
 
 	return view;
@@ -4593,8 +4591,7 @@
 		return NULL;
 	}
 
-	surface->width = 8192;
-	surface->height = 8192;
+	weston_surface_set_size(surface, 8192, 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,
diff --git a/src/compositor.c b/src/compositor.c
index c4ffb5e..d273e3f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1219,8 +1219,7 @@
 }
 
 static void
-weston_surface_set_size(struct weston_surface *surface,
-			int32_t width, int32_t height)
+surface_set_size(struct weston_surface *surface, int32_t width, int32_t height)
 {
 	struct weston_view *view;
 
@@ -1234,13 +1233,21 @@
 		weston_view_geometry_dirty(view);
 }
 
+WL_EXPORT void
+weston_surface_set_size(struct weston_surface *surface,
+			int32_t width, int32_t height)
+{
+	assert(!surface->resource);
+	surface_set_size(surface, width, height);
+}
+
 static void
 weston_surface_set_size_from_buffer(struct weston_surface *surface)
 {
 	int32_t width, height;
 
 	if (!surface->buffer_ref.buffer) {
-		weston_surface_set_size(surface, 0, 0);
+		surface_set_size(surface, 0, 0);
 		return;
 	}
 
@@ -1260,7 +1267,7 @@
 
 	width = width / surface->buffer_viewport.scale;
 	height = height / surface->buffer_viewport.scale;
-	weston_surface_set_size(surface, width, height);
+	surface_set_size(surface, width, height);
 }
 
 WL_EXPORT uint32_t
diff --git a/src/compositor.h b/src/compositor.h
index f5a0ba4..f32a497 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1152,6 +1152,10 @@
 int
 weston_surface_is_mapped(struct weston_surface *surface);
 
+WL_EXPORT void
+weston_surface_set_size(struct weston_surface *surface,
+			int32_t width, int32_t height);
+
 void
 weston_surface_schedule_repaint(struct weston_surface *surface);