[PATCH 4/7] xdg-shell: Remove SHELL_SURFACE_FULLSCREEN and use fullscreen state.

antognolli at gmail.com antognolli at gmail.com
Fri Jul 19 12:42:46 PDT 2013


From: Rafael Antognolli <rafael.antognolli at intel.com>

Use the newly added fullscreen state to implement the fullscreen surface
type.

Change each place where a surface type change was in place to check for
the fullscreen state too.
---
 src/xdg-surface.c | 108 +++++++++++++++++++++++++-----------------------------
 1 file changed, 49 insertions(+), 59 deletions(-)

diff --git a/src/xdg-surface.c b/src/xdg-surface.c
index 26cac7b..82e3551 100644
--- a/src/xdg-surface.c
+++ b/src/xdg-surface.c
@@ -171,7 +171,6 @@ enum shell_surface_type {
 	SHELL_SURFACE_NONE,
 	SHELL_SURFACE_TOPLEVEL,
 	SHELL_SURFACE_TRANSIENT,
-	SHELL_SURFACE_FULLSCREEN,
 	SHELL_SURFACE_POPUP,
 	SHELL_SURFACE_XWAYLAND
 };
@@ -233,6 +232,7 @@ struct shell_surface {
 
 	struct {
 		bool maximized;
+		bool fullscreen;
 	} cur, next; /* surface states */
 	bool state_changed;
 };
@@ -1099,7 +1099,7 @@ surface_move(struct shell_surface *shsurf, struct weston_seat *seat)
 	if (!shsurf)
 		return -1;
 
-	if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
+	if (shsurf->cur.fullscreen)
 		return 0;
 
 	move = malloc(sizeof *move);
@@ -1254,7 +1254,7 @@ surface_resize(struct shell_surface *shsurf,
 {
 	struct weston_resize_grab *resize;
 
-	if (shsurf->type == SHELL_SURFACE_FULLSCREEN || shsurf->cur.maximized)
+	if (shsurf->cur.fullscreen || shsurf->cur.maximized)
 		return 0;
 
 	if (edges == 0 || edges > 15 ||
@@ -1284,7 +1284,7 @@ shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
 	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
 	struct weston_surface *surface;
 
-	if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
+	if (shsurf->cur.fullscreen)
 		return;
 
 	surface = weston_surface_get_main_surface(seat->pointer->focus);
@@ -1586,20 +1586,10 @@ shell_unset_maximized(struct shell_surface *shsurf)
 static int
 reset_shell_surface_type(struct shell_surface *surface)
 {
-	switch (surface->type) {
-	case SHELL_SURFACE_FULLSCREEN:
+	if (surface->cur.fullscreen)
 		shell_unset_fullscreen(surface);
-		break;
-	case SHELL_SURFACE_NONE:
-	case SHELL_SURFACE_TOPLEVEL:
-	case SHELL_SURFACE_TRANSIENT:
-	case SHELL_SURFACE_POPUP:
-	case SHELL_SURFACE_XWAYLAND:
-		break;
-	}
-
 	if (surface->cur.maximized)
-	  shell_unset_maximized(surface);
+		shell_unset_maximized(surface);
 
 	surface->type = SHELL_SURFACE_NONE;
 	return 0;
@@ -1636,7 +1626,7 @@ set_surface_type(struct shell_surface *shsurf)
 
 	switch (shsurf->type) {
 	case SHELL_SURFACE_TOPLEVEL:
-		if (shsurf->cur.maximized)
+		if (shsurf->cur.maximized || shsurf->cur.fullscreen)
 			set_full_output(surface, shsurf);
 		break;
 	case SHELL_SURFACE_TRANSIENT:
@@ -1645,10 +1635,6 @@ set_surface_type(struct shell_surface *shsurf)
 				pes->geometry.y + shsurf->transient.y);
 		break;
 
-	case SHELL_SURFACE_FULLSCREEN:
-		set_full_output(surface, shsurf);
-		break;
-
 	case SHELL_SURFACE_XWAYLAND:
 		weston_surface_set_position(surface, shsurf->transient.x,
 					    shsurf->transient.y);
@@ -1663,8 +1649,10 @@ static void
 surface_clear_next_states(struct shell_surface *shsurf)
 {
 	shsurf->next.maximized = false;
+	shsurf->next.fullscreen = false;
 
-	if (shsurf->next.maximized != shsurf->cur.maximized)
+	if ((shsurf->next.maximized != shsurf->cur.maximized) ||
+	    (shsurf->next.fullscreen != shsurf->cur.fullscreen))
 		shsurf->state_changed = true;
 }
 
@@ -1775,6 +1763,7 @@ shell_surface_set_maximized(struct wl_client *client,
 {
 	struct shell_surface *shsurf = resource->data;
 
+	surface_clear_next_states(shsurf);
 	set_maximized(client, resource, output_resource);
 	shsurf->next.maximized = true;
 	shsurf->state_changed = true;
@@ -1958,7 +1947,7 @@ set_fullscreen(struct shell_surface *shsurf,
 	shsurf->fullscreen_output = shsurf->output;
 	shsurf->fullscreen.type = method;
 	shsurf->fullscreen.framerate = framerate;
-	shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
+	shsurf->next_type = shsurf->type;;
 
 	shsurf->client->send_configure(shsurf->surface, 0,
 				       shsurf->output->width,
@@ -1983,6 +1972,9 @@ shell_surface_set_fullscreen(struct wl_client *client,
 	surface_clear_next_states(shsurf);
 
 	set_fullscreen(shsurf, method, framerate, output);
+
+	shsurf->next.fullscreen = true;
+	shsurf->state_changed = true;
 }
 
 static void
@@ -2688,8 +2680,7 @@ move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *dat
 		return;
 
 	shsurf = get_shell_surface(surface);
-	if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
-	    shsurf->cur.maximized)
+	if (shsurf == NULL || shsurf->cur.fullscreen || shsurf->cur.maximized)
 		return;
 
 	surface_move(shsurf, (struct weston_seat *) seat);
@@ -2710,8 +2701,7 @@ resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *d
 		return;
 
 	shsurf = get_shell_surface(surface);
-	if (!shsurf || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
-	    shsurf->cur.maximized)
+	if (!shsurf || shsurf->cur.fullscreen || shsurf->cur.maximized)
 		return;
 
 	weston_surface_from_global(surface,
@@ -2974,8 +2964,7 @@ rotate_binding(struct weston_seat *seat, uint32_t time, uint32_t button,
 		return;
 
 	surface = get_shell_surface(base_surface);
-	if (!surface || surface->type == SHELL_SURFACE_FULLSCREEN ||
-	    surface->cur.maximized)
+	if (!surface || surface->cur.fullscreen || surface->cur.maximized)
 		return;
 
 	surface_rotate(surface, seat);
@@ -3001,6 +2990,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
 	struct weston_surface *main_surface;
 	struct focus_state *state;
 	struct workspace *ws;
+	struct shell_surface *shsurf;
 
 	main_surface = weston_surface_get_main_surface(es);
 
@@ -3014,18 +3004,18 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
 	wl_list_remove(&state->surface_destroy_listener.link);
 	wl_signal_add(&es->destroy_signal, &state->surface_destroy_listener);
 
-	switch (get_shell_surface_type(main_surface)) {
-	case SHELL_SURFACE_FULLSCREEN:
+	shsurf = get_shell_surface(main_surface);
+
+	if (shsurf->cur.fullscreen) {
 		/* should on top of panels */
 		shell_stack_fullscreen(get_shell_surface(main_surface));
 		shell_configure_fullscreen(get_shell_surface(main_surface));
-		break;
-	default:
-		restore_all_output_modes(shell->compositor);
-		ws = get_current_workspace(shell);
-		weston_surface_restack(main_surface, &ws->layer.surface_list);
-		break;
+		return;
 	}
+
+	restore_all_output_modes(shell->compositor);
+	ws = get_current_workspace(shell);
+	weston_surface_restack(main_surface, &ws->layer.surface_list);
 }
 
 /* no-op func for checking black surface */
@@ -3436,7 +3426,10 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
 	/* initial positioning, see also configure() */
 	switch (surface_type) {
 	case SHELL_SURFACE_TOPLEVEL:
-		if (shsurf->cur.maximized) {
+		if (shsurf->cur.fullscreen) {
+			center_on_output(surface, shsurf->fullscreen_output);
+			shell_map_fullscreen(shsurf);
+		} else if (shsurf->cur.maximized) {
 			/* use surface configure to set the geometry */
 			panel_height = get_output_panel_height(shell,
 							       surface->output);
@@ -3451,10 +3444,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
 			weston_surface_set_initial_position(surface, shell);
 		}
 		break;
-	case SHELL_SURFACE_FULLSCREEN:
-		center_on_output(surface, shsurf->fullscreen_output);
-		shell_map_fullscreen(shsurf);
-		break;
 	case SHELL_SURFACE_POPUP:
 		shell_map_popup(shsurf);
 		break;
@@ -3474,11 +3463,12 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
 		parent = shsurf->parent;
 		wl_list_insert(parent->layer_link.prev, &surface->layer_link);
 		break;
-	case SHELL_SURFACE_FULLSCREEN:
 	case SHELL_SURFACE_NONE:
 		break;
 	case SHELL_SURFACE_XWAYLAND:
 	default:
+		if (shsurf->cur.fullscreen)
+			break;
 		ws = get_current_workspace(shell);
 		wl_list_insert(&ws->layer.surface_list, &surface->layer_link);
 		break;
@@ -3498,7 +3488,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
 				XDG_SURFACE_TRANSIENT_INACTIVE)
 			break;
 	case SHELL_SURFACE_TOPLEVEL:
-	case SHELL_SURFACE_FULLSCREEN:
 		if (!shell->locked) {
 			wl_list_for_each(seat, &compositor->seat_list, link)
 				activate(shell, surface, seat);
@@ -3527,26 +3516,28 @@ static void
 configure(struct desktop_shell *shell, struct weston_surface *surface,
 	  float x, float y, int32_t width, int32_t height)
 {
-	enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
 	struct shell_surface *shsurf;
 	int32_t surf_x, surf_y;
 
 	shsurf = get_shell_surface(surface);
-	if (shsurf)
-		surface_type = shsurf->type;
 
 	weston_surface_configure(surface, x, y, width, height);
 
-	if (surface_type == SHELL_SURFACE_FULLSCREEN) {
-		shell_stack_fullscreen(shsurf);
-		shell_configure_fullscreen(shsurf);
-	} else if (shsurf->cur.maximized) {
-		/* setting x, y and using configure to change that geometry */
-		surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y,
-		                                                 NULL, NULL);
-		surface->geometry.x = surface->output->x - surf_x;
-		surface->geometry.y = surface->output->y +
-		get_output_panel_height(shell,surface->output) - surf_y;
+	if (shsurf) {
+		if (shsurf->cur.fullscreen) {
+			shell_stack_fullscreen(shsurf);
+			shell_configure_fullscreen(shsurf);
+		} else if (shsurf->cur.maximized) {
+			/* setting x, y and using configure to change that
+			 * geometry */
+			surface_subsurfaces_boundingbox(shsurf->surface,
+							&surf_x, &surf_y,
+							NULL, NULL);
+			surface->geometry.x = surface->output->x - surf_x;
+			surface->geometry.y = surface->output->y +
+				get_output_panel_height(shell,surface->output) -
+				surf_y;
+		}
 	}
 
 	/* XXX: would a fullscreen surface need the same handling? */
@@ -4006,7 +3997,6 @@ switcher_next(struct switcher *switcher)
 	wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
 		switch (get_shell_surface_type(surface)) {
 		case SHELL_SURFACE_TOPLEVEL:
-		case SHELL_SURFACE_FULLSCREEN:
 			if (first == NULL)
 				first = surface;
 			if (prev == switcher->current)
@@ -4040,7 +4030,7 @@ switcher_next(struct switcher *switcher)
 	next->alpha = 1.0;
 
 	shsurf = get_shell_surface(switcher->current);
-	if (shsurf && shsurf->type ==SHELL_SURFACE_FULLSCREEN)
+	if (shsurf && shsurf->cur.fullscreen)
 		shsurf->fullscreen.black_surface->alpha = 1.0;
 }
 
-- 
1.7.11.7



More information about the wayland-devel mailing list