[PATCH weston 01/11] shell: Add helper functions for stacking top level surfaces
Jonas Ådahl
jadahl at gmail.com
Sat Jan 26 06:33:31 PST 2013
To keep track of what workspace a shell surface belongs to, use a helper
function for stacking shell surfaces that updates a workspace reference.
Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
src/shell.c | 56 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 13 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index dcbabf3..67cdf63 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -193,6 +193,7 @@ struct shell_surface {
struct ping_timer *ping_timer;
+ struct workspace *workspace;
struct weston_transform workspace_transform;
struct weston_output *fullscreen_output;
@@ -547,6 +548,25 @@ workspace_is_empty(struct workspace *ws)
return wl_list_empty(&ws->layer.surface_list);
}
+static void
+workspace_stack_surface(struct workspace *ws, struct shell_surface *shsurf)
+{
+ wl_list_insert(&ws->layer.surface_list,
+ &shsurf->surface->layer_link);
+ shsurf->workspace = ws;
+}
+
+static void
+workspace_restack_surface(struct workspace *ws, struct shell_surface *shsurf)
+{
+ struct weston_surface *surface = shsurf->surface;
+
+ wl_list_remove(&surface->layer_link);
+ workspace_stack_surface(ws, shsurf);
+ weston_surface_damage_below(surface);
+ weston_surface_damage(surface);
+}
+
static struct workspace *
get_workspace(struct desktop_shell *shell, unsigned int index)
{
@@ -848,19 +868,19 @@ move_surface_to_workspace(struct desktop_shell *shell,
{
struct workspace *from;
struct workspace *to;
+ struct shell_surface *shsurf = get_shell_surface(surface);
struct weston_seat *seat;
- if (workspace == shell->workspaces.current)
+ if (!shsurf || workspace == shell->workspaces.current)
return;
if (workspace >= shell->workspaces.num)
workspace = shell->workspaces.num - 1;
- from = get_current_workspace(shell);
+ from = shsurf->workspace;
to = get_workspace(shell, workspace);
- wl_list_remove(&surface->layer_link);
- wl_list_insert(&to->layer.surface_list, &surface->layer_link);
+ workspace_restack_surface(to, shsurf);
drop_focus_state(shell, from, surface);
wl_list_for_each(seat, &shell->compositor->seat_list, link)
@@ -888,11 +908,14 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
index == shell->workspaces.current)
return;
- from = get_current_workspace(shell);
+ shsurf = get_shell_surface(surface);
+ from = shsurf->workspace;
to = get_workspace(shell, index);
- wl_list_remove(&surface->layer_link);
- wl_list_insert(&to->layer.surface_list, &surface->layer_link);
+ if (get_current_workspace(shell) != from)
+ return;
+
+ workspace_restack_surface(to, shsurf);
replace_focus_state(shell, to, seat);
drop_focus_state(shell, from, surface);
@@ -1448,8 +1471,7 @@ shell_unset_fullscreen(struct shell_surface *shsurf)
}
ws = get_current_workspace(shsurf->shell);
- wl_list_remove(&shsurf->surface->layer_link);
- wl_list_insert(&ws->layer.surface_list, &shsurf->surface->layer_link);
+ workspace_restack_surface(ws, shsurf);
}
static int
@@ -2625,18 +2647,26 @@ lower_fullscreen_layer(struct desktop_shell *shell)
{
struct workspace *ws;
struct weston_surface *surface, *prev;
+ struct shell_surface *shsurf;
ws = get_current_workspace(shell);
wl_list_for_each_reverse_safe(surface, prev,
&shell->fullscreen_layer.surface_list,
- layer_link)
- weston_surface_restack(surface, &ws->layer.surface_list);
+ layer_link) {
+ shsurf = get_shell_surface(surface);
+ if (shsurf)
+ workspace_restack_surface(ws, shsurf);
+ else
+ weston_surface_restack(surface,
+ &ws->layer.surface_list);
+ }
}
static void
activate(struct desktop_shell *shell, struct weston_surface *es,
struct weston_seat *seat)
{
+ struct shell_surface *shsurf = get_shell_surface(es);
struct focus_state *state;
struct workspace *ws;
@@ -2659,7 +2689,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
break;
default:
ws = get_current_workspace(shell);
- weston_surface_restack(es, &ws->layer.surface_list);
+ workspace_restack_surface(ws, shsurf);
break;
}
}
@@ -2940,7 +2970,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
break;
default:
ws = get_current_workspace(shell);
- wl_list_insert(&ws->layer.surface_list, &surface->layer_link);
+ workspace_stack_surface(ws, shsurf);
break;
}
--
1.7.10.4
More information about the wayland-devel
mailing list