[PATCH weston 3/4] compositor: Add a visibility switch to weston_layers

Kristian Høgsberg hoegsberg at gmail.com
Wed Feb 5 17:35:39 PST 2014


On Wed, Jan 29, 2014 at 06:47:53PM +0200, Ander Conselvan de Oliveira wrote:
> Different parts of the shell, such as the workspace implementation,
> rely on making layers invisible to hide surfaces without discarding
> the order in which they appear. However, the layers are made
> invisible by removing them from the compositor's layers list.
> 
> Instead, add the function weston_layer_show(), which can control the
> visibility of a layer, while maintaining it in the layers list. That
> way, it is not necessary to remember the order between layers when
> making them visible again.
> 
> This also has the side effect of causing views in a hidden workspace
> and in an output that has been moved (due to another being unplugged)
> to be moved correctly.

I'd like to see if we could make it even simpler than this; just have a
lock screen layer on top of all layers (except cursor) and then put move
the background image there and the lockscreen surface.  Leave everything in
place and don't switch visibilty, just rely on westons opaque surface
optimizations to avoid repainting and make sure to assign all seats
kb focus to the lock surface.

Kristian

> ---
>  desktop-shell/input-panel.c |  6 ++---
>  desktop-shell/shell.c       | 62 ++++++++++++++++++++-------------------------
>  src/compositor.c            | 11 ++++++++
>  src/compositor.h            |  4 +++
>  4 files changed, 44 insertions(+), 39 deletions(-)
> 
> diff --git a/desktop-shell/input-panel.c b/desktop-shell/input-panel.c
> index c08a403..5f0025b 100644
> --- a/desktop-shell/input-panel.c
> +++ b/desktop-shell/input-panel.c
> @@ -63,8 +63,7 @@ show_input_panels(struct wl_listener *listener, void *data)
>  	shell->showing_input_panels = true;
>  
>  	if (!shell->locked)
> -		wl_list_insert(&shell->panel_layer.link,
> -			       &shell->input_panel_layer.link);
> +		weston_layer_show(&shell->input_panel_layer, 1);
>  
>  	wl_list_for_each_safe(ipsurf, next,
>  			      &shell->input_panel.surfaces, link) {
> @@ -93,8 +92,7 @@ hide_input_panels(struct wl_listener *listener, void *data)
>  
>  	shell->showing_input_panels = false;
>  
> -	if (!shell->locked)
> -		wl_list_remove(&shell->input_panel_layer.link);
> +	weston_layer_show(&shell->input_panel_layer, 0);
>  
>  	wl_list_for_each_safe(view, next,
>  			      &shell->input_panel_layer.view_list, layer_link)
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index ae06382..888e33b 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -819,13 +819,13 @@ seat_destroyed(struct wl_listener *listener, void *data)
>  }
>  
>  static struct workspace *
> -workspace_create(void)
> +workspace_create(struct desktop_shell *shell)
>  {
>  	struct workspace *ws = malloc(sizeof *ws);
>  	if (ws == NULL)
>  		return NULL;
>  
> -	weston_layer_init(&ws->layer, NULL);
> +	weston_layer_init(&ws->layer, &shell->input_panel_layer.link);
>  
>  	wl_list_init(&ws->focus_list);
>  	wl_list_init(&ws->seat_destroyed_listener.link);
> @@ -864,7 +864,7 @@ activate_workspace(struct desktop_shell *shell, unsigned int index)
>  	struct workspace *ws;
>  
>  	ws = get_workspace(shell, index);
> -	wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
> +	weston_layer_show(&ws->layer, 1);
>  
>  	shell->workspaces.current = index;
>  }
> @@ -994,7 +994,7 @@ finish_workspace_change_animation(struct desktop_shell *shell,
>  	workspace_deactivate_transforms(to);
>  	shell->workspaces.anim_to = NULL;
>  
> -	wl_list_remove(&shell->workspaces.anim_from->layer.link);
> +	weston_layer_show(&shell->workspaces.anim_from->layer, 0);
>  }
>  
>  static void
> @@ -1076,7 +1076,7 @@ animate_workspace_change(struct desktop_shell *shell,
>  	wl_list_insert(&output->animation_list,
>  		       &shell->workspaces.animation.link);
>  
> -	wl_list_insert(from->layer.link.prev, &to->layer.link);
> +	weston_layer_show(&to->layer, 1);
>  
>  	workspace_translate_in(to, 0);
>  
> @@ -1090,8 +1090,8 @@ update_workspace(struct desktop_shell *shell, unsigned int index,
>  		 struct workspace *from, struct workspace *to)
>  {
>  	shell->workspaces.current = index;
> -	wl_list_insert(&from->layer.link, &to->layer.link);
> -	wl_list_remove(&from->layer.link);
> +	weston_layer_show(&to->layer, 1);
> +	weston_layer_show(&from->layer, 0);
>  }
>  
>  static void
> @@ -1241,9 +1241,6 @@ take_surface_to_workspace_by_seat(struct desktop_shell *shell,
>  
>  	if (shell->workspaces.anim_from == to &&
>  	    shell->workspaces.anim_to == from) {
> -		wl_list_remove(&to->layer.link);
> -		wl_list_insert(from->layer.link.prev, &to->layer.link);
> -
>  		reverse_workspace_change_animation(shell, index, from, to);
>  		broadcast_current_workspace_state(shell);
>  
> @@ -3732,19 +3729,15 @@ resume_desktop(struct desktop_shell *shell)
>  
>  	terminate_screensaver(shell);
>  
> -	wl_list_remove(&shell->lock_layer.link);
> -	wl_list_insert(&shell->compositor->cursor_layer.link,
> -		       &shell->fullscreen_layer.link);
> -	wl_list_insert(&shell->fullscreen_layer.link,
> -		       &shell->panel_layer.link);
> -	if (shell->showing_input_panels) {
> -		wl_list_insert(&shell->panel_layer.link,
> -			       &shell->input_panel_layer.link);
> -		wl_list_insert(&shell->input_panel_layer.link,
> -			       &ws->layer.link);
> -	} else {
> -		wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
> -	}
> +	weston_layer_show(&shell->lock_layer, 0);
> +
> +	weston_layer_show(&shell->fullscreen_layer, 1);
> +	weston_layer_show(&shell->panel_layer, 1);
> +
> +	if (shell->showing_input_panels)
> +		weston_layer_show(&shell->input_panel_layer, 1);
> +
> +	weston_layer_show(&ws->layer, 1);
>  
>  	restore_focus_state(shell, get_current_workspace(shell));
>  
> @@ -4334,13 +4327,12 @@ lock(struct desktop_shell *shell)
>  	 * toplevel layers.  This way nothing else can show or receive
>  	 * input events while we are locked. */
>  
> -	wl_list_remove(&shell->panel_layer.link);
> -	wl_list_remove(&shell->fullscreen_layer.link);
> -	if (shell->showing_input_panels)
> -		wl_list_remove(&shell->input_panel_layer.link);
> -	wl_list_remove(&ws->layer.link);
> -	wl_list_insert(&shell->compositor->cursor_layer.link,
> -		       &shell->lock_layer.link);
> +	weston_layer_show(&shell->panel_layer, 0);
> +	weston_layer_show(&shell->input_panel_layer, 0);
> +	weston_layer_show(&shell->fullscreen_layer, 0);
> +	weston_layer_show(&ws->layer, 0);
> +
> +	weston_layer_show(&shell->lock_layer, 1);
>  
>  	launch_screensaver(shell);
>  
> @@ -5679,11 +5671,11 @@ module_init(struct weston_compositor *ec,
>  	ec->shell_interface.resize = surface_resize;
>  	ec->shell_interface.set_title = set_title;
>  
> -	weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);
> +	weston_layer_init(&shell->lock_layer, &ec->cursor_layer.link);
> +	weston_layer_init(&shell->fullscreen_layer, &shell->lock_layer.link);
>  	weston_layer_init(&shell->panel_layer, &shell->fullscreen_layer.link);
> -	weston_layer_init(&shell->background_layer, &shell->panel_layer.link);
> -	weston_layer_init(&shell->lock_layer, NULL);
> -	weston_layer_init(&shell->input_panel_layer, NULL);
> +	weston_layer_init(&shell->input_panel_layer, &shell->panel_layer.link);
> +	weston_layer_init(&shell->background_layer, &shell->input_panel_layer.link);
>  
>  	wl_array_init(&shell->workspaces.array);
>  	wl_list_init(&shell->workspaces.client_list);
> @@ -5701,7 +5693,7 @@ module_init(struct weston_compositor *ec,
>  		if (pws == NULL)
>  			return -1;
>  
> -		*pws = workspace_create();
> +		*pws = workspace_create(shell);
>  		if (*pws == NULL)
>  			return -1;
>  	}
> diff --git a/src/compositor.c b/src/compositor.c
> index ff7ee7b..6ac17e6 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -1769,6 +1769,9 @@ weston_compositor_build_view_list(struct weston_compositor *compositor)
>  
>  	wl_list_init(&compositor->view_list);
>  	wl_list_for_each(layer, &compositor->layer_list, link) {
> +		if (layer->hidden)
> +			continue;
> +
>  		wl_list_for_each(view, &layer->view_list, layer_link) {
>  			view_list_add(compositor, view);
>  		}
> @@ -1896,12 +1899,20 @@ idle_repaint(void *data)
>  WL_EXPORT void
>  weston_layer_init(struct weston_layer *layer, struct wl_list *below)
>  {
> +	layer->hidden = 0;
> +
>  	wl_list_init(&layer->view_list);
>  	if (below != NULL)
>  		wl_list_insert(below, &layer->link);
>  }
>  
>  WL_EXPORT void
> +weston_layer_show(struct weston_layer *layer, int show)
> +{
> +	layer->hidden = !show;
> +}
> +
> +WL_EXPORT void
>  weston_output_schedule_repaint(struct weston_output *output)
>  {
>  	struct weston_compositor *compositor = output->compositor;
> diff --git a/src/compositor.h b/src/compositor.h
> index c8e38fb..e185f94 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -525,6 +525,7 @@ enum {
>  struct weston_layer {
>  	struct wl_list view_list;
>  	struct wl_list link;
> +	int hidden;
>  };
>  
>  struct weston_plane {
> @@ -1005,6 +1006,9 @@ void
>  weston_layer_init(struct weston_layer *layer, struct wl_list *below);
>  
>  void
> +weston_layer_show(struct weston_layer *layer, int show);
> +
> +void
>  weston_plane_init(struct weston_plane *plane,
>  			struct weston_compositor *ec,
>  			int32_t x, int32_t y);
> -- 
> 1.8.1.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list