[PATCH v2 weston] xdg-shell: handle clients launched in fullscreen

Pekka Paalanen ppaalanen at gmail.com
Fri Sep 5 02:12:00 PDT 2014


On Tue,  2 Sep 2014 11:35:12 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> When client is lauched in fullscreen, it is placed on the
> first output, because it is not mapped and
> shell_surface_set_output() therefore sets default output.
> 
> Since we have no better way how to position newly created windows,
> (http://lists.freedesktop.org/archives/wayland-devel/2014-May/thread.html#14568)
> set the output to the one that has currently focus. Priority has
> the touch focus, then pointer and then keyboard focus.
> 
> This fixes bug
> https://bugs.freedesktop.org/show_bug.cgi?id=69780
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  desktop-shell/shell.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 9c0e721..f192b90 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -3584,6 +3584,32 @@ 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,
> @@ -3600,6 +3626,13 @@ xdg_surface_set_fullscreen(struct wl_client *client,
>  	else
>  		output = NULL;
>  
> +	/* handle clients launching in fullscreen */
> +	if (output == NULL && !weston_surface_is_mapped(shsurf->surface)) {
> +		/* Set the output to the one that has focus currently. */
> +		assert(shsurf->surface);
> +		output = get_focused_output(shsurf->surface->compositor);
> +	}
> +
>  	shell_surface_set_output(shsurf, output);
>  	shsurf->fullscreen_output = shsurf->output;
>  

I quickly tested this on X11-backend with two outputs
and ./weston-simple-egl -f, and it seems to work well enough for now.

Pushed.


Thanks,
pq


More information about the wayland-devel mailing list