[mutter/bilelmoussaoui/keybindings: 115/124] core/window: Guard x11 types




commit 50de44708c5c59ba396746d4ef9f0f6b35a3ef4d
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 98306291c9..ca864c06ed 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:
@@ -2157,7 +2163,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;
@@ -2268,16 +2274,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)
@@ -2298,7 +2306,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;
     }
@@ -2314,10 +2322,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
@@ -2328,9 +2337,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)
     {
@@ -2341,7 +2353,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
@@ -2355,7 +2367,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);
     }
 
@@ -2408,10 +2420,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)
     {
@@ -2603,7 +2619,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);
@@ -3017,7 +3035,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 ())
@@ -3174,7 +3194,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);
     }
@@ -3213,7 +3235,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]);
 }
@@ -3246,8 +3270,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);
 
@@ -3312,8 +3337,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);
@@ -3404,8 +3430,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
     }
 }
 
@@ -3428,8 +3455,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
     }
 }
 
@@ -5014,7 +5042,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]);
@@ -5310,8 +5340,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)
@@ -5407,20 +5439,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 */
@@ -5587,6 +5623,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 ||
@@ -5595,6 +5632,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]);
@@ -6978,7 +7016,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);
@@ -7003,7 +7043,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]);
     }
 }
@@ -7359,9 +7401,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;
 }
@@ -7913,6 +7957,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)
     {
@@ -7937,7 +7982,9 @@ meta_window_set_transient_for (MetaWindow *window,
             }
         }
     }
-  else if (window->attached && parent == NULL)
+  else
+#endif
+  if (window->attached && parent == NULL)
     {
       guint32 timestamp;
 
@@ -8061,6 +8108,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)
 {
@@ -8083,14 +8131,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]