ivi-shell: fit source rectangle of ivi-surface to the size of application content.

Submitted by Nobuhiko Tanibata on April 27, 2015, 8 a.m.

Details

Message ID 1430121625-11383-1-git-send-email-nobuhiko_tanibata@xddp.denso.co.jp
State Accepted
Commit 65160dcadeefd49b8ec9cf6cbabf0ef85e4288b0
Headers show

Not browsing as part of any series.

Commit Message

Nobuhiko Tanibata April 27, 2015, 8 a.m.
When application changes the size of its content, UI shall fit the source
rectangle, view area, to the size of its content to show whole content.

Signed-off-by: Nobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
---
 ivi-shell/hmi-controller.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

Patch hide | download patch | download mbox

diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 2d15e06..cd79c38 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -542,6 +542,45 @@  set_notification_configure_surface(struct ivi_layout_surface *ivisurf,
 				   void *userdata)
 {
 	struct hmi_controller *hmi_ctrl = userdata;
+	struct ivi_layout_layer *application_layer =
+		hmi_ctrl->application_layer.ivilayer;
+	struct weston_surface *surface;
+	struct ivi_layout_surface **ivisurfs;
+	int32_t length = 0;
+	int32_t i;
+
+	/* return if the surface is not application content */
+	if (is_surf_in_ui_widget(hmi_ctrl, ivisurf)) {
+		return;
+	}
+
+	/*
+	 * if application changes size of wl_buffer. The source rectangle shall be
+	 * fit to the size.
+	 */
+	surface = ivi_controller_interface->surface_get_weston_surface(ivisurf);
+	if (surface) {
+		ivi_controller_interface->surface_set_source_rectangle(
+			ivisurf, 0, 0, surface->width,
+			surface->height);
+	}
+
+	/*
+	 *  search if the surface is already added to layer.
+	 *  If not yet, it is newly invoded application to go to switch_mode.
+	 */
+	ivi_controller_interface->get_surfaces_on_layer(application_layer,
+							&length, &ivisurfs);
+	for (i = 0; i < length; i++) {
+		if (ivisurf == ivisurfs[i]) {
+			/* 
+			 * if it is non new invoked application, just call
+			 * commit_changes to apply source_rectangle.
+			 */
+			ivi_controller_interface->commit_changes();
+			return;
+		}
+	}
 
 	switch_mode(hmi_ctrl, hmi_ctrl->layout_mode);
 }