[PATCH weston 3/5] ivi-shell: call send_surface_send_configure() directly

Pekka Paalanen ppaalanen at gmail.com
Tue Mar 15 15:39:23 UTC 2016


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

For some reason, it seems that ivi-layout.c has tried hard to avoid
calling directly into ivi-shell.c. This means there is a jump through
hoops just to get the configure event sent to the clients. Ivi-shell
registers a listener for a ivi-layout signal for sending the event.

Instead, let ivi-layout.c call directly into ivi-shell.c, and expose a
function to send out the configure events. This reduces some confusion
on who calls what.

The main idea though is that this makes ivi-shell.c not depend on struct
ivi_layout_surface fields directly anymore. In following patches,
ivi_layout_surface can be made opaque for ivi-shell.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 ivi-shell/ivi-layout-transition.c |  4 ++++
 ivi-shell/ivi-layout.c            | 13 +++++++++++--
 ivi-shell/ivi-shell.c             | 40 ++++++++++++++++-----------------------
 ivi-shell/ivi-shell.h             |  4 ++++
 4 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/ivi-shell/ivi-layout-transition.c b/ivi-shell/ivi-layout-transition.c
index 45b8dc5..966473b 100644
--- a/ivi-shell/ivi-layout-transition.c
+++ b/ivi-shell/ivi-layout-transition.c
@@ -31,6 +31,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 
+#include "ivi-shell.h"
 #include "ivi-layout-export.h"
 #include "ivi-layout-private.h"
 
@@ -303,6 +304,9 @@ transition_move_resize_view_destroy(struct ivi_layout_transition *transition)
 	struct ivi_layout_surface *layout_surface = data->surface;
 
 	wl_signal_emit(&layout_surface->configured, layout_surface);
+	shell_surface_send_configure(layout_surface->surface,
+				     layout_surface->prop.dest_width,
+				     layout_surface->prop.dest_height);
 
 	if (transition->private_data) {
 		free(transition->private_data);
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 77578d4..f1ea9bd 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -61,6 +61,7 @@
 #include <assert.h>
 
 #include "compositor.h"
+#include "ivi-shell.h"
 #include "ivi-layout-export.h"
 #include "ivi-layout-private.h"
 
@@ -776,8 +777,12 @@ commit_surface_list(struct ivi_layout *layout)
 			ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
 			ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
 
-			if (configured && !is_surface_transition(ivisurf))
+			if (configured && !is_surface_transition(ivisurf)) {
 				wl_signal_emit(&ivisurf->configured, ivisurf);
+				shell_surface_send_configure(ivisurf->surface,
+							     ivisurf->prop.dest_width,
+							     ivisurf->prop.dest_height);
+			}
 		} else {
 			configured = 0;
 			if (ivisurf->prop.dest_width  != ivisurf->pending.prop.dest_width ||
@@ -789,8 +794,12 @@ commit_surface_list(struct ivi_layout *layout)
 			ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
 			ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
 
-			if (configured && !is_surface_transition(ivisurf))
+			if (configured && !is_surface_transition(ivisurf)) {
 				wl_signal_emit(&ivisurf->configured, ivisurf);
+				shell_surface_send_configure(ivisurf->surface,
+							     ivisurf->prop.dest_width,
+							     ivisurf->prop.dest_height);
+			}
 		}
 	}
 }
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 19140ce..7a53769 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -63,8 +63,6 @@ struct ivi_shell_surface
 	int32_t height;
 
 	struct wl_list link;
-
-	struct wl_listener configured_listener;
 };
 
 struct ivi_shell_setting
@@ -78,25 +76,6 @@ struct ivi_shell_setting
  */
 
 static void
-surface_configure_notify(struct wl_listener *listener, void *data)
-{
-	struct ivi_layout_surface *layout_surf =
-		(struct ivi_layout_surface *)data;
-
-	struct ivi_shell_surface *shell_surf =
-		container_of(listener,
-			     struct ivi_shell_surface,
-			     configured_listener);
-
-	int32_t dest_width = layout_surf->prop.dest_width;
-	int32_t dest_height = layout_surf->prop.dest_height;
-
-	if (shell_surf->resource)
-		ivi_surface_send_configure(shell_surf->resource,
-					   dest_width, dest_height);
-}
-
-static void
 ivi_shell_surface_configure(struct weston_surface *, int32_t, int32_t);
 
 static struct ivi_shell_surface *
@@ -108,6 +87,21 @@ get_ivi_shell_surface(struct weston_surface *surface)
 	return NULL;
 }
 
+void
+shell_surface_send_configure(struct weston_surface *surface,
+			     int32_t width, int32_t height)
+{
+	struct ivi_shell_surface *shsurf;
+
+	shsurf = get_ivi_shell_surface(surface);
+	assert(shsurf);
+	if (!shsurf)
+		return;
+
+	if (shsurf->resource)
+		ivi_surface_send_configure(shsurf->resource, width, height);
+}
+
 static void
 ivi_shell_surface_configure(struct weston_surface *surface,
 			    int32_t sx, int32_t sy)
@@ -255,9 +249,7 @@ application_surface_create(struct wl_client *client,
 	ivisurf->width = 0;
 	ivisurf->height = 0;
 	ivisurf->layout_surface = layout_surface;
-	ivisurf->configured_listener.notify = surface_configure_notify;
-	ivi_layout_surface_add_configured_listener(layout_surface,
-				     &ivisurf->configured_listener);
+
 	/*
 	 * The following code relies on wl_surface destruction triggering
 	 * immediateweston_surface destruction
diff --git a/ivi-shell/ivi-shell.h b/ivi-shell/ivi-shell.h
index 744d969..45faceb 100644
--- a/ivi-shell/ivi-shell.h
+++ b/ivi-shell/ivi-shell.h
@@ -69,4 +69,8 @@ input_panel_setup(struct ivi_shell *shell);
 void
 input_panel_destroy(struct ivi_shell *shell);
 
+void
+shell_surface_send_configure(struct weston_surface *surface,
+			     int32_t width, int32_t height);
+
 #endif /* WESTON_IVI_SHELL_H */
-- 
2.4.10



More information about the wayland-devel mailing list