[mutter/bilelmoussaoui/x11-build-guards: 2/2] core/display: Guard X11 types




commit 47e0c8a5e96b695d35a8d8a12f40209ffb99bfab
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Tue May 31 11:57:37 2022 +0200

    core/display: Guard X11 types
    
    Related https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

 src/core/display-private.h |  5 ++++
 src/core/display.c         | 66 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 59 insertions(+), 12 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 37932095b8..760e25b2dc 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -256,7 +256,10 @@ struct _MetaDisplayClass
 MetaDisplay * meta_display_new (MetaContext  *context,
                                 GError      **error);
 
+#ifdef HAVE_X11_CLIENT
 void meta_display_manage_all_xwindows (MetaDisplay *display);
+#endif
+
 void meta_display_unmanage_windows   (MetaDisplay *display,
                                       guint32      timestamp);
 
@@ -300,7 +303,9 @@ META_EXPORT_TEST
 GSList*     meta_display_list_windows        (MetaDisplay          *display,
                                               MetaListWindowsFlags  flags);
 
+#ifdef HAVE_X11_CLIENT
 MetaDisplay* meta_display_for_x_display  (Display     *xdisplay);
+#endif
 
 META_EXPORT_TEST
 MetaDisplay* meta_get_display            (void);
diff --git a/src/core/display.c b/src/core/display.c
index 319ec042ec..99a57dc230 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -33,12 +33,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+
+#ifdef HAVE_X11_CLIENT
 #include <X11/Xatom.h>
 #include <X11/Xcursor/Xcursor.h>
 #include <X11/extensions/shape.h>
 #include <X11/extensions/Xcomposite.h>
 #include <X11/extensions/Xdamage.h>
 #include <X11/extensions/Xfixes.h>
+#endif
 
 #include "backends/meta-backend-private.h"
 #include "backends/meta-cursor-sprite-xcursor.h"
@@ -46,13 +49,7 @@
 #include "backends/meta-input-device-private.h"
 #include "backends/meta-input-mapper-private.h"
 #include "backends/meta-stage-private.h"
-#include "backends/x11/meta-backend-x11.h"
-#include "backends/x11/meta-clutter-backend-x11.h"
-#include "backends/x11/meta-event-x11.h"
-#include "backends/x11/cm/meta-backend-x11-cm.h"
-#include "backends/x11/nested/meta-backend-x11-nested.h"
 #include "compositor/compositor-private.h"
-#include "compositor/meta-compositor-x11.h"
 #include "cogl/cogl.h"
 #include "core/bell.h"
 #include "core/boxes-private.h"
@@ -71,12 +68,21 @@
 #include "meta/meta-backend.h"
 #include "meta/meta-enum-types.h"
 #include "meta/meta-sound-player.h"
-#include "meta/meta-x11-errors.h"
 #include "meta/prefs.h"
+
+#ifdef HAVE_X11_CLIENT
+#include "backends/x11/meta-backend-x11.h"
+#include "backends/x11/meta-clutter-backend-x11.h"
+#include "backends/x11/meta-event-x11.h"
+#include "backends/x11/cm/meta-backend-x11-cm.h"
+#include "backends/x11/nested/meta-backend-x11-nested.h"
+#include "compositor/meta-compositor-x11.h"
+#include "meta/meta-x11-errors.h"
 #include "x11/meta-startup-notification-x11.h"
 #include "x11/meta-x11-display-private.h"
 #include "x11/window-x11.h"
 #include "x11/xprops.h"
+#endif
 
 #ifdef HAVE_WAYLAND
 #include "compositor/meta-compositor-native.h"
@@ -621,10 +627,16 @@ create_compositor (MetaDisplay *display)
   if (META_IS_BACKEND_NATIVE (backend))
     return META_COMPOSITOR (meta_compositor_native_new (display, backend));
 #endif
+#ifdef HAVE_XWAYLAND
   if (META_IS_BACKEND_X11_NESTED (backend))
     return META_COMPOSITOR (meta_compositor_server_new (display, backend));
 #endif
+#endif/* HAVE_WAYLAND */
+#ifdef HAVE_X11
   return META_COMPOSITOR (meta_compositor_x11_new (display, backend));
+#else
+  g_assert_not_reached ();
+#endif 
 }
 
 static void
@@ -840,7 +852,9 @@ meta_display_new (MetaContext  *context,
   MetaDisplayPrivate *priv;
   int i;
   guint32 timestamp;
+#ifdef HAVE_X11_CLIENT
   Window old_active_xwindow = None;
+#endif
   MetaMonitorManager *monitor_manager;
   MetaSettings *settings;
 
@@ -970,11 +984,13 @@ meta_display_new (MetaContext  *context,
   display->last_focus_time = timestamp;
   display->last_user_time = timestamp;
 
+#ifdef HAVE_X11
   if (!meta_is_wayland_compositor ())
     meta_prop_get_window (display->x11_display,
                           display->x11_display->xroot,
                           display->x11_display->atom__NET_ACTIVE_WINDOW,
                           &old_active_xwindow);
+#endif
 
   if (!meta_compositor_do_manage (display->compositor, error))
     {
@@ -982,12 +998,14 @@ meta_display_new (MetaContext  *context,
       return NULL;
     }
 
+#ifdef HAVE_X11_CLIENT
   if (display->x11_display)
     {
       g_signal_emit (display, display_signals[X11_DISPLAY_OPENED], 0);
       meta_x11_display_restore_active_workspace (display->x11_display);
       meta_x11_display_create_guard_window (display->x11_display);
     }
+#endif
 
   /* Set up touch support */
   display->gesture_tracker = meta_gesture_tracker_new ();
@@ -997,6 +1015,7 @@ meta_display_new (MetaContext  *context,
   /* We know that if mutter is running as a Wayland compositor,
    * we start out with no windows.
    */
+#ifdef HAVE_X11_CLIENT
   if (!meta_is_wayland_compositor ())
     meta_display_manage_all_xwindows (display);
 
@@ -1014,6 +1033,10 @@ meta_display_new (MetaContext  *context,
     {
       meta_display_unset_input_focus (display, timestamp);
     }
+#else
+  meta_display_unset_input_focus (display, timestamp);
+#endif
+
 
   display->sound_player = g_object_new (META_TYPE_SOUND_PLAYER, NULL);
 
@@ -1057,6 +1080,7 @@ meta_display_list_windows (MetaDisplay          *display,
 
   winlist = NULL;
 
+#ifdef HAVE_X11_CLIENT
   if (display->x11_display)
     {
       g_hash_table_iter_init (&iter, display->x11_display->xids);
@@ -1072,6 +1096,7 @@ meta_display_list_windows (MetaDisplay          *display,
             winlist = g_slist_prepend (winlist, window);
         }
     }
+#endif
 
   g_hash_table_iter_init (&iter, display->wayland_windows);
   while (g_hash_table_iter_next (&iter, &key, &value))
@@ -1207,6 +1232,7 @@ meta_display_close (MetaDisplay *display,
  * Returns: The singleton X display, or %NULL if @xdisplay isn't the one
  *          we're managing.
  */
+#ifdef HAVE_X11_CLIENT
 MetaDisplay*
 meta_display_for_x_display (Display *xdisplay)
 {
@@ -1218,6 +1244,7 @@ meta_display_for_x_display (Display *xdisplay)
 
   return NULL;
 }
+#endif
 
 /**
  * meta_get_display:
@@ -1345,7 +1372,11 @@ meta_display_get_current_time_roundtrip (MetaDisplay *display)
     /* Xwayland uses monotonic clock, so lets use it here as well */
     return (guint32) (g_get_monotonic_time () / 1000);
   else
+#ifdef HAVE_X11_CLIENT
     return meta_x11_display_get_current_time_roundtrip (display->x11_display);
+#else
+    g_assert_not_reached ();
+#endif
 }
 
 /**
@@ -1436,9 +1467,11 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
   MetaStage *stage = META_STAGE (meta_backend_get_stage (backend));
   gboolean is_no_focus_xwindow = FALSE;
 
+#ifdef HAVE_X11_CLIENT
   if (display->x11_display)
     is_no_focus_xwindow = meta_x11_display_xwindow_is_a_no_focus_window (display->x11_display,
                                                                          
display->x11_display->focus_xwindow);
+#endif
 
   if (!meta_display_windows_are_interactable (display))
     focus_window = NULL;
@@ -1572,11 +1605,13 @@ meta_display_set_input_focus (MetaDisplay *display,
   if (meta_display_timestamp_too_old (display, &timestamp))
     return;
 
+#ifdef HAVE_X11_CLIENT
   if (display->x11_display)
     {
       meta_x11_display_set_input_focus (display->x11_display, window,
                                         focus_frame, timestamp);
     }
+#endif
 
   meta_display_update_focus_window (display, window);
 
@@ -1637,6 +1672,7 @@ MetaWindow*
 meta_display_lookup_stack_id (MetaDisplay *display,
                               guint64      stack_id)
 {
+#ifdef HAVE_X11_CLIENT
   if (META_STACK_ID_IS_X11 (stack_id))
     {
       if (!display->x11_display)
@@ -1644,10 +1680,8 @@ meta_display_lookup_stack_id (MetaDisplay *display,
       return meta_x11_display_lookup_x_window (display->x11_display,
                                                (Window)stack_id);
     }
-  else
-    {
-      return meta_display_lookup_stamp (display, stack_id);
-    }
+#endif
+  return meta_display_lookup_stamp (display, stack_id);
 }
 
 /* We return a pointer into a ring of static buffers. This is to make
@@ -1919,6 +1953,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
   if (pointer_already_grabbed)
     display->grab_have_pointer = TRUE;
 
+#ifdef HAVE_X11_CLIENT
   if (META_IS_BACKEND_X11 (meta_get_backend ()) && display->x11_display)
     {
       /* Since grab operations often happen as a result of implicit
@@ -1930,6 +1965,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
                       timestamp);
       XSync (display->x11_display->xdisplay, False);
     }
+#endif
 
   if (meta_backend_grab_device (backend, META_VIRTUAL_CORE_POINTER_ID, timestamp))
     display->grab_have_pointer = TRUE;
@@ -2158,12 +2194,14 @@ meta_is_syncing (void)
 void
 meta_set_syncing (gboolean setting)
 {
+#ifdef HAVE_X11_CLIENT
   if (setting != is_syncing)
     {
       is_syncing = setting;
       if (meta_get_display ())
         XSynchronize (meta_get_display ()->x11_display->xdisplay, is_syncing);
     }
+#endif
 }
 
 /**
@@ -2665,6 +2703,7 @@ meta_resize_gravity_from_grab_op (MetaGrabOp op)
   return gravity;
 }
 
+#ifdef HAVE_X11_CLIENT
 void
 meta_display_manage_all_xwindows (MetaDisplay *display)
 {
@@ -2689,6 +2728,7 @@ meta_display_manage_all_xwindows (MetaDisplay *display)
   g_free (children);
   meta_stack_thaw (display->stack);
 }
+#endif
 
 void
 meta_display_unmanage_windows (MetaDisplay *display,
@@ -2880,13 +2920,15 @@ meta_display_supports_extended_barriers (MetaDisplay *display)
     return TRUE;
 #endif
 
+#ifdef HAVE_X11_CLIENT
   if (META_IS_BACKEND_X11_CM (meta_get_backend ()))
     {
-      if (meta_is_wayland_compositor())
+      if (meta_is_wayland_compositor ())
         return FALSE;
 
       return META_X11_DISPLAY_HAS_XINPUT_23 (display->x11_display);
     }
+#endif
 
   return FALSE;
 }


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