diff --git a/configure.ac b/configure.ac index 246314058..61f67e26a 100644 --- a/configure.ac +++ b/configure.ac @@ -79,12 +79,9 @@ MUTTER_PC_MODULES=" xcomposite >= 0.2 xfixes xext xdamage xi >= 1.6.0 xcursor $CLUTTER_PACKAGE >= 1.19.5 - clutter-wayland-1.0 - clutter-wayland-compositor-1.0 clutter-egl-1.0 cogl-1.0 >= 1.17.1 libinput - wayland-server >= 1.5.90 upower-glib >= 0.99.0 gnome-desktop-3.0 xkbfile @@ -202,6 +199,12 @@ if test $have_native_backend = yes; then fi AM_CONDITIONAL([HAVE_NATIVE_BACKEND],[test $have_native_backend = yes]) +PKG_CHECK_MODULES(MUTTER_WAYLAND, [clutter-wayland-1.0 clutter-wayland-compositor-1.0 wayland-server >= 1.5.90], [have_wayland=yes], [have_wayland=no]) +if test $have_wayland = yes; then + AC_DEFINE([HAVE_WAYLAND],[1],[Define if you want to enable Wayland support]) +fi +AM_CONDITIONAL([HAVE_WAYLAND],[test $have_wayland = yes]) + PKG_CHECK_EXISTS([xi >= 1.6.99.1], AC_DEFINE([HAVE_XI23],[1],[Define if you have support for XInput 2.3 or greater])) diff --git a/src/Makefile.am b/src/Makefile.am index f6b0c0909..a0146fc49 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -115,8 +115,6 @@ libmutter_la_SOURCES = \ compositor/meta-surface-actor.h \ compositor/meta-surface-actor-x11.c \ compositor/meta-surface-actor-x11.h \ - compositor/meta-surface-actor-wayland.c \ - compositor/meta-surface-actor-wayland.h \ compositor/meta-texture-rectangle.c \ compositor/meta-texture-rectangle.h \ compositor/meta-texture-tower.c \ @@ -212,7 +210,12 @@ libmutter_la_SOURCES = \ x11/window-x11-private.h \ x11/xprops.c \ x11/xprops.h \ - x11/mutter-Xatomtype.h \ + x11/mutter-Xatomtype.h + +if HAVE_WAYLAND +libmutter_la_SOURCES += \ + compositor/meta-surface-actor-wayland.c \ + compositor/meta-surface-actor-wayland.h \ wayland/meta-wayland.c \ wayland/meta-wayland.h \ wayland/meta-wayland-private.h \ @@ -237,6 +240,7 @@ libmutter_la_SOURCES = \ wayland/meta-wayland-outputs.h \ wayland/window-wayland.c \ wayland/window-wayland.h +endif if HAVE_NATIVE_BACKEND libmutter_la_SOURCES += \ diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index 3d1f85718..67f92e597 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -31,7 +31,6 @@ #include #include -#include #include #include "meta-stage.h" diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c index 1b231316a..905b5d19f 100644 --- a/src/backends/meta-cursor-tracker.c +++ b/src/backends/meta-cursor-tracker.c @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c index 3d88b6815..592e26f32 100644 --- a/src/backends/meta-cursor.c +++ b/src/backends/meta-cursor.c @@ -39,7 +39,9 @@ #include #include +#ifdef HAVE_WAYLAND #include +#endif MetaCursorReference * meta_cursor_reference_ref (MetaCursorReference *self) @@ -247,6 +249,7 @@ meta_cursor_reference_from_theme (MetaCursor cursor) return self; } +#ifdef HAVE_WAYLAND static void meta_cursor_image_load_from_buffer (MetaCursorImage *image, struct wl_resource *buffer, @@ -345,6 +348,7 @@ meta_cursor_reference_from_buffer (struct wl_resource *buffer, return self; } +#endif CoglTexture * meta_cursor_reference_get_cogl_texture (MetaCursorReference *cursor, diff --git a/src/backends/meta-cursor.h b/src/backends/meta-cursor.h index e9e12907e..b627dc0cc 100644 --- a/src/backends/meta-cursor.h +++ b/src/backends/meta-cursor.h @@ -28,13 +28,15 @@ MetaCursorReference * meta_cursor_reference_ref (MetaCursorReference *cursor); void meta_cursor_reference_unref (MetaCursorReference *cursor); #include -#include MetaCursorReference * meta_cursor_reference_from_theme (MetaCursor cursor); +#ifdef HAVE_WAYLAND +#include MetaCursorReference * meta_cursor_reference_from_buffer (struct wl_resource *buffer, int hot_x, int hot_y); +#endif MetaCursor meta_cursor_reference_get_meta_cursor (MetaCursorReference *cursor); diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c index 70454bb01..2333bee6a 100644 --- a/src/backends/native/meta-launcher.c +++ b/src/backends/native/meta-launcher.c @@ -41,7 +41,6 @@ #include "dbus-utils.h" #include "meta-dbus-login1.h" -#include "wayland/meta-wayland-private.h" #include "backends/meta-backend-private.h" #include "meta-cursor-renderer-native.h" diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index a887c0657..4843deacc 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -396,8 +396,10 @@ after_stage_paint (ClutterStage *stage, for (l = compositor->windows; l; l = l->next) meta_window_actor_post_paint (l->data); +#ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) meta_wayland_compositor_paint_finished (meta_wayland_compositor_get_default ()); +#endif } static void diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index f5ea1283a..4347a057f 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -32,7 +32,10 @@ #include "meta-surface-actor.h" #include "meta-surface-actor-x11.h" + +#ifdef HAVE_WAYLAND #include "meta-surface-actor-wayland.h" +#endif #include "wayland/meta-wayland-surface.h" @@ -596,6 +599,7 @@ meta_window_actor_get_shape_bounds (MetaWindowActor *self, cairo_region_get_extents (priv->shape_region, bounds); +#ifdef HAVE_WAYLAND if (META_IS_SURFACE_ACTOR_WAYLAND (priv->surface)) { double scale = priv->surface ? @@ -605,6 +609,7 @@ meta_window_actor_get_shape_bounds (MetaWindowActor *self, bounds->width *= scale; bounds->height *= scale; } +#endif } static void diff --git a/src/core/display.c b/src/core/display.c index b6bfad260..e99a6d6ad 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -70,7 +70,9 @@ #include "x11/group-props.h" #include "x11/xprops.h" +#ifdef HAVE_WAYLAND #include "wayland/meta-xwayland-private.h" +#endif /* * SECTION:pings @@ -468,6 +470,7 @@ meta_set_gnome_wm_keybindings (const char *wm_keybindings) void meta_display_cancel_touch (MetaDisplay *display) { +#ifdef HAVE_WAYLAND MetaWaylandCompositor *compositor; if (!meta_is_wayland_compositor ()) @@ -475,6 +478,7 @@ meta_display_cancel_touch (MetaDisplay *display) compositor = meta_wayland_compositor_get_default (); meta_wayland_touch_cancel (&compositor->seat->touch); +#endif } static void @@ -545,8 +549,10 @@ meta_display_open (void) return FALSE; } +#ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) meta_xwayland_complete_init (); +#endif if (meta_is_syncing ()) XSynchronize (xdisplay, True); @@ -1436,6 +1442,7 @@ meta_display_queue_autoraise_callback (MetaDisplay *display, void meta_display_sync_wayland_input_focus (MetaDisplay *display) { +#ifdef HAVE_WAYLAND MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); MetaWindow *focus_window = NULL; @@ -1451,6 +1458,7 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display) meta_wayland_compositor_set_input_focus (compositor, focus_window); meta_wayland_seat_repick (compositor->seat); +#endif } void diff --git a/src/core/events.c b/src/core/events.c index 040813a5a..e456be2e6 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -35,7 +35,9 @@ #endif #include "x11/events.h" +#ifdef HAVE_WAYLAND #include "wayland/meta-wayland-private.h" +#endif #include "meta-surface-actor.h" static MetaWindow * @@ -162,17 +164,20 @@ meta_display_handle_event (MetaDisplay *display, const ClutterEvent *event) { MetaWindow *window; - gboolean bypass_clutter = FALSE, bypass_wayland = FALSE; - MetaWaylandCompositor *compositor = NULL; + gboolean bypass_clutter = FALSE; + G_GNUC_UNUSED gboolean bypass_wayland = FALSE; MetaGestureTracker *tracker; meta_display_update_pointer_emulating_sequence (display, event); +#ifdef HAVE_WAYLAND + MetaWaylandCompositor *compositor = NULL; if (meta_is_wayland_compositor ()) { compositor = meta_wayland_compositor_get_default (); meta_wayland_compositor_update (compositor, event); } +#endif handle_idletime_for_event (event); @@ -281,11 +286,13 @@ meta_display_handle_event (MetaDisplay *display, if (display->grab_op == META_GRAB_OP_WAYLAND_POPUP) bypass_clutter = TRUE; +#ifdef HAVE_WAYLAND if (compositor && !bypass_wayland) { if (meta_wayland_compositor_handle_event (compositor, event)) bypass_clutter = TRUE; } +#endif display->current_time = CurrentTime; return bypass_clutter; diff --git a/src/core/main.c b/src/core/main.c index d327a8ed6..bcf1ffac2 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -78,7 +78,9 @@ #include "x11/session.h" +#ifdef HAVE_WAYLAND #include "wayland/meta-wayland.h" +#endif /* * The exit code we'll return to our parent process when we eventually die. @@ -160,7 +162,9 @@ static gchar *opt_client_id; static gboolean opt_replace_wm; static gboolean opt_disable_sm; static gboolean opt_sync; +#ifdef HAVE_WAYLAND static gboolean opt_wayland; +#endif #ifdef HAVE_NATIVE_BACKEND static gboolean opt_display_server; #endif @@ -201,12 +205,14 @@ static GOptionEntry meta_options[] = { N_("Make X calls synchronous"), NULL }, +#ifdef HAVE_WAYLAND { "wayland", 0, 0, G_OPTION_ARG_NONE, &opt_wayland, N_("Run as a wayland compositor"), NULL }, +#endif #ifdef HAVE_NATIVE_BACKEND { "display-server", 0, 0, G_OPTION_ARG_NONE, @@ -271,8 +277,10 @@ meta_finalize (void) meta_display_close (display, CurrentTime); /* I doubt correct timestamps matter here */ +#ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) meta_wayland_finalize (); +#endif } static gboolean @@ -323,7 +331,9 @@ meta_init (void) #endif clutter_set_windowing_backend (CLUTTER_WINDOWING_X11); +#ifdef HAVE_WAYLAND meta_set_is_wayland_compositor (opt_wayland); +#endif if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) @@ -336,6 +346,7 @@ meta_init (void) g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); #endif +#ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) { /* NB: When running as a hybrid wayland compositor we run our own headless X @@ -343,6 +354,7 @@ meta_init (void) meta_wayland_init (); } else +#endif meta_select_display (opt_display_name); meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL)); diff --git a/src/core/window.c b/src/core/window.c index 2a45f951a..45638c843 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -49,14 +49,17 @@ #include #include +#include #include "meta/compositor-mutter.h" #include "x11/window-x11.h" #include "x11/window-props.h" #include "x11/xprops.h" +#ifdef HAVE_WAYLAND #include "wayland/window-wayland.h" #include "wayland/meta-wayland-private.h" +#endif #include "backends/meta-backend-private.h" @@ -779,8 +782,12 @@ _meta_window_shared_new (MetaDisplay *display, if (client_type == META_WINDOW_CLIENT_TYPE_X11) window = g_object_new (META_TYPE_WINDOW_X11, NULL); - else +#ifdef HAVE_WAYLAND + else if (client_type == META_WINDOW_CLIENT_TYPE_WAYLAND) window = g_object_new (META_TYPE_WINDOW_WAYLAND, NULL); +#endif + else + g_assert_not_reached (); window->constructing = TRUE; @@ -1221,6 +1228,7 @@ meta_window_unmanage (MetaWindow *window, meta_verbose ("Unmanaging %s\n", window->desc); +#ifdef HAVE_WAYLAND /* This needs to happen for both Wayland and XWayland clients, * so it can't be in MetaWindowWayland. */ if (window->surface) @@ -1228,6 +1236,7 @@ meta_window_unmanage (MetaWindow *window, meta_wayland_surface_set_window (window->surface, NULL); window->surface = NULL; } +#endif if (window->visible_to_compositor) { @@ -2434,8 +2443,10 @@ meta_window_show (MetaWindow *window) if (did_show) meta_screen_queue_check_fullscreen (window->screen); +#ifdef HAVE_WAYLAND if (did_show && window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND) meta_wayland_compositor_repick (meta_wayland_compositor_get_default ()); +#endif /* * Now that we have shown the window, we no longer want to consider the diff --git a/src/x11/events.c b/src/x11/events.c index 869e40cc0..5b8659a4a 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -1448,12 +1448,15 @@ handle_other_xevent (MetaDisplay *display, case ClientMessage: if (window) { +#ifdef HAVE_WAYLAND if (event->xclient.message_type == display->atom_WL_SURFACE_ID) { guint32 surface_id = event->xclient.data.l[0]; meta_xwayland_handle_wl_surface_id (window, surface_id); } - else if (!frame_was_receiver) + else +#endif + if (!frame_was_receiver) meta_window_x11_client_message (window, event); } else