[mutter/bilelmoussaoui/x11-build-guards-2: 5/10] context/main: Guard X11/Xwayland types




commit 9479576bf1611b8df90004d0b48819cfa1c72d88
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Fri Jun 17 10:54:08 2022 +0200

    context/main: Guard X11/Xwayland types
    
    A continuation of
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2429
    that disables the code paths specific to x11/xwayland

 src/core/meta-context-main.c | 63 ++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 17 deletions(-)
---
diff --git a/src/core/meta-context-main.c b/src/core/meta-context-main.c
index 5baa7c9f5c..aa46d0079d 100644
--- a/src/core/meta-context-main.c
+++ b/src/core/meta-context-main.c
@@ -33,21 +33,25 @@
 
 #include "backends/meta-monitor-manager-private.h"
 #include "backends/meta-virtual-monitor.h"
-#include "backends/x11/cm/meta-backend-x11-cm.h"
 #include "meta/meta-backend.h"
 #include "wayland/meta-wayland.h"
+
+#ifdef HAVE_X11
+#include "backends/x11/cm/meta-backend-x11-cm.h"
 #include "x11/session.h"
+#endif
 
 #ifdef HAVE_NATIVE_BACKEND
 #include "backends/native/meta-backend-native.h"
 #endif
 
-#ifdef HAVE_WAYLAND
+#ifdef HAVE_XWAYLAND
 #include "backends/x11/nested/meta-backend-x11-nested.h"
 #endif
 
 typedef struct _MetaContextMainOptions
 {
+#ifdef HAVE_X11
   struct {
     char *display_name;
     gboolean replace;
@@ -59,10 +63,13 @@ typedef struct _MetaContextMainOptions
     char *client_id;
     gboolean disable;
   } sm;
+#endif
 #ifdef HAVE_WAYLAND
   gboolean wayland;
+#ifdef HAVE_XWAYLAND
   gboolean nested;
   gboolean no_x11;
+#endif
   char *wayland_display;
 #endif
 #ifdef HAVE_NATIVE_BACKEND
@@ -92,7 +99,7 @@ static gboolean
 check_configuration (MetaContextMain  *context_main,
                      GError          **error)
 {
-#ifdef HAVE_WAYLAND
+#if defined(HAVE_XWAYLAND) && defined(HAVE_X11)
   if (context_main->options.x11.force && context_main->options.no_x11)
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
@@ -111,9 +118,9 @@ check_configuration (MetaContextMain  *context_main,
                    "Can't run in X11 mode nested");
       return FALSE;
     }
-#endif /* HAVE_WAYLAND */
+#endif /* defined(HAVE_XWAYLAND) && defined(HAVE_X11) */
 
-#ifdef HAVE_NATIVE_BACKEND
+#if defined(HAVE_NATIVE_BACKEND) && defined(HAVE_X11)
   if (context_main->options.x11.force && context_main->options.display_server)
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
@@ -134,8 +141,9 @@ check_configuration (MetaContextMain  *context_main,
                    "Can't run in display server mode headlessly");
       return FALSE;
     }
-#endif /* HAVE_NATIVE_BACKEND */
+#endif /* defined(HAVE_NATIVE_BACKEND) && defined(HAVE_X11) */
 
+#ifdef HAVE_X11
   if (context_main->options.sm.save_file &&
       context_main->options.sm.client_id)
     {
@@ -143,6 +151,7 @@ check_configuration (MetaContextMain  *context_main,
                    "Can't specify both SM save file and SM client id");
       return FALSE;
     }
+#endif
 
   return TRUE;
 }
@@ -237,17 +246,22 @@ determine_compositor_type (MetaContextMain  *context_main,
   g_autofree char *session_type = NULL;
 
 #ifdef HAVE_WAYLAND
-  if (context_main->options.wayland ||
+  if (context_main->options.wayland
 #ifdef HAVE_NATIVE_BACKEND
-      context_main->options.display_server ||
-      context_main->options.headless ||
+      || context_main->options.display_server
+      || context_main->options.headless
 #endif /* HAVE_NATIVE_BACKEND */
-      context_main->options.nested)
+#ifdef HAVE_XWAYLAND
+      || context_main->options.nested
+#endif /* HAVE_XWAYLAND */
+      )
     return META_COMPOSITOR_TYPE_WAYLAND;
 #endif /* HAVE_WAYLAND */
 
+#ifdef HAVE_X11
   if (context_main->options.x11.force)
     return META_COMPOSITOR_TYPE_X11;
+#endif
 
   session_type = find_session_type (error);
   if (!session_type)
@@ -304,7 +318,7 @@ static MetaX11DisplayPolicy
 meta_context_main_get_x11_display_policy (MetaContext *context)
 {
   MetaCompositorType compositor_type;
-#ifdef HAVE_WAYLAND
+#ifdef HAVE_XWAYLAND
   MetaContextMain *context_main = META_CONTEXT_MAIN (context);
   char *unit;
 #endif
@@ -315,16 +329,16 @@ meta_context_main_get_x11_display_policy (MetaContext *context)
     case META_COMPOSITOR_TYPE_X11:
       return META_X11_DISPLAY_POLICY_MANDATORY;
     case META_COMPOSITOR_TYPE_WAYLAND:
-#ifdef HAVE_WAYLAND
+#ifdef HAVE_XWAYLAND
       if (context_main->options.no_x11)
         return META_X11_DISPLAY_POLICY_DISABLED;
       else if (sd_pid_get_user_unit (0, &unit) < 0)
         return META_X11_DISPLAY_POLICY_MANDATORY;
       else
         return META_X11_DISPLAY_POLICY_ON_DEMAND;
-#else /* HAVE_WAYLAND */
+#else /* HAVE_XWAYLAND */
       g_assert_not_reached ();
-#endif /* HAVE_WAYLAND */
+#endif /* HAVE_XWAYLAND */
     }
 
   g_assert_not_reached ();
@@ -333,9 +347,12 @@ meta_context_main_get_x11_display_policy (MetaContext *context)
 static gboolean
 meta_context_main_is_replacing (MetaContext *context)
 {
+#ifdef HAVE_X11
   MetaContextMain *context_main = META_CONTEXT_MAIN (context);
-
   return context_main->options.x11.replace;
+#else
+  return FALSE;
+#endif
 }
 
 #ifdef HAVE_NATIVE_BACKEND
@@ -400,6 +417,7 @@ meta_context_main_setup (MetaContext  *context,
   return TRUE;
 }
 
+#ifdef HAVE_X11
 static MetaBackend *
 create_x11_cm_backend (MetaContext  *context,
                        GError      **error)
@@ -417,8 +435,10 @@ create_x11_cm_backend (MetaContext  *context,
                          "display-name", context_main->options.x11.display_name,
                          NULL);
 }
+#endif
 
 #ifdef HAVE_WAYLAND
+#ifdef HAVE_XWAYLAND
 static MetaBackend *
 create_nested_backend (MetaContext  *context,
                        GError      **error)
@@ -428,6 +448,7 @@ create_nested_backend (MetaContext  *context,
                          "context", context,
                          NULL);
 }
+#endif /* HAVE_XWAYLAND */
 
 #ifdef HAVE_NATIVE_BACKEND
 static MetaBackend *
@@ -465,16 +486,20 @@ meta_context_main_create_backend (MetaContext  *context,
   compositor_type = meta_context_get_compositor_type (context);
   switch (compositor_type)
     {
-#ifdef HAVE_X11
     case META_COMPOSITOR_TYPE_X11:
+#ifdef HAVE_X11
       return create_x11_cm_backend (context, error);
+#else
+      g_assert_not_reached ();
 #endif
     case META_COMPOSITOR_TYPE_WAYLAND:
 #ifdef HAVE_WAYLAND
+#ifdef HAVE_XWAYLAND /* HAVE_XWAYLAND */
       if (context_main->options.nested)
         return create_nested_backend (context, error);
+#endif /* HAVE_XWAYLAND */
 #ifdef HAVE_NATIVE_BACKEND
-      else if (context_main->options.headless)
+      if (context_main->options.headless)
         return create_headless_backend (context, error);
       else
         return create_native_backend (context, error);
@@ -490,6 +515,7 @@ meta_context_main_create_backend (MetaContext  *context,
 static void
 meta_context_main_notify_ready (MetaContext *context)
 {
+#ifdef HAVE_X11
   MetaContextMain *context_main = META_CONTEXT_MAIN (context);
 
   if (!context_main->options.sm.disable)
@@ -500,6 +526,7 @@ meta_context_main_notify_ready (MetaContext *context)
     }
   g_clear_pointer (&context_main->options.sm.client_id, g_free);
   g_clear_pointer (&context_main->options.sm.save_file, g_free);
+#endif
 }
 
 #ifdef HAVE_X11
@@ -605,6 +632,7 @@ meta_context_main_add_option_entries (MetaContextMain *context_main)
       N_("Run as a wayland compositor"),
       NULL
     },
+#ifdef HAVE_XWAYLAND
     {
       "nested", 0, 0, G_OPTION_ARG_NONE,
       &context_main->options.nested,
@@ -617,6 +645,7 @@ meta_context_main_add_option_entries (MetaContextMain *context_main)
       N_("Run wayland compositor without starting Xwayland"),
       NULL
     },
+#endif
     {
       "wayland-display", 0, 0, G_OPTION_ARG_STRING,
       &context_main->options.wayland_display,


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