[mutter/bilelmoussaoui/x11-build-guards-2: 4/10] core/window: Guard x11 types




commit 0b8190eb9f56b68c03222d780df7478cd8b5a44a
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Wed Jun 15 15:05:21 2022 +0200

    core/window: Guard x11 types
    
    Releavant: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

 src/core/window.c | 81 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 67 insertions(+), 14 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 95a8e33e04..0d5fe5abcf 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -116,8 +116,10 @@
 static guint64 next_window_stamp = G_GUINT64_CONSTANT(0x100000000);
 
 static void     invalidate_work_areas     (MetaWindow     *window);
+#ifdef HAVE_X11_CLIENT
 static void     set_wm_state              (MetaWindow     *window);
 static void     set_net_wm_state          (MetaWindow     *window);
+#endif
 static void     meta_window_set_above     (MetaWindow     *window,
                                            gboolean        new_value);
 
@@ -1352,6 +1354,7 @@ _meta_window_shared_new (MetaDisplay         *display,
   else if (window->override_redirect)
     window->layer = META_LAYER_OVERRIDE_REDIRECT; /* otherwise set by MetaStack */
 
+#ifdef HAVE_X11_CLIENT
   if (!window->override_redirect)
     {
       /* FIXME we have a tendency to set this then immediately
@@ -1360,6 +1363,7 @@ _meta_window_shared_new (MetaDisplay         *display,
       set_wm_state (window);
       set_net_wm_state (window);
     }
+#endif
 
   meta_compositor_add_window (window->display->compositor, window);
   window->known_to_compositor = TRUE;
@@ -1596,6 +1600,7 @@ meta_window_unmanage (MetaWindow  *window,
   g_object_unref (window);
 }
 
+#ifdef HAVE_X11_CLIENT
 static void
 set_wm_state (MetaWindow *window)
 {
@@ -1616,6 +1621,7 @@ set_allowed_actions_hint (MetaWindow *window)
   if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
     meta_window_x11_set_allowed_actions_hint (window);
 }
+#endif /* HAVE_X11_CLIENT */
 
 /**
  * meta_window_located_on_workspace:
@@ -2163,7 +2169,7 @@ meta_window_show (MetaWindow *window)
               "Showing window %s, shaded: %d iconic: %d placed: %d",
               window->desc, window->shaded, window->iconic, window->placed);
 
-  focus_window = window->display->focus_window;  /* May be NULL! */
+  focus_window = display->focus_window;  /* May be NULL! */
   did_show = FALSE;
   window_state_on_map (window, &takes_focus_on_map, &place_on_top_on_map);
   needs_stacking_adjustment = FALSE;
@@ -2274,16 +2280,18 @@ meta_window_show (MetaWindow *window)
 
   if (window->hidden)
     {
-      meta_stack_freeze (window->display->stack);
+      meta_stack_freeze (display->stack);
       window->hidden = FALSE;
-      meta_stack_thaw (window->display->stack);
+      meta_stack_thaw (display->stack);
       did_show = TRUE;
     }
 
   if (window->iconic)
     {
       window->iconic = FALSE;
+#ifdef HAVE_X11_CLIENT
       set_wm_state (window);
+#endif
     }
 
   if (!window->visible_to_compositor)
@@ -2304,7 +2312,7 @@ meta_window_show (MetaWindow *window)
           break;
         }
 
-      meta_compositor_show_window (window->display->compositor,
+      meta_compositor_show_window (display->compositor,
                                    window, effect);
       window->pending_compositor_effect = META_COMP_EFFECT_NONE;
     }
@@ -2320,10 +2328,11 @@ meta_window_show (MetaWindow *window)
         {
           guint32     timestamp;
 
-          timestamp = meta_display_get_current_time_roundtrip (window->display);
+          timestamp = meta_display_get_current_time_roundtrip (display);
 
           meta_window_focus (window, timestamp);
         }
+#ifdef HAVE_X11_CLIENT
       else if (display->x11_display)
         {
           /* Prevent EnterNotify events in sloppy/mouse focus from
@@ -2334,9 +2343,12 @@ meta_window_show (MetaWindow *window)
            */
           meta_x11_display_increment_focus_sentinel (display->x11_display);
         }
+#endif
     }
 
+#ifdef HAVE_X11_CLIENT
   set_net_wm_state (window);
+#endif
 
   if (did_show && window->struts)
     {
@@ -2347,7 +2359,7 @@ meta_window_show (MetaWindow *window)
     }
 
   if (did_show)
-    meta_display_queue_check_fullscreen (window->display);
+    meta_display_queue_check_fullscreen (display);
 
   /*
    * Now that we have shown the window, we no longer want to consider the
@@ -2361,7 +2373,7 @@ meta_window_show (MetaWindow *window)
   if (notify_demands_attention)
     {
       g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_DEMANDS_ATTENTION]);
-      g_signal_emit_by_name (window->display, "window-demands-attention",
+      g_signal_emit_by_name (display, "window-demands-attention",
                              window);
     }
 
@@ -2414,10 +2426,14 @@ meta_window_hide (MetaWindow *window)
   if (!window->iconic)
     {
       window->iconic = TRUE;
+#ifdef HAVE_X11_CLIENT
       set_wm_state (window);
+#endif
     }
 
+#ifdef HAVE_X11_CLIENT
   set_net_wm_state (window);
+#endif
 
   if (did_hide && window->struts)
     {
@@ -2602,7 +2618,9 @@ meta_window_maximize_internal (MetaWindow        *window,
   update_edge_constraints (window);
 
   meta_window_recalc_features (window);
+#ifdef HAVE_X11_CLIENT
   set_net_wm_state (window);
+#endif
 
   if (window->monitor && window->monitor->in_fullscreen)
     meta_display_queue_check_fullscreen (window->display);
@@ -3016,7 +3034,9 @@ unmaximize_window_before_freeing (MetaWindow        *window)
   if (window->withdrawn)                /* See bug #137185 */
     {
       window->rect = window->saved_rect;
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
     }
 #ifdef HAVE_WAYLAND
   else if (!meta_is_wayland_compositor ())
@@ -3173,7 +3193,9 @@ meta_window_unmaximize (MetaWindow        *window,
         }
 
       meta_window_recalc_features (window);
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
       if (!window->monitor->in_fullscreen)
         meta_display_queue_check_fullscreen (window->display);
     }
@@ -3212,7 +3234,9 @@ meta_window_set_above (MetaWindow *window,
 
   window->wm_state_above = new_value;
   meta_window_update_layer (window);
+#ifdef HAVE_X11_CLIENT
   set_net_wm_state (window);
+#endif
   meta_window_frame_size_changed (window);
   g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_ABOVE]);
 }
@@ -3245,8 +3269,9 @@ meta_window_make_fullscreen_internal (MetaWindow  *window)
       meta_stack_thaw (window->display->stack);
 
       meta_window_recalc_features (window);
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
-
+#endif
       /* For the auto-minimize feature, if we fail to get focus */
       meta_display_queue_check_fullscreen (window->display);
 
@@ -3311,8 +3336,9 @@ meta_window_unmake_fullscreen (MetaWindow  *window)
       /* Need to update window->has_resize_func before we move_resize()
        */
       meta_window_recalc_features (window);
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
-
+#endif
       meta_compositor_size_change_window (window->display->compositor,
                                           window, META_SIZE_CHANGE_UNFULLSCREEN,
                                           &old_frame_rect, &old_buffer_rect);
@@ -3403,8 +3429,9 @@ meta_window_shade (MetaWindow  *window,
                   "Re-focusing window %s after shading it",
                   window->desc);
       meta_window_focus (window, timestamp);
-
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
     }
 }
 
@@ -3427,8 +3454,9 @@ meta_window_unshade (MetaWindow  *window,
                   "Focusing window %s after unshading it",
                   window->desc);
       meta_window_focus (window, timestamp);
-
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
     }
 }
 
@@ -5013,7 +5041,9 @@ meta_window_update_appears_focused (MetaWindow *window)
 
   window->appears_focused = appears_focused;
 
+#ifdef HAVE_X11_CLIENT
   set_net_wm_state (window);
+#endif
   meta_window_frame_size_changed (window);
 
   g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_APPEARS_FOCUSED]);
@@ -5309,8 +5339,10 @@ meta_window_type_changed (MetaWindow *window)
   window->attached = meta_window_should_attach_to_parent (window);
   meta_window_recalc_features (window);
 
+#ifdef HAVE_X11_CLIENT
   if (!window->override_redirect)
     set_net_wm_state (window);
+#endif
 
   /* Update frame */
   if (window->decorated)
@@ -5406,20 +5438,24 @@ meta_window_recalc_skip_features (MetaWindow *window)
 void
 meta_window_recalc_features (MetaWindow *window)
 {
+#ifdef HAVE_X11_CLIENT
   gboolean old_has_close_func;
   gboolean old_has_minimize_func;
   gboolean old_has_move_func;
-  gboolean old_has_resize_func;
   gboolean old_has_shade_func;
   gboolean old_always_sticky;
+#endif
+  gboolean old_has_resize_func;
   gboolean old_skip_taskbar;
 
+#ifdef HAVE_X11_CLIENT
   old_has_close_func = window->has_close_func;
   old_has_minimize_func = window->has_minimize_func;
   old_has_move_func = window->has_move_func;
-  old_has_resize_func = window->has_resize_func;
   old_has_shade_func = window->has_shade_func;
   old_always_sticky = window->always_sticky;
+#endif
+  old_has_resize_func = window->has_resize_func;
   old_skip_taskbar = window->skip_taskbar;
 
   /* Use MWM hints initially */
@@ -5586,6 +5622,7 @@ meta_window_recalc_features (MetaWindow *window)
    * The fix is to only recalc_features when something has
    * actually changed.
    */
+#ifdef HAVE_X11_CLIENT
   if (window->constructing                               ||
       old_has_close_func != window->has_close_func       ||
       old_has_minimize_func != window->has_minimize_func ||
@@ -5594,6 +5631,7 @@ meta_window_recalc_features (MetaWindow *window)
       old_has_shade_func != window->has_shade_func       ||
       old_always_sticky != window->always_sticky)
     set_allowed_actions_hint (window);
+#endif
 
   if (window->has_resize_func != old_has_resize_func)
     g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_RESIZEABLE]);
@@ -6977,7 +7015,9 @@ meta_window_set_demands_attention (MetaWindow *window)
                   window->desc);
 
       window->wm_state_demands_attention = TRUE;
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
       g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_DEMANDS_ATTENTION]);
       g_signal_emit_by_name (window->display, "window-demands-attention",
                              window);
@@ -7002,7 +7042,9 @@ meta_window_unset_demands_attention (MetaWindow *window)
   if (window->wm_state_demands_attention)
     {
       window->wm_state_demands_attention = FALSE;
+#ifdef HAVE_X11_CLIENT
       set_net_wm_state (window);
+#endif
       g_object_notify_by_pspec (G_OBJECT (window), obj_props[PROP_DEMANDS_ATTENTION]);
     }
 }
@@ -7358,9 +7400,11 @@ meta_window_get_transient_for (MetaWindow *window)
 
   if (window->transient_for)
     return window->transient_for;
+#ifdef HAVE_X11_CLIENT
   else if (window->xtransient_for)
     return meta_x11_display_lookup_x_window (window->display->x11_display,
                                              window->xtransient_for);
+#endif
   else
     return NULL;
 }
@@ -7912,6 +7956,7 @@ meta_window_set_transient_for (MetaWindow *window,
   if (window->appears_focused && window->transient_for != NULL)
     meta_window_propagate_focus_appearance (window, FALSE);
 
+#ifdef HAVE_X11_CLIENT
   /* may now be a dialog */
   if (window->client_type == META_WINDOW_CLIENT_TYPE_X11)
     {
@@ -7936,7 +7981,9 @@ meta_window_set_transient_for (MetaWindow *window,
             }
         }
     }
-  else if (window->attached && parent == NULL)
+  else
+#endif
+  if (window->attached && parent == NULL)
     {
       guint32 timestamp;
 
@@ -8059,6 +8106,7 @@ window_has_pointer_wayland (MetaWindow *window)
   return pointer_actor && clutter_actor_contains (window_actor, pointer_actor);
 }
 
+#ifdef HAVE_X11_CLIENT
 static gboolean
 window_has_pointer_x11 (MetaWindow *window)
 {
@@ -8081,14 +8129,19 @@ window_has_pointer_x11 (MetaWindow *window)
 
   return meta_x11_display_lookup_x_window (x11_display, child) == window;
 }
+#endif
 
 gboolean
 meta_window_has_pointer (MetaWindow *window)
 {
   if (meta_is_wayland_compositor ())
     return window_has_pointer_wayland (window);
+#ifdef HAVE_X11_CLIENT
   else
     return window_has_pointer_x11 (window);
+#else
+  return FALSE;
+#endif
 }
 
 static gboolean


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