Thank you Olivier. Sorry for that.
An alternative solution would be to only ifdef out the
xwl_glamor_pixmap_get_wl_buffer call in xwl_present_flip and otherwise
return FALSE. But we then would needlessly still build the Present
support when compiling without glamor.
Reviewed-by: Roman Gilg
On Mon, Apr 16, 2018 at 9:39 AM, Olivier Fourdan wrote:
> Present support in Xwayland relies on glamor, make sure Xwayland can
> be built without glamor by moving references to Present code inside
> the conditional GLAMOR_HAS_GBM.
>
> Reported-by: Matt Turner
> Signed-off-by: Olivier Fourdan
> ---
> hw/xwayland/Makefile.am | 4 ++--
> hw/xwayland/meson.build | 3 +--
> hw/xwayland/xwayland.c | 10 +-
> hw/xwayland/xwayland.h | 7 ++-
> 4 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
> index 0291afee7..80d3a1f19 100644
> --- a/hw/xwayland/Makefile.am
> +++ b/hw/xwayland/Makefile.am
> @@ -11,7 +11,6 @@ Xwayland_CFLAGS = \
>
> Xwayland_SOURCES = \
> xwayland.c \
> - xwayland-present.c \
> xwayland-input.c\
> xwayland-cursor.c \
> xwayland-shm.c \
> @@ -35,7 +34,8 @@ Xwayland_built_sources =
>
> if GLAMOR_EGL
> Xwayland_SOURCES +=\
> - xwayland-glamor.c
> + xwayland-glamor.c \
> + xwayland-present.c
> if XV
> Xwayland_SOURCES +=\
> xwayland-glamor-xv.c
> diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
> index 69a5c819a..8d178825e 100644
> --- a/hw/xwayland/meson.build
> +++ b/hw/xwayland/meson.build
> @@ -1,6 +1,5 @@
> srcs = [
> 'xwayland.c',
> -'xwayland-present.c',
> 'xwayland-input.c',
> 'xwayland-cursor.c',
> 'xwayland-shm.c',
> @@ -53,7 +52,7 @@ srcs += code.process(dmabuf_xml)
>
> xwayland_glamor = []
> if gbm_dep.found()
> -srcs += 'xwayland-glamor.c'
> +srcs += [ 'xwayland-glamor.c', 'xwayland-present.c' ]
> if build_xv
> srcs += 'xwayland-glamor-xv.c'
> endif
> diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
> index dd074c341..44bbc3b18 100644
> --- a/hw/xwayland/xwayland.c
> +++ b/hw/xwayland/xwayland.c
> @@ -525,6 +525,7 @@ xwl_realize_window(WindowPtr window)
> wl_region_destroy(region);
> }
>
> +#ifdef GLAMOR_HAS_GBM
> if (xwl_screen->present) {
> xwl_window->present_crtc_fake = RRCrtcCreate(xwl_screen->screen,
> xwl_window);
> xwl_window->present_msc = 1;
> @@ -533,6 +534,7 @@ xwl_realize_window(WindowPtr window)
> xorg_list_init(_window->present_event_list);
> xorg_list_init(_window->present_release_queue);
> }
> +#endif
>
> wl_display_flush(xwl_screen->display);
>
> @@ -599,9 +601,11 @@ xwl_unrealize_window(WindowPtr window)
>
> compUnredirectWindow(serverClient, window, CompositeRedirectManual);
>
> +#ifdef GLAMOR_HAS_GBM
> if (xwl_screen->present)
> /* Always cleanup Present (Present might have been active on child
> window) */
> xwl_present_cleanup(window);
> +#endif
>
> screen->UnrealizeWindow = xwl_screen->UnrealizeWindow;
> ret = (*screen->UnrealizeWindow) (window);
> @@ -621,8 +625,10 @@ xwl_unrealize_window(WindowPtr window)
> if (xwl_window->frame_callback)
> wl_callback_destroy(xwl_window->frame_callback);
>
> +#ifdef GLAMOR_HAS_GBM
> if (xwl_window->present_crtc_fake)
> RRCrtcDestroy(xwl_window->present_crtc_fake);
> +#endif
>
> free(xwl_window);
> dixSetPrivate(>devPrivates, _window_private_key, NULL);
> @@ -709,9 +715,11 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
>
> xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
>_screen->damage_window_list,
> link_damage) {
> +#ifdef GLAMOR_HAS_GBM
> /* Present on the main surface. So don't commit here as well. */
> if (xwl_window->present_window)
> continue;
> +#endif
> /* If we're waiting on a frame callback from the server,
> * don't attach a new buffer. */
> if (xwl_window->frame_callback)
> @@ -1053,10 +1061,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char
> **argv)
> ErrorF("Failed to initialize glamor, falling back to sw\n");
> xwl_screen->glamor = 0;
> }
> -#endif
>
> if (xwl_screen->glamor && xwl_screen->rootless)
> xwl_screen->present = xwl_present_init(pScreen);
> +#endif
>
> if (!xwl_screen->glamor) {
> xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
> diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
> index