backends: Move most of the code from meta_backend_init into the subclasses
This commit is contained in:
parent
31d744195d
commit
48dc544bef
@ -26,17 +26,13 @@
|
|||||||
|
|
||||||
#include "meta-backend.h"
|
#include "meta-backend.h"
|
||||||
#include "meta-backend-private.h"
|
#include "meta-backend-private.h"
|
||||||
#include <meta/main.h>
|
|
||||||
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <clutter/x11/clutter-x11.h>
|
|
||||||
|
|
||||||
#include "backends/x11/meta-backend-x11.h"
|
#include "backends/x11/meta-backend-x11.h"
|
||||||
#include "backends/native/meta-backend-native.h"
|
#include "backends/native/meta-backend-native.h"
|
||||||
|
|
||||||
#include "backends/native/meta-weston-launch.h"
|
#include "backends/native/meta-weston-launch.h"
|
||||||
#include <meta/util.h>
|
|
||||||
|
|
||||||
static MetaBackend *_backend;
|
static MetaBackend *_backend;
|
||||||
|
|
||||||
@ -181,8 +177,6 @@ static GSourceFuncs event_funcs = {
|
|||||||
event_dispatch
|
event_dispatch
|
||||||
};
|
};
|
||||||
|
|
||||||
static MetaLauncher *launcher;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_clutter_init (void)
|
meta_clutter_init (void)
|
||||||
{
|
{
|
||||||
@ -190,31 +184,6 @@ meta_clutter_init (void)
|
|||||||
|
|
||||||
meta_create_backend ();
|
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)
|
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
|
||||||
g_error ("Unable to initialize Clutter.\n");
|
g_error ("Unable to initialize Clutter.\n");
|
||||||
|
|
||||||
@ -222,37 +191,3 @@ meta_clutter_init (void)
|
|||||||
g_source_attach (source, NULL);
|
g_source_attach (source, NULL);
|
||||||
g_source_unref (source);
|
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;
|
|
||||||
}
|
|
||||||
|
@ -41,6 +41,4 @@ MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
|
|||||||
|
|
||||||
void meta_clutter_init (void);
|
void meta_clutter_init (void);
|
||||||
|
|
||||||
gboolean meta_activate_vt (int vt, GError **error);
|
|
||||||
|
|
||||||
#endif /* META_BACKEND_H */
|
#endif /* META_BACKEND_H */
|
||||||
|
@ -24,11 +24,19 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <meta/main.h>
|
||||||
#include "meta-backend-native.h"
|
#include "meta-backend-native.h"
|
||||||
|
|
||||||
#include "meta-idle-monitor-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 *
|
static MetaIdleMonitor *
|
||||||
meta_backend_native_create_idle_monitor (MetaBackend *backend,
|
meta_backend_native_create_idle_monitor (MetaBackend *backend,
|
||||||
@ -50,4 +58,48 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
|||||||
static void
|
static void
|
||||||
meta_backend_native_init (MetaBackendNative *native)
|
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;
|
||||||
}
|
}
|
||||||
|
@ -49,4 +49,6 @@ struct _MetaBackendNativeClass
|
|||||||
|
|
||||||
GType meta_backend_native_get_type (void) G_GNUC_CONST;
|
GType meta_backend_native_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
gboolean meta_activate_vt (int vt, GError **error);
|
||||||
|
|
||||||
#endif /* META_BACKEND_NATIVE_H */
|
#endif /* META_BACKEND_NATIVE_H */
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
#include "meta-backend-x11.h"
|
#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"
|
#include "meta-idle-monitor-xsync.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
|
G_DEFINE_TYPE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
|
||||||
@ -50,6 +54,23 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
|
|||||||
static void
|
static void
|
||||||
meta_backend_x11_init (MetaBackendX11 *x11)
|
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
|
void
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wayland/meta-wayland.h"
|
#include "wayland/meta-wayland.h"
|
||||||
#include "meta-backend.h"
|
#include "backends/native/meta-backend-native.h"
|
||||||
|
|
||||||
#define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings"
|
#define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings"
|
||||||
#define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings"
|
#define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user