shell: Refactor workspace code to operate on shsurfs rather than views

This is needed for the work to refactor window stacking and ordering, as
window order operates on shsurfs, not views.
dev
Philip Withnall 11 years ago committed by Kristian Høgsberg
parent 352e7ed527
commit 659163d25c
  1. 25
      src/shell.c

@ -1235,20 +1235,25 @@ workspace_has_only(struct workspace *ws, struct weston_surface *surface)
} }
static void static void
move_view_to_workspace(struct desktop_shell *shell, move_surface_to_workspace(struct desktop_shell *shell,
struct weston_view *view, struct shell_surface *shsurf,
uint32_t workspace) uint32_t workspace)
{ {
struct workspace *from; struct workspace *from;
struct workspace *to; struct workspace *to;
struct weston_seat *seat; struct weston_seat *seat;
struct weston_surface *focus; struct weston_surface *focus;
struct weston_view *view;
assert(weston_surface_get_main_surface(view->surface) == view->surface);
if (workspace == shell->workspaces.current) if (workspace == shell->workspaces.current)
return; 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) if (workspace >= shell->workspaces.num)
workspace = shell->workspaces.num - 1; workspace = shell->workspaces.num - 1;
@ -1296,6 +1301,8 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
wl_list_remove(&view->layer_link); wl_list_remove(&view->layer_link);
wl_list_insert(&to->layer.view_list, &view->layer_link); wl_list_insert(&to->layer.view_list, &view->layer_link);
shsurf = get_shell_surface(surface);
replace_focus_state(shell, to, seat); replace_focus_state(shell, to, seat);
drop_focus_state(shell, from, surface); drop_focus_state(shell, from, surface);
@ -1319,7 +1326,6 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
workspace_has_only(to, surface)) workspace_has_only(to, surface))
update_workspace(shell, index, from, to); update_workspace(shell, index, from, to);
else { else {
shsurf = get_shell_surface(surface);
if (wl_list_empty(&shsurf->workspace_transform.link)) if (wl_list_empty(&shsurf->workspace_transform.link))
wl_list_insert(&shell->workspaces.anim_sticky_list, wl_list_insert(&shell->workspaces.anim_sticky_list,
&shsurf->workspace_transform.link); &shsurf->workspace_transform.link);
@ -1344,13 +1350,14 @@ workspace_manager_move_surface(struct wl_client *client,
struct weston_surface *surface = struct weston_surface *surface =
wl_resource_get_user_data(surface_resource); wl_resource_get_user_data(surface_resource);
struct weston_surface *main_surface; struct weston_surface *main_surface;
struct weston_view *view; struct shell_surface *shell_surface;
main_surface = weston_surface_get_main_surface(surface); main_surface = weston_surface_get_main_surface(surface);
view = get_default_view(main_surface); shell_surface = get_shell_surface(main_surface);
if (!view) if (shell_surface == NULL)
return; 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 = { static const struct workspace_manager_interface workspace_manager_implementation = {

Loading…
Cancel
Save