[RFC patch] compositor: add map() to the shell plugin interface

Pekka Paalanen ppaalanen at gmail.com
Wed Nov 9 02:11:00 PST 2011


wlsc_shell::attach() call does not provide any direct indication whether
this attach request is the first one for a surface and therefore will
map the surface on screen. On map, the shell may want to change the
initial positioning or stacking of the surface.

Add wlsc_shell::map() call. Push the responsibility of adding the
surface to compositor->surface_list to the shell plugin.

This change will help implement screen locking, where the shell will add
newly mapped surfaces to a different list while locked.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 compositor/compositor.c         |    5 +++--
 compositor/compositor.h         |    1 +
 compositor/meego-tablet-shell.c |   13 +++++++++----
 compositor/shell.c              |    7 +++++++
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/compositor/compositor.c b/compositor/compositor.c
index 53b282a..5f0dc39 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -1094,6 +1094,7 @@ surface_attach(struct wl_client *client,
 	       struct wl_resource *buffer_resource, int32_t x, int32_t y)
 {
 	struct wlsc_surface *es = resource->data;
+	struct wlsc_shell *shell = es->compositor->shell;
 	struct wl_buffer *buffer = buffer_resource->data;
 	int repick = 0;
 
@@ -1108,7 +1109,7 @@ surface_attach(struct wl_client *client,
 		       &es->buffer_destroy_listener.link);
 
 	if (es->visual == WLSC_NONE_VISUAL) {
-		wl_list_insert(&es->compositor->surface_list, &es->link);
+		shell->map(shell, es);
 		repick = 1;
 	}
 
@@ -1121,7 +1122,7 @@ surface_attach(struct wl_client *client,
 
 	wlsc_buffer_attach(buffer, &es->surface);
 
-	es->compositor->shell->attach(es->compositor->shell, es);
+	shell->attach(shell, es);
 
 	if (repick)
 		wlsc_compositor_repick(es->compositor);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 421b80e..998d8c3 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -163,6 +163,7 @@ struct wlsc_shell {
 			 struct wlsc_surface *es,
 			 struct wlsc_input_device *device, uint32_t time);
 	void (*lock)(struct wlsc_shell *shell);
+	void (*map)(struct wlsc_shell *shell, struct wlsc_surface *surface);
 	void (*attach)(struct wlsc_shell *shell, struct wlsc_surface *surface);
 	void (*set_selection_focus)(struct wlsc_shell *shell,
 				    struct wl_selection *selection,
diff --git a/compositor/meego-tablet-shell.c b/compositor/meego-tablet-shell.c
index 35b9775..d1adbd2 100644
--- a/compositor/meego-tablet-shell.c
+++ b/compositor/meego-tablet-shell.c
@@ -201,17 +201,21 @@ meego_tablet_zoom_run(struct meego_tablet_shell *shell,
 	return zoom;
 }
 
-/* FIXME: We should be handling map, not attach...  Map is when the
- * surface becomes visible, which is what we want to catch.  Attach
- * will happen whenever the surface changes. */
-
 static void
 meego_tablet_shell_attach(struct wlsc_shell *base,
 			  struct wlsc_surface *surface)
 {
+}
+
+static void
+meego_tablet_shell_map(struct wlsc_shell *base,
+		       struct wlsc_surface *surface)
+{
 	struct meego_tablet_shell *shell =
 		container_of(base, struct meego_tablet_shell, shell);
 
+	wl_list_insert(&surface->compositor->surface_list, &surface->link);
+
 	surface->x = 0;
 	surface->y = 0;
 
@@ -679,6 +683,7 @@ shell_init(struct wlsc_compositor *compositor)
 	compositor->shell = &shell->shell;
 
 	shell->shell.lock = meego_tablet_shell_lock;
+	shell->shell.map = meego_tablet_shell_map;
 	shell->shell.attach = meego_tablet_shell_attach;
 	shell->shell.set_selection_focus =
 		meego_tablet_shell_set_selection_focus;
diff --git a/compositor/shell.c b/compositor/shell.c
index ed2637d..827aea3 100644
--- a/compositor/shell.c
+++ b/compositor/shell.c
@@ -934,6 +934,12 @@ attach(struct wlsc_shell *base, struct wlsc_surface *es)
 }
 
 static void
+map(struct wlsc_shell *base, struct wlsc_surface *es)
+{
+	wl_list_insert(&es->compositor->surface_list, &es->link);
+}
+
+static void
 desktop_shell_sigchld(struct wlsc_process *process, int status)
 {
 	struct wl_shell *shell =
@@ -1032,6 +1038,7 @@ shell_init(struct wlsc_compositor *ec)
 	shell->compositor = ec;
 	shell->shell.activate = activate;
 	shell->shell.lock = lock;
+	shell->shell.map = map;
 	shell->shell.attach = attach;
 	shell->shell.set_selection_focus = wlsc_selection_set_focus;
 
-- 
1.7.3.4



More information about the wayland-devel mailing list