diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index b4de3f674..f464425b3 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -25,11 +25,14 @@ #include "config.h" #include "meta-backend.h" +#include #include #include #include +#include "meta-weston-launch.h" + /* Mutter is responsible for pulling events off the X queue, so Clutter * doesn't need (and shouldn't) run its normal event source which polls * the X fd, but we do have to deal with dispatching events that accumulate @@ -78,6 +81,8 @@ static GSourceFuncs event_funcs = { event_dispatch }; +static MetaLauncher *launcher; + void meta_clutter_init (void) { @@ -86,6 +91,13 @@ meta_clutter_init (void) clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); clutter_x11_disable_event_retrieval (); + /* If we're running on bare metal, we're a display server, + * so start talking to weston-launch. */ +#if defined(CLUTTER_WINDOWING_EGL) + if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL)) + launcher = meta_launcher_new (); +#endif + if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) g_error ("Unable to initialize Clutter.\n"); @@ -93,3 +105,37 @@ meta_clutter_init (void) g_source_attach (source, NULL); g_source_unref (source); } + +gboolean +meta_activate_vt (int vt, GError **error) +{ + if (launcher) + return meta_launcher_activate_vt (launcher, vt, error); + else + { + g_debug ("Ignoring VT switch keybinding, not running as display server"); + return TRUE; + } +} + +/** + * meta_activate_session: + * + * Tells mutter to activate the session. When mutter is a + * Wayland compositor, this tells logind to switch over to + * the new session. + */ +gboolean +meta_activate_session (void) +{ + GError *error = NULL; + + if (!meta_launcher_activate_vt (launcher, -1, &error)) + { + g_warning ("Could not activate session: %s\n", error->message); + g_error_free (error); + return FALSE; + } + + return TRUE; +} diff --git a/src/backends/meta-backend.h b/src/backends/meta-backend.h index 4c4ee1fc3..03d8a5633 100644 --- a/src/backends/meta-backend.h +++ b/src/backends/meta-backend.h @@ -25,6 +25,10 @@ #ifndef META_BACKEND_H #define META_BACKEND_H +#include + void meta_clutter_init (void); +gboolean meta_activate_vt (int vt, GError **error); + #endif /* META_BACKEND_H */ diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 8f787b78d..e663311fb 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -52,6 +52,7 @@ #endif #include "wayland/meta-wayland.h" +#include "meta-backend.h" #define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings" #define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings" @@ -3181,10 +3182,9 @@ handle_switch_vt (MetaDisplay *display, gpointer dummy) { gint vt = binding->handler->data; - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); GError *error = NULL; - if (!meta_wayland_compositor_activate_vt (compositor, vt, &error)) + if (!meta_activate_vt (vt, &error)) { g_warning ("Failed to switch VT: %s", error->message); g_error_free (error); diff --git a/src/core/main.c b/src/core/main.c index c0aeeb651..a3d000e0a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -437,32 +437,6 @@ meta_register_with_session (void) g_free (opt_client_id); } -/** - * meta_activate_session: - * - * Tells mutter to activate the session. When mutter is a - * Wayland compositor, this tells logind to switch over to - * the new session. - */ -gboolean -meta_activate_session (void) -{ - if (meta_is_wayland_compositor ()) - { - MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); - GError *error = NULL; - - if (!meta_wayland_compositor_activate_session (compositor, &error)) - { - g_warning ("Could not activate session: %s\n", error->message); - g_error_free (error); - return FALSE; - } - } - - return TRUE; -} - /** * meta_run: (skip) * diff --git a/src/meta/main.h b/src/meta/main.h index 9a748099e..82f05a018 100644 --- a/src/meta/main.h +++ b/src/meta/main.h @@ -28,7 +28,7 @@ GOptionContext *meta_get_option_context (void); void meta_init (void); int meta_run (void); void meta_register_with_session (void); -gboolean meta_activate_session (void); +gboolean meta_activate_session (void); /* Actually defined in meta-backend.c */ gboolean meta_get_replace_current_wm (void); /* Actually defined in util.c */ void meta_set_wm_name (const char *wm_name); diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index a2a2b90a5..d575e2f0c 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -27,7 +27,6 @@ #include #include "window-private.h" -#include "meta-weston-launch.h" #include #include "meta-wayland.h" @@ -85,8 +84,6 @@ struct _MetaWaylandCompositor MetaXWaylandManager xwayland_manager; - MetaLauncher *launcher; - MetaWaylandSeat *seat; }; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index 2e5635321..1d9be56ad 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -53,7 +53,6 @@ #include #include #include "frame.h" -#include "meta-weston-launch.h" #include "meta-monitor-manager.h" static MetaWaylandCompositor _meta_wayland_compositor; @@ -629,13 +628,6 @@ meta_wayland_init (void) clutter_wayland_set_compositor_display (compositor->wayland_display); - /* If we're running on bare metal, we're a display server, - * so start talking to weston-launch. */ -#if defined(CLUTTER_WINDOWING_EGL) - if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL)) - compositor->launcher = meta_launcher_new (); -#endif - meta_clutter_init (); meta_monitor_manager_initialize (); @@ -688,38 +680,4 @@ meta_wayland_finalize (void) compositor = meta_wayland_compositor_get_default (); meta_xwayland_stop (&compositor->xwayland_manager); - - if (compositor->launcher) - meta_launcher_free (compositor->launcher); -} - -gboolean -meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor, - int vt, - GError **error) -{ - if (compositor->launcher) - { - return meta_launcher_activate_vt (compositor->launcher, vt, error); - } - else - { - g_debug ("Ignoring VT switch keybinding, not running as display server"); - return TRUE; - } -} - -gboolean -meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor, - GError **error) -{ - if (compositor->launcher) - { - return meta_launcher_activate_vt (compositor->launcher, -1, error); - } - else - { - g_debug ("Ignoring activate_session, not running as display server"); - return TRUE; - } } diff --git a/src/wayland/meta-wayland.h b/src/wayland/meta-wayland.h index 81bb2e535..4f12660d9 100644 --- a/src/wayland/meta-wayland.h +++ b/src/wayland/meta-wayland.h @@ -43,11 +43,5 @@ void meta_wayland_compositor_update (MetaWaylandComp const ClutterEvent *event); void meta_wayland_compositor_paint_finished (MetaWaylandCompositor *compositor); -gboolean meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor, - int vt, - GError **error); -gboolean meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor, - GError **error); - #endif