core/context: Guard X11 calls

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
This commit is contained in:
Bilal Elmoussaoui 2024-01-22 16:56:45 +01:00 committed by Marge Bot
parent c388abe1e3
commit 8922ada681

View File

@ -423,6 +423,7 @@ meta_context_main_setup (MetaContext *context,
return TRUE; return TRUE;
} }
#ifdef HAVE_X11
static MetaBackend * static MetaBackend *
create_x11_cm_backend (MetaContext *context, create_x11_cm_backend (MetaContext *context,
GError **error) GError **error)
@ -440,8 +441,9 @@ create_x11_cm_backend (MetaContext *context,
"display-name", context_main->options.x11.display_name, "display-name", context_main->options.x11.display_name,
NULL); NULL);
} }
#endif
#ifdef HAVE_WAYLAND #if defined (HAVE_X11) && defined (HAVE_WAYLAND)
static MetaBackend * static MetaBackend *
create_nested_backend (MetaContext *context, create_nested_backend (MetaContext *context,
GError **error) GError **error)
@ -451,7 +453,9 @@ create_nested_backend (MetaContext *context,
"context", context, "context", context,
NULL); NULL);
} }
#endif
#ifdef HAVE_WAYLAND
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
static MetaBackend * static MetaBackend *
create_headless_backend (MetaContext *context, create_headless_backend (MetaContext *context,
@ -488,16 +492,19 @@ meta_context_main_create_backend (MetaContext *context,
compositor_type = meta_context_get_compositor_type (context); compositor_type = meta_context_get_compositor_type (context);
switch (compositor_type) switch (compositor_type)
{ {
#ifdef HAVE_X11
case META_COMPOSITOR_TYPE_X11: case META_COMPOSITOR_TYPE_X11:
#ifdef HAVE_X11
return create_x11_cm_backend (context, error); return create_x11_cm_backend (context, error);
#endif #endif
case META_COMPOSITOR_TYPE_WAYLAND: case META_COMPOSITOR_TYPE_WAYLAND:
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
#ifdef HAVE_X11
if (context_main->options.nested) if (context_main->options.nested)
return create_nested_backend (context, error); return create_nested_backend (context, error);
else
#endif
#ifdef HAVE_NATIVE_BACKEND #ifdef HAVE_NATIVE_BACKEND
else if (context_main->options.headless) if (context_main->options.headless)
return create_headless_backend (context, error); return create_headless_backend (context, error);
else else
return create_native_backend (context, error); return create_native_backend (context, error);
@ -510,6 +517,7 @@ meta_context_main_create_backend (MetaContext *context,
g_assert_not_reached (); g_assert_not_reached ();
} }
#ifdef HAVE_X11
static void static void
meta_context_main_notify_ready (MetaContext *context) meta_context_main_notify_ready (MetaContext *context)
{ {
@ -525,7 +533,6 @@ meta_context_main_notify_ready (MetaContext *context)
g_clear_pointer (&context_main->options.sm.save_file, g_free); g_clear_pointer (&context_main->options.sm.save_file, g_free);
} }
#ifdef HAVE_X11
static gboolean static gboolean
meta_context_main_is_x11_sync (MetaContext *context) meta_context_main_is_x11_sync (MetaContext *context)
{ {
@ -745,8 +752,8 @@ meta_context_main_class_init (MetaContextMainClass *klass)
context_class->is_replacing = meta_context_main_is_replacing; context_class->is_replacing = meta_context_main_is_replacing;
context_class->setup = meta_context_main_setup; context_class->setup = meta_context_main_setup;
context_class->create_backend = meta_context_main_create_backend; context_class->create_backend = meta_context_main_create_backend;
context_class->notify_ready = meta_context_main_notify_ready;
#ifdef HAVE_X11 #ifdef HAVE_X11
context_class->notify_ready = meta_context_main_notify_ready;
context_class->is_x11_sync = meta_context_main_is_x11_sync; context_class->is_x11_sync = meta_context_main_is_x11_sync;
#endif #endif
} }