1
0
Fork 0

build: Allow building xwayland without x11

Co-authored-by: Jonas Ådahl <jadahl@gmail.com>
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/3553

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3853>
This commit is contained in:
Bilal Elmoussaoui 2024-06-30 15:08:55 +02:00
parent 4134d12789
commit 820a7ad813
15 changed files with 84 additions and 50 deletions

View file

@ -34,7 +34,7 @@ if have_egl
]
endif
if have_x11_client
if have_x11
cogl_pkg_deps += [
x11_dep,
]

View file

@ -192,14 +192,14 @@ if have_egl
egl_dep = dependency('egl')
endif
have_glx = get_option('glx') and have_x11_client
have_glx = get_option('glx') and have_x11
if have_glx
if not have_gl
error('GLX support requires OpenGL to be enabled')
endif
endif
have_egl_xlib = have_egl and have_x11_client
have_egl_xlib = have_egl and have_x11
have_gles2 = get_option('gles2')
if have_gles2

View file

@ -33,7 +33,7 @@ mtk_pkg_deps = [
pixman_dep,
]
if have_x11
if have_x11_client
mtk_pkg_deps += x11_dep
endif

View file

@ -12,7 +12,7 @@ mtk_sources = [
'mtk-region.c',
]
if have_x11
if have_x11_client
mtk_sources += 'mtk-x11-errors.c'
mtk_headers += [
'mtk-x11-errors.h',

View file

@ -437,6 +437,7 @@ has_shadow (MetaWindowActorX11 *actor_x11)
return TRUE;
}
#ifdef HAVE_X11
gboolean
meta_window_actor_x11_should_unredirect (MetaWindowActorX11 *actor_x11)
{
@ -478,6 +479,7 @@ meta_window_actor_x11_set_unredirected (MetaWindowActorX11 *actor_x11,
surface_x11 = META_SURFACE_ACTOR_X11 (surface);
meta_surface_actor_x11_set_unredirected (surface_x11, unredirected);
}
#endif /* HAVE_X11 */
static const char *
get_shadow_class (MetaWindowActorX11 *actor_x11)
@ -1013,9 +1015,11 @@ is_actor_maybe_transparent (MetaWindowActorX11 *actor_x11)
if (!surface)
return TRUE;
#ifdef HAVE_X11
if (META_IS_SURFACE_ACTOR_X11 (surface) &&
meta_surface_actor_x11_is_unredirected (META_SURFACE_ACTOR_X11 (surface)))
return FALSE;
#endif
stex = meta_surface_actor_get_texture (surface);
if (!meta_shaped_texture_has_alpha (stex))
@ -1148,9 +1152,11 @@ handle_updates (MetaWindowActorX11 *actor_x11)
meta_window_actor_get_surface (META_WINDOW_ACTOR (actor_x11));
MetaWindow *window;
#ifdef HAVE_X11
if (META_IS_SURFACE_ACTOR_X11 (surface) &&
meta_surface_actor_x11_is_unredirected (META_SURFACE_ACTOR_X11 (surface)))
return;
#endif
window = meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
if (meta_window_actor_is_frozen (META_WINDOW_ACTOR (actor_x11)))
@ -1168,6 +1174,7 @@ handle_updates (MetaWindowActorX11 *actor_x11)
return;
}
#ifdef HAVE_X11
if (META_IS_SURFACE_ACTOR_X11 (surface))
{
MetaSurfaceActorX11 *surface_x11 = META_SURFACE_ACTOR_X11 (surface);
@ -1178,6 +1185,7 @@ handle_updates (MetaWindowActorX11 *actor_x11)
if (META_IS_SURFACE_ACTOR_X11 (surface) &&
!meta_surface_actor_x11_is_visible (META_SURFACE_ACTOR_X11 (surface)))
return;
#endif /* HAVE_X11 */
update_frame_bounds (actor_x11);
check_needs_reshape (actor_x11);

View file

@ -20,6 +20,8 @@
#pragma once
#include <X11/extensions/Xdamage.h>
#include "compositor/meta-window-actor-private.h"
#define META_TYPE_WINDOW_ACTOR_X11 (meta_window_actor_x11_get_type())
@ -31,10 +33,12 @@ G_DECLARE_FINAL_TYPE (MetaWindowActorX11,
void meta_window_actor_x11_process_x11_damage (MetaWindowActorX11 *actor_x11,
XDamageNotifyEvent *event);
#ifdef HAVE_X11
gboolean meta_window_actor_x11_should_unredirect (MetaWindowActorX11 *actor_x11);
void meta_window_actor_x11_set_unredirected (MetaWindowActorX11 *actor_x11,
gboolean unredirected);
#endif
void meta_window_actor_x11_update_shape (MetaWindowActorX11 *actor_x11);

View file

@ -495,7 +495,7 @@ init_surface_actor (MetaWindowActor *self)
MetaWindow *window = priv->window;
MetaSurfaceActor *surface_actor = NULL;
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
if (!meta_is_wayland_compositor ())
{
surface_actor = meta_surface_actor_x11_new (window);
@ -953,7 +953,7 @@ meta_window_actor_sync_actor_geometry (MetaWindowActor *self,
/* When running as a Wayland compositor we catch size changes when new
* buffers are attached */
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
if (META_IS_SURFACE_ACTOR_X11 (priv->surface))
meta_surface_actor_x11_set_size (META_SURFACE_ACTOR_X11 (priv->surface),
actor_rect.width, actor_rect.height);

View file

@ -664,7 +664,7 @@ create_compositor (MetaDisplay *display)
if (META_IS_BACKEND_NATIVE (backend))
return META_COMPOSITOR (meta_compositor_native_new (display, backend));
#endif
#ifdef HAVE_XWAYLAND
#if defined(HAVE_XWAYLAND) && defined(HAVE_X11)
if (META_IS_BACKEND_X11_NESTED (backend))
return META_COMPOSITOR (meta_compositor_server_new (display, backend));
#endif
@ -801,7 +801,7 @@ disable_input_capture (MetaInputCapture *input_capture,
priv->enable_input_capture = FALSE;
}
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
static gboolean
meta_display_init_x11_display (MetaDisplay *display,
GError **error)
@ -860,7 +860,6 @@ meta_display_init_x11_finish (MetaDisplay *display,
return TRUE;
}
#ifdef HAVE_XWAYLAND
static void
on_xserver_started (MetaXWaylandManager *manager,
GAsyncResult *result,
@ -889,7 +888,6 @@ on_xserver_started (MetaXWaylandManager *manager,
g_task_return_boolean (task, TRUE);
}
}
#endif /* HAVE_XWAYLAND */
void
meta_display_init_x11 (MetaDisplay *display,
@ -898,21 +896,17 @@ meta_display_init_x11 (MetaDisplay *display,
gpointer user_data)
{
g_autoptr (GTask) task = NULL;
#ifdef HAVE_XWAYLAND
MetaWaylandCompositor *compositor;
#endif
task = g_task_new (display, cancellable, callback, user_data);
g_task_set_source_tag (task, meta_display_init_x11);
#ifdef HAVE_XWAYLAND
compositor = wayland_compositor_from_display (display);
meta_xwayland_start_xserver (&compositor->xwayland_manager,
cancellable,
(GAsyncReadyCallback) on_xserver_started,
g_steal_pointer (&task));
#endif
}
static void

View file

@ -178,7 +178,7 @@ sequence_is_pointer_emulated (MetaDisplay *display,
return FALSE;
}
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
static void
maybe_unfreeze_pointer_events (MetaBackend *backend,
const ClutterEvent *event,
@ -424,7 +424,7 @@ meta_display_handle_event (MetaDisplay *display,
if (meta_window_handle_ungrabbed_event (window, event))
return CLUTTER_EVENT_STOP;
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
/* Now replay the button press event to release our own sync grab. */
maybe_unfreeze_pointer_events (backend, event, EVENTS_UNFREEZE_REPLAY);
#endif
@ -441,7 +441,7 @@ meta_display_handle_event (MetaDisplay *display,
/* We could not match the event with a window, make sure we sync
* the pointer to discard the sequence and don't keep events frozen.
*/
#ifdef HAVE_X11_CLIENT
#ifdef HAVE_X11
maybe_unfreeze_pointer_events (backend, event, EVENTS_UNFREEZE_SYNC);
#endif
}

View file

@ -33,6 +33,10 @@
#pragma once
#ifdef HAVE_X11_CLIENT
#include <X11/Xlib.h>
#endif
#include "core/util-private.h"
#include "meta/display.h"
#include "meta/window.h"

View file

@ -97,7 +97,7 @@ if have_introspection
]
endif
if have_x11
if have_x11_client
mutter_pkg_deps += [
xfixes_dep,
xi_dep,
@ -451,17 +451,17 @@ if have_x11
'backends/x11/nested/meta-stage-x11-nested.h',
'backends/x11/nested/meta-renderer-x11-nested.c',
'backends/x11/nested/meta-renderer-x11-nested.h',
]
endif
if have_x11_client
mutter_sources += [
'compositor/meta-compositor-x11.c',
'compositor/meta-compositor-x11.h',
'compositor/meta-surface-actor-x11.c',
'compositor/meta-surface-actor-x11.h',
'compositor/meta-sync-ring.c',
'compositor/meta-sync-ring.h',
]
endif
if have_x11_client
mutter_sources += [
'compositor/meta-window-actor-x11.c',
'compositor/meta-window-actor-x11.h',
'x11/atomnames.h',

View file

@ -1850,11 +1850,12 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
{
MetaDisplay *display = x11_display->display;
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
Window modified;
gboolean bypass_compositor = FALSE;
XIEvent *input_event;
#ifdef HAVE_X11
MetaCursorTracker *cursor_tracker;
MetaBackend *backend = meta_context_get_backend (context);
#endif
gboolean bypass_compositor G_GNUC_UNUSED = FALSE;
XIEvent *input_event;
#ifdef HAVE_XWAYLAND
MetaWaylandCompositor *wayland_compositor;
#endif
@ -1897,8 +1898,10 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
display->current_time = event_get_time (x11_display, event);
#ifdef HAVE_X11
if (META_IS_BACKEND_X11 (backend))
meta_backend_x11_reset_cached_logical_monitor (META_BACKEND_X11 (backend));
#endif
if (x11_display->focused_by_us &&
event->xany.serial > x11_display->focus_serial &&
@ -1915,6 +1918,7 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
x11_display->is_server_focus = FALSE;
}
#ifdef HAVE_X11
if (event->xany.window == x11_display->xroot)
{
cursor_tracker = meta_backend_get_cursor_tracker (backend);
@ -1930,8 +1934,7 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
}
}
}
modified = event_get_modified_window (x11_display, event);
#endif
input_event = get_input_event (x11_display, event);
@ -1950,11 +1953,15 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
}
out:
#ifdef HAVE_X11
if (!bypass_compositor && META_IS_COMPOSITOR_X11 (display->compositor))
{
MetaCompositorX11 *compositor_x11 =
META_COMPOSITOR_X11 (display->compositor);
MetaWindow *window;
Window modified;
modified = event_get_modified_window (x11_display, event);
if (modified != None)
window = meta_x11_display_lookup_x_window (x11_display, modified);
@ -1963,6 +1970,7 @@ meta_x11_display_handle_xevent (MetaX11Display *x11_display,
meta_compositor_x11_process_xevent (compositor_x11, event, window);
}
#endif /* HAVE_X11 */
display->current_time = META_CURRENT_TIME;

View file

@ -1242,7 +1242,9 @@ meta_x11_display_new (MetaDisplay *display,
if (!xdisplay)
return NULL;
#ifdef HAVE_X11
XSynchronize (xdisplay, meta_context_is_x11_sync (context));
#endif
#ifdef HAVE_XWAYLAND
if (meta_is_wayland_compositor ())
@ -1340,9 +1342,8 @@ meta_x11_display_new (MetaDisplay *display,
x11_display,
G_CONNECT_SWAPPED);
#ifdef HAVE_XWAYLAND
#ifdef HAVE_X11
if (!meta_is_wayland_compositor ())
#endif
{
ClutterStage *stage =
CLUTTER_STAGE (meta_get_stage_for_display (display));
@ -1353,6 +1354,7 @@ meta_x11_display_new (MetaDisplay *display,
x11_display,
G_CONNECT_SWAPPED);
}
#endif
x11_display->xids = g_hash_table_new (meta_unsigned_long_hash,
meta_unsigned_long_equal);
@ -1754,6 +1756,7 @@ update_cursor_theme (MetaX11Display *x11_display)
set_cursor_theme (x11_display->xdisplay, backend);
schedule_reload_x11_cursor (x11_display);
#ifdef HAVE_X11
if (META_IS_BACKEND_X11 (backend))
{
MetaBackendX11 *backend_x11 = META_BACKEND_X11 (backend);
@ -1762,6 +1765,7 @@ update_cursor_theme (MetaX11Display *x11_display)
set_cursor_theme (xdisplay, backend);
meta_backend_x11_reload_cursor (backend_x11);
}
#endif
}
MetaWindow *
@ -1883,7 +1887,7 @@ create_guard_window (MetaX11Display *x11_display)
/* https://bugzilla.gnome.org/show_bug.cgi?id=710346 */
XStoreName (x11_display->xdisplay, guard_window, "mutter guard window");
{
#ifdef HAVE_X11
if (!meta_is_wayland_compositor ())
{
MetaBackendX11 *backend =
@ -1903,7 +1907,7 @@ create_guard_window (MetaX11Display *x11_display)
XISelectEvents (backend_xdisplay, guard_window, &mask, 1);
}
}
#endif
meta_stack_tracker_record_add (x11_display->display->stack_tracker,
guard_window,
@ -2429,6 +2433,7 @@ meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
XRectangle *rects,
int n_rects)
{
#ifdef HAVE_X11
Display *xdisplay = x11_display->xdisplay;
MetaBackend *backend = backend_from_x11_display (x11_display);
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
@ -2447,6 +2452,7 @@ meta_x11_display_set_stage_input_region (MetaX11Display *x11_display,
XFixesSetWindowShapeRegion (xdisplay,
x11_display->composite_overlay_window,
ShapeInput, 0, 0, x11_display->stage_input_region);
#endif
}
/**

View file

@ -21,6 +21,7 @@
#include "meta-x11-keybindings-private.h"
#ifdef HAVE_X11
static GArray *
calc_grab_modifiers (MetaKeyBindingManager *keys,
unsigned int modmask)
@ -55,6 +56,7 @@ calc_grab_modifiers (MetaKeyBindingManager *keys,
return mods_array;
}
#endif
static void
meta_change_button_grab (MetaKeyBindingManager *keys,
@ -64,6 +66,7 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
int button,
int modmask)
{
#ifdef HAVE_X11
MetaBackendX11 *backend;
Display *xdisplay;
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
@ -111,6 +114,7 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
mtk_x11_error_trap_pop (xdisplay);
g_array_free (mods, TRUE);
#endif
}
static void
@ -133,6 +137,7 @@ meta_x11_keybindings_change_keygrab (MetaKeyBindingManager *keys,
gboolean grab,
MetaResolvedKeyCombo *resolved_combo)
{
#ifdef HAVE_X11
MetaBackendX11 *backend_x11;
Display *xdisplay;
GArray *mods;
@ -185,6 +190,7 @@ meta_x11_keybindings_change_keygrab (MetaKeyBindingManager *keys,
mtk_x11_error_trap_pop (xdisplay);
g_array_free (mods, TRUE);
#endif
}
typedef struct

View file

@ -3840,9 +3840,11 @@ is_our_xwindow (MetaX11Display *x11_display,
Window xwindow,
XWindowAttributes *attrs)
{
#ifdef HAVE_X11
MetaDisplay *display;
MetaContext *context;
MetaBackend *backend;
#endif
if (xwindow == x11_display->no_focus_window)
return TRUE;
@ -3859,6 +3861,7 @@ is_our_xwindow (MetaX11Display *x11_display,
if (xwindow == x11_display->composite_overlay_window)
return TRUE;
#ifdef HAVE_X11
display = meta_x11_display_get_display (x11_display);
context = meta_display_get_context (display);
backend = meta_context_get_backend (context);
@ -3866,6 +3869,7 @@ is_our_xwindow (MetaX11Display *x11_display,
if (META_IS_BACKEND_X11 (backend) &&
xwindow == meta_backend_x11_get_xwindow (META_BACKEND_X11 (backend)))
return TRUE;
#endif
/* Any windows created via meta_create_offscreen_window */
if (attrs->override_redirect &&