[mutter/bilelmoussaoui/x11-build-guards: 27/28] wayland: Guard XWayland types




commit 72e62579faaf6af46f91b1dc1f63706044753176
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Wed Jun 1 10:35:29 2022 +0200

    wayland: Guard XWayland types

 src/core/display.c                             |  3 ++-
 src/wayland/meta-wayland-pointer-constraints.c | 11 ++++++++++-
 src/wayland/meta-wayland.c                     | 12 ++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 77d06bb715..79abc9b848 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -942,12 +942,13 @@ meta_display_new (MetaContext  *context,
 #ifdef HAVE_WAYLAND
   if (meta_is_wayland_compositor ())
     {
+
+#ifdef HAVE_XWAYLAND
       MetaWaylandCompositor *wayland_compositor =
         meta_wayland_compositor_get_default ();
 
       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/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 965b95ddad..df460f9bfc 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -155,6 +155,7 @@ connect_window (MetaWaylandSurfacePointerConstraintsData *data,
                       G_CALLBACK (window_raised), NULL);
 }
 
+#ifdef HAVE_XWAYLAND
 static void
 window_associated (MetaWaylandSurfaceRole                   *surface_role,
                    MetaWaylandSurfacePointerConstraintsData *data)
@@ -168,6 +169,7 @@ window_associated (MetaWaylandSurfaceRole                   *surface_role,
 
   meta_wayland_pointer_constraint_maybe_enable_for_window (window);
 }
+#endif
 
 static MetaWaylandSurfacePointerConstraintsData *
 surface_constraint_data_new (MetaWaylandSurface *surface)
@@ -184,6 +186,7 @@ surface_constraint_data_new (MetaWaylandSurface *surface)
     {
       connect_window (data, window);
     }
+#ifdef HAVE_XWAYLAND
   else if (meta_xwayland_is_xwayland_surface (surface))
     {
       data->window_associated_handler_id =
@@ -191,6 +194,7 @@ surface_constraint_data_new (MetaWaylandSurface *surface)
                           G_CALLBACK (window_associated),
                           data);
     }
+#endif
   else
     {
       /* TODO: Support constraints on non-toplevel windows, such as subsurfaces.
@@ -464,7 +468,9 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
        * Locks from Xwayland may come before we have had the opportunity to
        * associate the X11 Window with the wl_surface.
        */
+#ifdef HAVE_XWAYLAND
       g_warn_if_fail (meta_xwayland_is_xwayland_surface (constraint->surface));
+#endif
       return FALSE;
     }
 
@@ -474,6 +480,7 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
   if (constraint->seat->pointer->focus_surface != constraint->surface)
     return FALSE;
 
+#ifdef HAVE_XWAYLAND
   if (meta_xwayland_is_xwayland_surface (constraint->surface))
     {
       MetaDisplay *display = meta_get_display ();
@@ -497,6 +504,7 @@ should_constraint_be_enabled (MetaWaylandPointerConstraint *constraint)
         return FALSE;
     }
   else
+#endif
     {
       if (!meta_window_appears_focused (window))
         return FALSE;
@@ -618,8 +626,9 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
       MetaFrame *frame = window->frame;
       int actual_width, actual_height;
 
+#ifdef HAVE_XWAYLAND
       g_assert (meta_xwayland_is_xwayland_surface (constraint->surface));
-
+#endif
       actual_width = window->buffer_rect.width - (frame->child_x +
                                                   frame->right_width);
       actual_height = window->buffer_rect.height - (frame->child_y +
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 677300d907..43d21565c4 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -413,7 +413,9 @@ void
 meta_wayland_compositor_init_display (MetaWaylandCompositor *compositor,
                                       MetaDisplay           *display)
 {
+#ifdef HAVE_XWAYLAND
   meta_xwayland_init_display (&compositor->xwayland_manager, display);
+#endif
 }
 
 static void meta_wayland_log_func (const char *, va_list) G_GNUC_PRINTF (1, 0);
@@ -430,12 +432,14 @@ meta_wayland_log_func (const char *fmt,
 void
 meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor)
 {
+#ifdef HAVE_XWAYLAND
   MetaX11DisplayPolicy x11_display_policy;
 
   x11_display_policy =
     meta_context_get_x11_display_policy (compositor->context);
   if (x11_display_policy != META_X11_DISPLAY_POLICY_DISABLED)
     meta_xwayland_shutdown (&compositor->xwayland_manager);
+#endif
 
   if (compositor->wayland_display)
     wl_display_destroy_clients (compositor->wayland_display);
@@ -477,6 +481,7 @@ meta_wayland_compositor_class_init (MetaWaylandCompositorClass *klass)
   object_class->finalize = meta_wayland_compositor_finalize;
 }
 
+#ifdef HAVE_XWAYLAND
 static bool
 meta_xwayland_global_filter (const struct wl_client *client,
                              const struct wl_global *global,
@@ -493,6 +498,7 @@ meta_xwayland_global_filter (const struct wl_client *client,
   /* All others are visible to all clients */
   return true;
 }
+#endif
 
 void
 meta_wayland_override_display_name (const char *display_name)
@@ -622,10 +628,12 @@ meta_wayland_compositor_new (MetaContext *context)
   meta_wayland_activation_init (compositor);
 
   /* Xwayland specific protocol, needs to be filtered out for all other clients */
+#ifdef HAVE_XWAYLAND
   if (meta_xwayland_grab_keyboard_init (compositor))
     wl_display_set_global_filter (compositor->wayland_display,
                                   meta_xwayland_global_filter,
                                   compositor);
+#endif
 
 #ifdef HAVE_WAYLAND_EGLSTREAM
   {
@@ -650,6 +658,7 @@ meta_wayland_compositor_new (MetaContext *context)
 
   x11_display_policy =
     meta_context_get_x11_display_policy (compositor->context);
+#ifdef HAVE_XWAYLAND
   if (x11_display_policy != META_X11_DISPLAY_POLICY_DISABLED)
     {
       g_autoptr (GError) error = NULL;
@@ -660,6 +669,7 @@ meta_wayland_compositor_new (MetaContext *context)
                                &error))
         g_error ("Failed to start X Wayland: %s", error->message);
     }
+#endif
 
   if (_display_name_override)
     {
@@ -806,7 +816,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);
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]