[mutter/bilelmoussaoui/x11-build-guards: 80/85] compositor: Guard X11 types
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/x11-build-guards: 80/85] compositor: Guard X11 types
- Date: Wed, 27 Jul 2022 08:35:14 +0000 (UTC)
commit bd9bd8d51f3834ae5ca284ec9c23812821bd6c20
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Tue May 31 11:42:47 2022 +0200
compositor: Guard X11 types
This also moves meta_compositor_x11_redirect_windows to DisplayX11
where it makes more sense as meta_display_x11_redirection_windows
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
src/compositor/compositor-private.h | 2 -
src/compositor/compositor.c | 93 ++++++++++--------------------------
src/compositor/meta-compositor-x11.c | 2 +-
src/core/display.c | 20 +++++---
src/meta/meta-x11-display.h | 2 +
src/x11/meta-x11-display.c | 44 +++++++++++++++++
6 files changed, 87 insertions(+), 76 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index d3b3145a35..fab6e23cc7 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -60,8 +60,6 @@ MetaInhibitShortcutsDialog * meta_compositor_create_inhibit_shortcuts_dialog (Me
void meta_compositor_locate_pointer (MetaCompositor *compositor);
-void meta_compositor_redirect_x11_windows (MetaCompositor *compositor);
-
gboolean meta_compositor_is_unredirect_inhibited (MetaCompositor *compositor);
MetaDisplay * meta_compositor_get_display (MetaCompositor *compositor);
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 8c11f74dc1..d17a047b86 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -54,15 +54,9 @@
#include "compositor/compositor-private.h"
-#include <X11/extensions/Xcomposite.h>
-
-#include "backends/x11/meta-backend-x11.h"
-#include "backends/x11/meta-event-x11.h"
-#include "backends/x11/meta-stage-x11.h"
#include "clutter/clutter-mutter.h"
#include "cogl/cogl.h"
#include "compositor/meta-later-private.h"
-#include "compositor/meta-window-actor-x11.h"
#include "compositor/meta-window-actor-private.h"
#include "compositor/meta-window-group-private.h"
#include "core/frame.h"
@@ -75,16 +69,27 @@
#include "meta/meta-background-group.h"
#include "meta/meta-context.h"
#include "meta/meta-shadow-factory.h"
-#include "meta/meta-x11-errors.h"
#include "meta/prefs.h"
#include "meta/window.h"
-#include "x11/meta-x11-display-private.h"
#ifdef HAVE_WAYLAND
#include "compositor/meta-window-actor-wayland.h"
#include "wayland/meta-wayland-private.h"
#endif
+#ifdef HAVE_X11_CLIENT
+#include <X11/extensions/Xcomposite.h>
+
+#include "backends/x11/meta-backend-x11.h"
+#include "backends/x11/meta-event-x11.h"
+#include "backends/x11/meta-stage-x11.h"
+
+#include "compositor/meta-window-actor-x11.h"
+
+#include "meta/meta-x11-errors.h"
+#include "x11/meta-x11-display-private.h"
+#endif
+
enum
{
PROP_0,
@@ -305,6 +310,7 @@ void
meta_focus_stage_window (MetaDisplay *display,
guint32 timestamp)
{
+#ifdef HAVE_X11_CLIENT
ClutterStage *stage;
Window window;
@@ -320,18 +326,19 @@ meta_focus_stage_window (MetaDisplay *display,
meta_x11_display_set_input_focus_xwindow (display->x11_display,
window,
timestamp);
+#endif
}
gboolean
meta_stage_is_focused (MetaDisplay *display)
{
- ClutterStage *stage;
- Window window;
-
if (meta_is_wayland_compositor ())
return TRUE;
- stage = CLUTTER_STAGE (meta_get_stage_for_display (display));
+#ifdef HAVE_X11_CLIENT
+ ClutterStage *stage = CLUTTER_STAGE (meta_get_stage_for_display (display));
+ Window window;
+
if (!stage)
return FALSE;
@@ -341,6 +348,9 @@ meta_stage_is_focused (MetaDisplay *display)
return FALSE;
return (display->x11_display->focus_xwindow == window);
+#else
+ return FALSE;
+#endif
}
void
@@ -355,61 +365,6 @@ meta_compositor_grab_end (MetaCompositor *compositor)
META_COMPOSITOR_GET_CLASS (compositor)->grab_end (compositor);
}
-static void
-redirect_windows (MetaX11Display *x11_display)
-{
- MetaBackend *backend = meta_get_backend ();
- MetaContext *context = meta_backend_get_context (backend);
- Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
- Window xroot = meta_x11_display_get_xroot (x11_display);
- int screen_number = meta_x11_display_get_screen_number (x11_display);
- guint n_retries;
- guint max_retries;
-
- if (meta_context_is_replacing (context))
- max_retries = 5;
- else
- max_retries = 1;
-
- n_retries = 0;
-
- /* Some compositors (like old versions of Mutter) might not properly unredirect
- * subwindows before destroying the WM selection window; so we wait a while
- * for such a compositor to exit before giving up.
- */
- while (TRUE)
- {
- meta_x11_error_trap_push (x11_display);
- XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
- XSync (xdisplay, FALSE);
-
- if (!meta_x11_error_trap_pop_with_return (x11_display))
- break;
-
- if (n_retries == max_retries)
- {
- /* This probably means that a non-WM compositor like xcompmgr is running;
- * we have no way to get it to exit */
- meta_fatal (_("Another compositing manager is already running on screen %i on display ā%sā."),
- screen_number, x11_display->name);
- }
-
- n_retries++;
- g_usleep (G_USEC_PER_SEC);
- }
-}
-
-void
-meta_compositor_redirect_x11_windows (MetaCompositor *compositor)
-{
- MetaCompositorPrivate *priv =
- meta_compositor_get_instance_private (compositor);
- MetaDisplay *display = priv->display;
-
- if (display->x11_display)
- redirect_windows (display->x11_display);
-}
-
gboolean
meta_compositor_do_manage (MetaCompositor *compositor,
GError **error)
@@ -483,9 +438,11 @@ meta_compositor_add_window (MetaCompositor *compositor,
switch (window->client_type)
{
+#ifdef HAVE_X11_CLIENT
case META_WINDOW_CLIENT_TYPE_X11:
window_actor_type = META_TYPE_WINDOW_ACTOR_X11;
break;
+#endif
#ifdef HAVE_WAYLAND
case META_WINDOW_CLIENT_TYPE_WAYLAND:
@@ -571,7 +528,9 @@ meta_compositor_window_shape_changed (MetaCompositor *compositor,
if (!window_actor)
return;
+#ifdef HAVE_X11_CLIENT
meta_window_actor_x11_update_shape (META_WINDOW_ACTOR_X11 (window_actor));
+#endif
}
void
diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c
index 614bec674b..a4015358f9 100644
--- a/src/compositor/meta-compositor-x11.c
+++ b/src/compositor/meta-compositor-x11.c
@@ -198,7 +198,7 @@ meta_compositor_x11_manage (MetaCompositor *compositor,
compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay);
- meta_compositor_redirect_x11_windows (META_COMPOSITOR (compositor));
+ meta_x11_display_redirect_windows (x11_display);
return TRUE;
}
diff --git a/src/core/display.c b/src/core/display.c
index 5bb34a65ab..111fc781a2 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -628,7 +628,7 @@ create_compositor (MetaDisplay *display)
}
static void
-meta_display_init (MetaDisplay *disp)
+meta_display_init (MetaDisplay *display)
{
/* Some stuff could go in here that's currently in _open,
* but it doesn't really matter. */
@@ -694,6 +694,7 @@ on_monitor_privacy_screen_changed (MetaDisplay *display,
: _("Privacy Screen Disabled"));
}
+#ifdef HAVE_X11_CLIENT
static gboolean
meta_display_init_x11_display (MetaDisplay *display,
GError **error)
@@ -719,7 +720,6 @@ meta_display_init_x11_display (MetaDisplay *display,
return TRUE;
}
-#ifdef HAVE_WAYLAND
gboolean
meta_display_init_x11_finish (MetaDisplay *display,
GAsyncResult *result,
@@ -818,7 +818,7 @@ on_x11_initialized (MetaDisplay *display,
if (!meta_display_init_x11_finish (display, result, &error))
g_critical ("Failed to init X11 display: %s", error->message);
}
-#endif
+#endif /* HAVE_X11_CLIENT */
void
meta_display_shutdown_x11 (MetaDisplay *display)
@@ -933,10 +933,12 @@ meta_display_new (MetaContext *context,
{
MetaWaylandCompositor *wayland_compositor =
meta_wayland_compositor_get_default ();
- MetaX11DisplayPolicy x11_display_policy;
meta_wayland_compositor_init_display (wayland_compositor, display);
+#ifdef HAVE_XWAYLAND
+ MetaX11DisplayPolicy x11_display_policy;
+
x11_display_policy = meta_context_get_x11_display_policy (context);
if (x11_display_policy == META_X11_DISPLAY_POLICY_MANDATORY)
{
@@ -944,11 +946,12 @@ meta_display_new (MetaContext *context,
(GAsyncReadyCallback) on_x11_initialized,
NULL);
}
-
+#endif /* HAVE_XWAYLAND */
timestamp = meta_display_get_current_time_roundtrip (display);
}
else
-#endif
+#endif /* HAVE_WAYLAND */
+#ifdef HAVE_X11
{
if (!meta_display_init_x11_display (display, error))
{
@@ -958,6 +961,11 @@ meta_display_new (MetaContext *context,
timestamp = display->x11_display->timestamp;
}
+#else
+ {
+ g_assert_not_reached ();
+ }
+#endif
display->last_focus_time = timestamp;
display->last_user_time = timestamp;
diff --git a/src/meta/meta-x11-display.h b/src/meta/meta-x11-display.h
index eb84c2b201..2ca9646bf7 100644
--- a/src/meta/meta-x11-display.h
+++ b/src/meta/meta-x11-display.h
@@ -70,4 +70,6 @@ void meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
META_EXPORT
void meta_x11_display_clear_stage_input_region (MetaX11Display *x11_display);
+META_EXPORT
+void meta_x11_display_redirect_windows (MetaX11Display *x11_display);
#endif /* META_X11_DISPLAY_H */
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index b424dee70e..37959e1589 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -2327,3 +2327,47 @@ meta_x11_display_clear_stage_input_region (MetaX11Display *x11_display)
meta_x11_display_set_stage_input_region (x11_display,
x11_display->empty_region);
}
+
+void
+meta_x11_display_redirect_windows (MetaX11Display *x11_display)
+{
+ MetaBackend *backend = meta_get_backend ();
+ MetaContext *context = meta_backend_get_context (backend);
+ Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
+ Window xroot = meta_x11_display_get_xroot (x11_display);
+ int screen_number = meta_x11_display_get_screen_number (x11_display);
+ guint n_retries;
+ guint max_retries;
+
+ if (meta_context_is_replacing (context))
+ max_retries = 5;
+ else
+ max_retries = 1;
+
+ n_retries = 0;
+
+ /* Some compositors (like old versions of Mutter) might not properly unredirect
+ * subwindows before destroying the WM selection window; so we wait a while
+ * for such a compositor to exit before giving up.
+ */
+ while (TRUE)
+ {
+ meta_x11_error_trap_push (x11_display);
+ XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
+ XSync (xdisplay, FALSE);
+
+ if (!meta_x11_error_trap_pop_with_return (x11_display))
+ break;
+
+ if (n_retries == max_retries)
+ {
+ /* This probably means that a non-WM compositor like xcompmgr is running;
+ * we have no way to get it to exit */
+ meta_fatal (_("Another compositing manager is already running on screen %i on display ā%sā."),
+ screen_number, x11_display->name);
+ }
+
+ n_retries++;
+ g_usleep (G_USEC_PER_SEC);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]