[PATCH 2/3] shell: Add fullscreen path into activate()

zhiwen.wu at linux.intel.com zhiwen.wu at linux.intel.com
Sun Apr 1 05:13:08 PDT 2012


From: Alex Wu <zhiwen.wu at linux.intel.com>

Use shell_stack_fullscreen() to raise fullscreen surface in activate(),
and before activate() a regular surface, move all the fullscreen
surfaces from fullscreen_layer to toplevel_layer.

Also add a void *private into struct wesont_surface since we already
have a configure() vfunc. That helps to get the associated fullscreen
surface of black surface.
---
 src/compositor.h |    1 +
 src/shell.c      |   43 +++++++++++++++++++++++++++++++++++++------
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 9f8f57d..d1cd7c8 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -336,6 +336,7 @@ struct weston_surface {
 	 * are the sx and sy paramerters supplied to surface::attach .
 	 */
 	void (*configure)(struct weston_surface *es, int32_t sx, int32_t sy);
+	void *private;
 };
 
 void
diff --git a/src/shell.c b/src/shell.c
index 46fa370..a4cf0b4 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -519,8 +519,12 @@ shell_surface_set_maximized(struct wl_client *client,
 	shsurf->type = SHELL_SURFACE_MAXIMIZED;
 }
 
+static void
+black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
+
 static struct weston_surface *
 create_black_surface(struct weston_compositor *ec,
+		     struct weston_surface *fs_surface,
 		     GLfloat x, GLfloat y, int w, int h)
 {
 	struct weston_surface *surface = NULL;
@@ -531,6 +535,8 @@ create_black_surface(struct weston_compositor *ec,
 		return NULL;
 	}
 
+	surface->configure = black_surface_configure;
+	surface->private = fs_surface;
 	weston_surface_configure(surface, x, y, w, h);
 	weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1);
 	return surface;
@@ -551,6 +557,7 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
 	if (!shsurf->fullscreen.black_surface)
 		shsurf->fullscreen.black_surface =
 			create_black_surface(surface->compositor,
+					     surface,
 					     output->x, output->y,
 					     output->current->width,
 					     output->current->height);
@@ -1410,6 +1417,7 @@ activate(struct weston_shell *base, struct weston_surface *es,
 {
 	struct wl_shell *shell = container_of(base, struct wl_shell, shell);
 	struct weston_compositor *compositor = shell->compositor;
+	struct weston_surface *surf, *prev;
 
 	weston_surface_activate(es, device, time);
 
@@ -1430,14 +1438,42 @@ activate(struct weston_shell *base, struct weston_surface *es,
 		break;
 	case SHELL_SURFACE_FULLSCREEN:
 		/* should on top of panels */
+		shell_stack_fullscreen(get_shell_surface(es));
 		break;
 	default:
+                /* move the fullscreen surfaces down into the toplevel layer */
+		if (!wl_list_empty(&shell->fullscreen_layer.surface_list)) {
+			wl_list_for_each_reverse_safe(surf,
+						      prev, 
+					              &shell->fullscreen_layer.surface_list, 
+						      layer_link)
+				weston_surface_restack(surf,
+						       &shell->toplevel_layer.surface_list); 
+		}
+
 		weston_surface_restack(es,
 				       &shell->toplevel_layer.surface_list);
 		break;
 	}
 }
 
+/* no-op func for checking black surface */
+static void
+black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy)
+{
+}
+
+static bool 
+is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
+{
+	if (es->configure == black_surface_configure) {
+		if (fs_surface)
+			*fs_surface = (struct weston_surface *)es->private;
+		return true;
+	}
+	return false;
+}
+
 static void
 click_to_activate_binding(struct wl_input_device *device,
 			  uint32_t time, uint32_t key,
@@ -1452,13 +1488,8 @@ click_to_activate_binding(struct wl_input_device *device,
 	if (!focus)
 		return;
 
-	upper = container_of(focus->link.prev, struct weston_surface, link);
-	if (focus->link.prev != &compositor->surface_list &&
-	    get_shell_surface_type(upper) == SHELL_SURFACE_FULLSCREEN) {
-		printf("%s: focus is black surface, raise its fullscreen surface\n", __func__);
-		shell_stack_fullscreen(get_shell_surface(upper));
+	if (is_black_surface(focus, &upper))
 		focus = upper;
-	}
 
 	if (state && device->pointer_grab == &device->default_pointer_grab)
 		activate(compositor->shell, focus, wd, time);
-- 
1.7.5.4



More information about the wayland-devel mailing list