From a27b9d9707b0c5ccfd6aec3e5f335937c1796429 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 1 Jun 2022 10:35:29 +0200 Subject: [PATCH] wayland: Guard XWayland types Part-of: --- src/core/display.c | 2 +- src/tests/meta-test-utils.c | 7 ++++++- src/wayland/meta-wayland-pointer-constraints.c | 2 ++ src/wayland/meta-wayland-private.h | 2 ++ src/wayland/meta-wayland.c | 4 ++++ src/wayland/meta-wayland.h | 4 ++++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index b062daa11..4b7467bed 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -934,12 +934,12 @@ meta_display_new (MetaContext *context, #ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) { +#ifdef HAVE_XWAYLAND MetaWaylandCompositor *wayland_compositor = wayland_compositor_from_display (display); meta_wayland_compositor_init_display (wayland_compositor, display); -#ifdef HAVE_XWAYLAND MetaX11DisplayPolicy x11_display_policy; x11_display_policy = meta_context_get_x11_display_policy (context); diff --git a/src/tests/meta-test-utils.c b/src/tests/meta-test-utils.c index 416dc0b64..2b9a791bd 100644 --- a/src/tests/meta-test-utils.c +++ b/src/tests/meta-test-utils.c @@ -613,7 +613,9 @@ meta_test_client_new (MetaContext *context, ClientProcessHandler *process_handler; MetaWaylandCompositor *compositor; const char *wayland_display_name; +#ifdef HAVE_XWAYLAND const char *x11_display_name; +#endif launcher = g_subprocess_launcher_new ((G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE)); @@ -621,8 +623,9 @@ meta_test_client_new (MetaContext *context, g_assert (meta_is_wayland_compositor ()); compositor = meta_context_get_wayland_compositor (context); wayland_display_name = meta_wayland_get_wayland_display_name (compositor); +#ifdef HAVE_XWAYLAND x11_display_name = meta_wayland_get_public_xwayland_display_name (compositor); - +#endif if (wayland_display_name) { g_subprocess_launcher_setenv (launcher, @@ -630,12 +633,14 @@ meta_test_client_new (MetaContext *context, TRUE); } +#ifdef HAVE_XWAYLAND if (x11_display_name) { g_subprocess_launcher_setenv (launcher, "DISPLAY", x11_display_name, TRUE); } +#endif subprocess = g_subprocess_launcher_spawn (launcher, error, diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 40dd2095e..9389dd6f8 100644 --- a/src/wayland/meta-wayland-pointer-constraints.c +++ b/src/wayland/meta-wayland-pointer-constraints.c @@ -474,8 +474,10 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint) * associate the X11 Window with the wl_surface. * For subsurfaces the window of the ancestor might be gone already. */ +#ifdef HAVE_XWAYLAND g_warn_if_fail (meta_xwayland_is_xwayland_surface (constraint->surface) || META_IS_WAYLAND_SUBSURFACE (constraint->surface->role)); +#endif return FALSE; } #endif diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index a6bf9cc0a..2a28ccd61 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -92,7 +92,9 @@ struct _MetaWaylandCompositor GHashTable *outputs; GList *frame_callback_surfaces; +#ifdef HAVE_XWAYLAND MetaXWaylandManager xwayland_manager; +#endif MetaWaylandSeat *seat; MetaWaylandTabletManager *tablet_manager; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 83f86bfa9..c83504137 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -894,6 +894,7 @@ meta_wayland_get_wayland_display_name (MetaWaylandCompositor *compositor) return compositor->display_name; } +#ifdef HAVE_XWAYLAND const char * meta_wayland_get_public_xwayland_display_name (MetaWaylandCompositor *compositor) { @@ -905,6 +906,7 @@ meta_wayland_get_private_xwayland_display_name (MetaWaylandCompositor *composito { return compositor->xwayland_manager.private_connection.name; } +#endif /* HAVE_XWAYLAND */ void meta_wayland_compositor_restore_shortcuts (MetaWaylandCompositor *compositor, @@ -1004,7 +1006,9 @@ meta_wayland_compositor_notify_surface_id (MetaWaylandCompositor *compositor, GINT_TO_POINTER (id)); if (window) { +#ifdef HAVE_XWAYLAND meta_xwayland_associate_window_with_surface (window, surface); +#endif meta_wayland_compositor_remove_surface_association (compositor, id); } } diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h index e0e5c9251..f842d6f18 100644 --- a/src/wayland/meta-wayland.h +++ b/src/wayland/meta-wayland.h @@ -72,10 +72,12 @@ GQueue *meta_wayland_compositor_get_committed_transactions (Meta META_EXPORT_TEST const char *meta_wayland_get_wayland_display_name (MetaWaylandCompositor *compositor); +#ifdef HAVE_XWAYLAND META_EXPORT_TEST const char *meta_wayland_get_public_xwayland_display_name (MetaWaylandCompositor *compositor); const char *meta_wayland_get_private_xwayland_display_name (MetaWaylandCompositor *compositor); +#endif void meta_wayland_compositor_restore_shortcuts (MetaWaylandCompositor *compositor, ClutterInputDevice *source); @@ -94,8 +96,10 @@ void meta_wayland_compositor_notify_surface_id (MetaWaylandCo int id, MetaWaylandSurface *surface); +#ifdef HAVE_XWAYLAND META_EXPORT_TEST MetaXWaylandManager * meta_wayland_compositor_get_xwayland_manager (MetaWaylandCompositor *compositor); +#endif #endif