[Cogl] [PATCH 1/2] wayland: Don't set the surface to toplevel until it is shown

Robert Bragg robert at sixbynine.org
Tue May 28 04:58:15 PDT 2013


It seems like we should be adding some documentation to explain this
behaviour somewhere, though I'm not exactly sure where. Maybe we could
even add a wayland specific note to cogl_onscreen_show()?

Apart from that then I think this looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

If you we can't find a good place to document this for now then we can
just go ahead and land the patch and we'll hopefully think about a way
to document it later.

thanks,
- Robert

On Fri, May 17, 2013 at 3:57 PM, Neil Roberts <neil at linux.intel.com> wrote:
> If we delay setting the surface to toplevel until it is shown then
> that gives the application an opportunity to avoid calling show so
> that it can set its own surface type.
> ---
>  cogl/winsys/cogl-winsys-egl-wayland.c | 40 +++++++++++++++++++++++++++++------
>  1 file changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
> index fe8b938..334ec1b 100644
> --- a/cogl/winsys/cogl-winsys-egl-wayland.c
> +++ b/cogl/winsys/cogl-winsys-egl-wayland.c
> @@ -74,6 +74,8 @@ typedef struct _CoglOnscreenWayland
>    int pending_dx;
>    int pending_dy;
>    CoglBool has_pending;
> +
> +  CoglBool shell_surface_type_set;
>  } CoglOnscreenWayland;
>
>  static void
> @@ -373,12 +375,9 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
>                              NULL);
>
>    if (!onscreen->foreign_surface)
> -    {
> -      wayland_onscreen->wayland_shell_surface =
> -        wl_shell_get_shell_surface (wayland_renderer->wayland_shell,
> -                                    wayland_onscreen->wayland_surface);
> -      wl_shell_surface_set_toplevel (wayland_onscreen->wayland_shell_surface);
> -    }
> +    wayland_onscreen->wayland_shell_surface =
> +      wl_shell_get_shell_surface (wayland_renderer->wayland_shell,
> +                                  wayland_onscreen->wayland_surface);
>
>    return TRUE;
>  }
> @@ -456,6 +455,32 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
>    wl_display_flush (wayland_renderer->wayland_display);
>  }
>
> +static void
> +_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
> +                                      CoglBool visibility)
> +{
> +  CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
> +  CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
> +
> +  /* The first time the onscreen is shown we will set it to toplevel
> +   * so that it will appear on the screen. If the surface is foreign
> +   * then we won't have the shell surface and we'll just let the
> +   * application deal with setting the surface type. */
> +  if (visibility &&
> +      wayland_onscreen->wayland_shell_surface &&
> +      !wayland_onscreen->shell_surface_type_set)
> +    {
> +      wl_shell_surface_set_toplevel (wayland_onscreen->wayland_shell_surface);
> +      wayland_onscreen->shell_surface_type_set = TRUE;
> +    }
> +
> +  /* FIXME: We should also do something here to hide the surface when
> +   * visilibity == FALSE. It sounds like there are currently ongoing
> +   * discussions about adding support for hiding surfaces in the
> +   * Wayland protocol so we might as well wait until then to add that
> +   * here. */
> +}
> +
>  void
>  cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer,
>                                             struct wl_display *display)
> @@ -653,6 +678,9 @@ _cogl_winsys_egl_wayland_get_vtable (void)
>        vtable.onscreen_swap_buffers_with_damage =
>          _cogl_winsys_onscreen_swap_buffers_with_damage;
>
> +      vtable.onscreen_set_visibility =
> +        _cogl_winsys_onscreen_set_visibility;
> +
>        vtable_inited = TRUE;
>      }
>
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list