mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
core: Add private API to override compositor configuration
Add private API for overriding the compositor configuration, i.e. the compositor type (X11 WM or Wayland compositor) and backend type. This will make it possible to add a special test backend used by src/tests/. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
bc5077f623
commit
d3920ddb67
@ -97,7 +97,7 @@ struct _MetaBackendClass
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void meta_init_backend (MetaBackendType backend_type);
|
void meta_init_backend (GType backend_gtype);
|
||||||
|
|
||||||
ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
|
ClutterBackend * meta_backend_get_clutter_backend (MetaBackend *backend);
|
||||||
|
|
||||||
|
@ -796,31 +796,14 @@ meta_get_clutter_backend (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_init_backend (MetaBackendType backend_type)
|
meta_init_backend (GType backend_gtype)
|
||||||
{
|
{
|
||||||
GType type;
|
|
||||||
MetaBackend *backend;
|
MetaBackend *backend;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
switch (backend_type)
|
|
||||||
{
|
|
||||||
case META_BACKEND_TYPE_X11:
|
|
||||||
type = META_TYPE_BACKEND_X11;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef HAVE_NATIVE_BACKEND
|
|
||||||
case META_BACKEND_TYPE_NATIVE:
|
|
||||||
type = META_TYPE_BACKEND_NATIVE;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* meta_backend_init() above install the backend globally so
|
/* meta_backend_init() above install the backend globally so
|
||||||
* so meta_get_backend() works even during initialization. */
|
* so meta_get_backend() works even during initialization. */
|
||||||
backend = g_object_new (type, NULL);
|
backend = g_object_new (backend_gtype, NULL);
|
||||||
if (!g_initable_init (G_INITABLE (backend), NULL, &error))
|
if (!g_initable_init (G_INITABLE (backend), NULL, &error))
|
||||||
{
|
{
|
||||||
g_warning ("Failed to create backend: %s", error->message);
|
g_warning ("Failed to create backend: %s", error->message);
|
||||||
|
34
src/core/main-private.h
Normal file
34
src/core/main-private.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_MAIN_PRIVATE_H
|
||||||
|
#define META_MAIN_PRIVATE_H
|
||||||
|
|
||||||
|
typedef enum _MetaCompositorType
|
||||||
|
{
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
META_COMPOSITOR_TYPE_WAYLAND,
|
||||||
|
#endif
|
||||||
|
META_COMPOSITOR_TYPE_X11,
|
||||||
|
} MetaCompositorType;
|
||||||
|
|
||||||
|
void meta_override_compositor_configuration (MetaCompositorType compositor_type,
|
||||||
|
GType backend_gtype);
|
||||||
|
|
||||||
|
#endif /* META_MAIN_PRIVATE_H */
|
@ -52,6 +52,7 @@
|
|||||||
#include <meta/prefs.h>
|
#include <meta/prefs.h>
|
||||||
#include <meta/compositor.h>
|
#include <meta/compositor.h>
|
||||||
#include <meta/meta-backend.h>
|
#include <meta/meta-backend.h>
|
||||||
|
#include "core/main-private.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <glib-unix.h>
|
#include <glib-unix.h>
|
||||||
@ -82,10 +83,14 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
|
#include "backends/x11/meta-backend-x11.h"
|
||||||
|
|
||||||
#if defined(HAVE_NATIVE_BACKEND) && defined(HAVE_WAYLAND)
|
#ifdef HAVE_NATIVE_BACKEND
|
||||||
|
#include "backends/native/meta-backend-native.h"
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
#include <systemd/sd-login.h>
|
#include <systemd/sd-login.h>
|
||||||
#endif
|
#endif /* HAVE_WAYLAND */
|
||||||
|
#endif /* HAVE_NATIVE_BACKEND */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The exit code we'll return to our parent process when we eventually die.
|
* The exit code we'll return to our parent process when we eventually die.
|
||||||
@ -394,7 +399,7 @@ check_for_wayland_session_type (void)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
calculate_compositor_configuration (MetaCompositorType *compositor_type,
|
calculate_compositor_configuration (MetaCompositorType *compositor_type,
|
||||||
MetaBackendType *backend_type)
|
GType *backend_gtype)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
gboolean run_as_wayland_compositor = opt_wayland;
|
gboolean run_as_wayland_compositor = opt_wayland;
|
||||||
@ -411,12 +416,12 @@ calculate_compositor_configuration (MetaCompositorType *compositor_type,
|
|||||||
|
|
||||||
#ifdef CLUTTER_WINDOWING_EGL
|
#ifdef CLUTTER_WINDOWING_EGL
|
||||||
if (opt_display_server || (run_as_wayland_compositor && !opt_nested))
|
if (opt_display_server || (run_as_wayland_compositor && !opt_nested))
|
||||||
*backend_type = META_BACKEND_TYPE_NATIVE;
|
*backend_gtype = META_TYPE_BACKEND_NATIVE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
*backend_type = META_BACKEND_TYPE_X11;
|
*backend_gtype = META_TYPE_BACKEND_X11;
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
if (run_as_wayland_compositor)
|
if (run_as_wayland_compositor)
|
||||||
@ -426,6 +431,19 @@ calculate_compositor_configuration (MetaCompositorType *compositor_type,
|
|||||||
*compositor_type = META_COMPOSITOR_TYPE_X11;
|
*compositor_type = META_COMPOSITOR_TYPE_X11;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean _compositor_configuration_overridden = FALSE;
|
||||||
|
static MetaCompositorType _compositor_type_override;
|
||||||
|
static GType _backend_gtype_override;
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_override_compositor_configuration (MetaCompositorType compositor_type,
|
||||||
|
GType backend_gtype)
|
||||||
|
{
|
||||||
|
_compositor_configuration_overridden = TRUE;
|
||||||
|
_compositor_type_override = compositor_type;
|
||||||
|
_backend_gtype_override = backend_gtype;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_init: (skip)
|
* meta_init: (skip)
|
||||||
*
|
*
|
||||||
@ -438,7 +456,7 @@ meta_init (void)
|
|||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
sigset_t empty_mask;
|
sigset_t empty_mask;
|
||||||
MetaCompositorType compositor_type;
|
MetaCompositorType compositor_type;
|
||||||
MetaBackendType backend_type;
|
GType backend_gtype;
|
||||||
|
|
||||||
sigemptyset (&empty_mask);
|
sigemptyset (&empty_mask);
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
@ -460,7 +478,15 @@ meta_init (void)
|
|||||||
if (g_getenv ("MUTTER_DEBUG"))
|
if (g_getenv ("MUTTER_DEBUG"))
|
||||||
meta_set_debugging (TRUE);
|
meta_set_debugging (TRUE);
|
||||||
|
|
||||||
calculate_compositor_configuration (&compositor_type, &backend_type);
|
if (_compositor_configuration_overridden)
|
||||||
|
{
|
||||||
|
compositor_type = _compositor_type_override;
|
||||||
|
backend_gtype = _backend_gtype_override;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calculate_compositor_configuration (&compositor_type, &backend_gtype);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_WAYLAND
|
#ifdef HAVE_WAYLAND
|
||||||
if (compositor_type == META_COMPOSITOR_TYPE_WAYLAND)
|
if (compositor_type == META_COMPOSITOR_TYPE_WAYLAND)
|
||||||
@ -488,7 +514,7 @@ meta_init (void)
|
|||||||
if (!meta_is_wayland_compositor ())
|
if (!meta_is_wayland_compositor ())
|
||||||
meta_select_display (opt_display_name);
|
meta_select_display (opt_display_name);
|
||||||
|
|
||||||
meta_init_backend (backend_type);
|
meta_init_backend (backend_gtype);
|
||||||
|
|
||||||
meta_clutter_init ();
|
meta_clutter_init ();
|
||||||
|
|
||||||
|
@ -28,22 +28,6 @@
|
|||||||
#include <meta/util.h>
|
#include <meta/util.h>
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
|
|
||||||
typedef enum _MetaCompositorType
|
|
||||||
{
|
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
META_COMPOSITOR_TYPE_WAYLAND,
|
|
||||||
#endif
|
|
||||||
META_COMPOSITOR_TYPE_X11,
|
|
||||||
} MetaCompositorType;
|
|
||||||
|
|
||||||
typedef enum _MetaBackendType
|
|
||||||
{
|
|
||||||
#ifdef HAVE_NATIVE_BACKEND
|
|
||||||
META_BACKEND_TYPE_NATIVE,
|
|
||||||
#endif
|
|
||||||
META_BACKEND_TYPE_X11,
|
|
||||||
} MetaBackendType;
|
|
||||||
|
|
||||||
void meta_set_verbose (gboolean setting);
|
void meta_set_verbose (gboolean setting);
|
||||||
void meta_set_debugging (gboolean setting);
|
void meta_set_debugging (gboolean setting);
|
||||||
void meta_set_syncing (gboolean setting);
|
void meta_set_syncing (gboolean setting);
|
||||||
|
Loading…
Reference in New Issue
Block a user