[PATCH] xdg-shell: update shsurf->output when maximizing

Pekka Paalanen ppaalanen at gmail.com
Wed Sep 10 06:35:17 PDT 2014


On Mon,  8 Sep 2014 12:34:20 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> shsurf->output is the output that user expects the shell surface
> is on. When maximizing, we don't have any explicit setting of the output
> like in the case of fullscreening, so set the output to the one that
> the surface is currently on. In the case that the surface is not mapped yet,
> (if it ever happens) use the same heuristics as for fullscreening.
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  desktop-shell/shell.c | 60 +++++++++++++++++++++++++++++----------------------
>  1 file changed, 34 insertions(+), 26 deletions(-)
> 
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 234849a..2b7b247 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -3541,6 +3541,32 @@ get_primary_view(void *shell, struct shell_surface *shsurf)
>  	return shsurf->view;
>  }
>  
> +static struct weston_output *
> +get_focused_output(struct weston_compositor *compositor)
> +{
> +	struct weston_seat *seat;
> +	struct weston_output *output = NULL;
> +
> +	wl_list_for_each(seat, &compositor->seat_list, link) {
> +		/* Priority has touch focus, then pointer and
> +		 * then keyboard focus. We should probably have
> +		 * three for loops and check frist for touch,
> +		 * then for pointer, etc. but unless somebody has some
> +		 * objections, I think this is sufficient. */
> +		if (seat->touch && seat->touch->focus)
> +			output = seat->touch->focus->output;
> +		else if (seat->pointer && seat->pointer->focus)
> +			output = seat->pointer->focus->output;
> +		else if (seat->keyboard && seat->keyboard->focus)
> +			output = seat->keyboard->focus->output;
> +
> +		if (output)
> +			break;
> +	}
> +
> +	return output;
> +}
> +
>  static void
>  shell_get_shell_surface(struct wl_client *client,
>  			struct wl_resource *resource,
> @@ -3696,9 +3722,17 @@ xdg_surface_set_maximized(struct wl_client *client,
>  			  struct wl_resource *resource)
>  {
>  	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
> +	struct weston_output *output;
>  
>  	shsurf->state_requested = true;
>  	shsurf->requested_state.maximized = true;
> +
> +	if (!weston_surface_is_mapped(shsurf->surface))
> +		output = get_focused_output(shsurf->surface->compositor);
> +	else
> +		output = shsurf->surface->output;
> +
> +	shell_surface_set_output(shsurf, output);

Comparing this to the code in shell_surface_set_output(), I get the
feeling, that we should simply do shell_surface_set_output(shsurf,
NULL) here, and have shell_surface_set_output() call
get_focused_output() instead of get_default_output().

In fact, I believe we should just replace all uses of
get_default_output() with get_focused_output(). Get_default_output was
just a quick hack when we needed whatever output to put a surface on.

But that's all for 1.7 cycle, and also sorting out the is_mapped fiasco.

>   	send_configure_for_surface(shsurf);
>  }
>  
> @@ -3713,32 +3747,6 @@ xdg_surface_unset_maximized(struct wl_client *client,
>  	send_configure_for_surface(shsurf);
>  }
>  
> -static struct weston_output *
> -get_focused_output(struct weston_compositor *compositor)
> -{
> -	struct weston_seat *seat;
> -	struct weston_output *output = NULL;
> -
> -	wl_list_for_each(seat, &compositor->seat_list, link) {
> -		/* Priority has touch focus, then pointer and
> -		 * then keyboard focus. We should probably have
> -		 * three for loops and check frist for touch,
> -		 * then for pointer, etc. but unless somebody has some
> -		 * objections, I think this is sufficient. */
> -		if (seat->touch && seat->touch->focus)
> -			output = seat->touch->focus->output;
> -		else if (seat->pointer && seat->pointer->focus)
> -			output = seat->pointer->focus->output;
> -		else if (seat->keyboard && seat->keyboard->focus)
> -			output = seat->keyboard->focus->output;
> -
> -		if (output)
> -			break;
> -	}
> -
> -	return output;
> -}
> -
>  static void
>  xdg_surface_set_fullscreen(struct wl_client *client,
>  			   struct wl_resource *resource,

I amended the commit message a bit, since it wasn't obvious what
difference this patch makes.

Pushed.


Thanks,
pq


More information about the wayland-devel mailing list