[PATCH 07/17] shell: Refactor workspace code to operate on shsurfs rather than views

Philip Withnall philip at tecnocode.co.uk
Mon Nov 25 10:01:36 PST 2013


From: Philip Withnall <philip.withnall at collabora.co.uk>

This is needed for the work to refactor window stacking and ordering, as
window order operates on shsurfs, not views.
---
 src/shell.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index 15895e2..209ed30 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1232,20 +1232,25 @@ workspace_has_only(struct workspace *ws, struct weston_surface *surface)
 }
 
 static void
-move_view_to_workspace(struct desktop_shell *shell,
-		       struct weston_view *view,
-		       uint32_t workspace)
+move_surface_to_workspace(struct desktop_shell *shell,
+                          struct shell_surface *shsurf,
+                          uint32_t workspace)
 {
 	struct workspace *from;
 	struct workspace *to;
 	struct weston_seat *seat;
 	struct weston_surface *focus;
-
-	assert(weston_surface_get_main_surface(view->surface) == view->surface);
+	struct weston_view *view;
 
 	if (workspace == shell->workspaces.current)
 		return;
 
+	view = get_default_view(shsurf->surface);
+	if (!view)
+		return;
+
+	assert(weston_surface_get_main_surface(view->surface) == view->surface);
+
 	if (workspace >= shell->workspaces.num)
 		workspace = shell->workspaces.num - 1;
 
@@ -1293,6 +1298,8 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
 	wl_list_remove(&view->layer_link);
 	wl_list_insert(&to->layer.view_list, &view->layer_link);
 
+	shsurf = get_shell_surface(surface);
+
 	replace_focus_state(shell, to, seat);
 	drop_focus_state(shell, from, surface);
 
@@ -1316,7 +1323,6 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
 	    workspace_has_only(to, surface))
 		update_workspace(shell, index, from, to);
 	else {
-		shsurf = get_shell_surface(surface);
 		if (wl_list_empty(&shsurf->workspace_transform.link))
 			wl_list_insert(&shell->workspaces.anim_sticky_list,
 				       &shsurf->workspace_transform.link);
@@ -1341,13 +1347,14 @@ workspace_manager_move_surface(struct wl_client *client,
 	struct weston_surface *surface =
 		wl_resource_get_user_data(surface_resource);
 	struct weston_surface *main_surface;
-	struct weston_view *view;
+	struct shell_surface *shell_surface;
 
 	main_surface = weston_surface_get_main_surface(surface);
-	view = get_default_view(main_surface);
-	if (!view)
+	shell_surface = get_shell_surface(main_surface);
+	if (shell_surface == NULL)
 		return;
-	move_view_to_workspace(shell, view, workspace);
+
+	move_surface_to_workspace(shell, shell_surface, workspace);
 }
 
 static const struct workspace_manager_interface workspace_manager_implementation = {
-- 
1.8.3.1



More information about the wayland-devel mailing list