summaryrefslogtreecommitdiff
path: root/src/backends
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-04-21 19:47:04 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2014-04-21 20:25:21 -0400
commit48dc544beff407b5502fae32c3259d87c8e31b0c (patch)
tree1224c78c850a9dcd52c609d0938fe60848254473 /src/backends
parent31d744195d8cb5f7366326c3990cf84f83bf6a6c (diff)
downloadmutter-48dc544beff407b5502fae32c3259d87c8e31b0c.tar.gz
backends: Move most of the code from meta_backend_init into the subclasses
Diffstat (limited to 'src/backends')
-rw-r--r--src/backends/meta-backend.c65
-rw-r--r--src/backends/meta-backend.h2
-rw-r--r--src/backends/native/meta-backend-native.c54
-rw-r--r--src/backends/native/meta-backend-native.h2
-rw-r--r--src/backends/x11/meta-backend-x11.c21
5 files changed, 76 insertions, 68 deletions
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 5f2f03a17..0cf95c7aa 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -26,17 +26,13 @@
#include "meta-backend.h"
#include "meta-backend-private.h"
-#include <meta/main.h>
-#include <gdk/gdkx.h>
#include <clutter/clutter.h>
-#include <clutter/x11/clutter-x11.h>
#include "backends/x11/meta-backend-x11.h"
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-weston-launch.h"
-#include <meta/util.h>
static MetaBackend *_backend;
@@ -181,8 +177,6 @@ static GSourceFuncs event_funcs = {
event_dispatch
};
-static MetaLauncher *launcher;
-
void
meta_clutter_init (void)
{
@@ -190,31 +184,6 @@ meta_clutter_init (void)
meta_create_backend ();
- /* When running as an X11 compositor, we install our own event filter and
- * pass events to Clutter explicitly, so we need to prevent Clutter from
- * handling our events.
- *
- * However, when running as a Wayland compostior under X11 nested, Clutter
- * Clutter needs to see events related to its own window. We need to
- * eventually replace this with a proper frontend / backend split: Clutter
- * under nested is connecting to the "host X server" to get its events it
- * needs to put up a window, and GTK+ is connecting to the "inner X server".
- * The two would the same in the X11 compositor case, but not when running
- * XWayland as a Wayland compositor.
- */
- if (!meta_is_wayland_compositor ())
- {
- 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");
@@ -222,37 +191,3 @@ 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 021e235b0..7047c5e09 100644
--- a/src/backends/meta-backend.h
+++ b/src/backends/meta-backend.h
@@ -41,6 +41,4 @@ MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
void meta_clutter_init (void);
-gboolean meta_activate_vt (int vt, GError **error);
-
#endif /* META_BACKEND_H */
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 5e6ec7cfa..01ce26de3 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -24,11 +24,19 @@
#include "config.h"
+#include <meta/main.h>
#include "meta-backend-native.h"
#include "meta-idle-monitor-native.h"
+#include "meta-weston-launch.h"
-G_DEFINE_TYPE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND);
+struct _MetaBackendNativePrivate
+{
+ MetaLauncher *launcher;
+};
+typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND);
static MetaIdleMonitor *
meta_backend_native_create_idle_monitor (MetaBackend *backend,
@@ -50,4 +58,48 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
static void
meta_backend_native_init (MetaBackendNative *native)
{
+ MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
+
+ /* We're a display server, so start talking to weston-launch. */
+ priv->launcher = meta_launcher_new ();
+}
+
+gboolean
+meta_activate_vt (int vt, GError **error)
+{
+ MetaBackend *backend = meta_get_backend ();
+ MetaBackendNative *native = META_BACKEND_NATIVE (backend);
+ MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
+
+ return meta_launcher_activate_vt (priv->launcher, vt, error);
+}
+
+/**
+ * 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;
+ MetaBackend *backend = meta_get_backend ();
+
+ /* Do nothing. */
+ if (!META_IS_BACKEND_NATIVE (backend))
+ return TRUE;
+
+ MetaBackendNative *native = META_BACKEND_NATIVE (backend);
+ MetaBackendNativePrivate *priv = meta_backend_native_get_instance_private (native);
+
+ if (!meta_launcher_activate_vt (priv->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/native/meta-backend-native.h b/src/backends/native/meta-backend-native.h
index 4ee6efc31..64a494b04 100644
--- a/src/backends/native/meta-backend-native.h
+++ b/src/backends/native/meta-backend-native.h
@@ -49,4 +49,6 @@ struct _MetaBackendNativeClass
GType meta_backend_native_get_type (void) G_GNUC_CONST;
+gboolean meta_activate_vt (int vt, GError **error);
+
#endif /* META_BACKEND_NATIVE_H */
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 35e8416a2..61de4443d 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -26,6 +26,10 @@
#include "meta-backend-x11.h"
+#include <gdk/gdkx.h>
+#include <clutter/x11/clutter-x11.h>
+
+#include <meta/util.h>
#include "meta-idle-monitor-xsync.h"
G_DEFINE_TYPE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
@@ -50,6 +54,23 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
static void
meta_backend_x11_init (MetaBackendX11 *x11)
{
+ /* When running as an X11 compositor, we install our own event filter and
+ * pass events to Clutter explicitly, so we need to prevent Clutter from
+ * handling our events.
+ *
+ * However, when running as a Wayland compostior under X11 nested, Clutter
+ * Clutter needs to see events related to its own window. We need to
+ * eventually replace this with a proper frontend / backend split: Clutter
+ * under nested is connecting to the "host X server" to get its events it
+ * needs to put up a window, and GTK+ is connecting to the "inner X server".
+ * The two would the same in the X11 compositor case, but not when running
+ * XWayland as a Wayland compositor.
+ */
+ if (!meta_is_wayland_compositor ())
+ {
+ clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+ clutter_x11_disable_event_retrieval ();
+ }
}
void