mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
clutter: Remove option parsing support
For a long time we always passed NULL, lets take it one step further and just remove all the options parsing stuff. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
This commit is contained in:
parent
a545fecad3
commit
528ae91385
@ -66,16 +66,12 @@ struct _ClutterBackendClass
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* vfuncs */
|
||||
gboolean (* pre_parse) (ClutterBackend *backend,
|
||||
GError **error);
|
||||
gboolean (* post_parse) (ClutterBackend *backend,
|
||||
gboolean (* finish_init) (ClutterBackend *backend,
|
||||
GError **error);
|
||||
ClutterStageWindow * (* create_stage) (ClutterBackend *backend,
|
||||
ClutterStage *wrapper,
|
||||
GError **error);
|
||||
void (* init_features) (ClutterBackend *backend);
|
||||
void (* add_options) (ClutterBackend *backend,
|
||||
GOptionGroup *group);
|
||||
ClutterFeatureFlags (* get_features) (ClutterBackend *backend);
|
||||
CoglRenderer * (* get_renderer) (ClutterBackend *backend,
|
||||
GError **error);
|
||||
@ -108,11 +104,7 @@ ClutterStageWindow * _clutter_backend_create_stage (Clutter
|
||||
gboolean _clutter_backend_create_context (ClutterBackend *backend,
|
||||
GError **error);
|
||||
|
||||
void _clutter_backend_add_options (ClutterBackend *backend,
|
||||
GOptionGroup *group);
|
||||
gboolean _clutter_backend_pre_parse (ClutterBackend *backend,
|
||||
GError **error);
|
||||
gboolean _clutter_backend_post_parse (ClutterBackend *backend,
|
||||
gboolean _clutter_backend_finish_init (ClutterBackend *backend,
|
||||
GError **error);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
|
@ -489,45 +489,17 @@ clutter_backend_init (ClutterBackend *self)
|
||||
self->fallback_resource_scale = 1.f;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_backend_add_options (ClutterBackend *backend,
|
||||
GOptionGroup *group)
|
||||
{
|
||||
ClutterBackendClass *klass;
|
||||
|
||||
g_assert (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
||||
if (klass->add_options)
|
||||
klass->add_options (backend, group);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_backend_pre_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
_clutter_backend_finish_init (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendClass *klass;
|
||||
|
||||
g_assert (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
||||
if (klass->pre_parse)
|
||||
return klass->pre_parse (backend, error);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_clutter_backend_post_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendClass *klass;
|
||||
|
||||
g_assert (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
klass = CLUTTER_BACKEND_GET_CLASS (backend);
|
||||
if (klass->post_parse)
|
||||
return klass->post_parse (backend, error);
|
||||
if (klass->finish_init)
|
||||
return klass->finish_init (backend, error);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ static ClutterMainContext *ClutterCntx = NULL;
|
||||
/* command line options */
|
||||
static gboolean clutter_is_initialized = FALSE;
|
||||
static gboolean clutter_show_fps = FALSE;
|
||||
static gboolean clutter_fatal_warnings = FALSE;
|
||||
static gboolean clutter_disable_mipmap_text = FALSE;
|
||||
static gboolean clutter_enable_accessibility = TRUE;
|
||||
static gboolean clutter_sync_to_vblank = TRUE;
|
||||
@ -515,44 +514,6 @@ _clutter_context_get_default (void)
|
||||
return ClutterCntx;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_arg_direction_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_text_direction =
|
||||
(strcmp (value, "rtl") == 0) ? CLUTTER_TEXT_DIRECTION_RTL
|
||||
: CLUTTER_TEXT_DIRECTION_LTR;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
static gboolean
|
||||
clutter_arg_debug_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_debug_flags |=
|
||||
g_parse_debug_string (value,
|
||||
clutter_debug_keys,
|
||||
G_N_ELEMENTS (clutter_debug_keys));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_arg_no_debug_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
clutter_debug_flags &=
|
||||
~g_parse_debug_string (value,
|
||||
clutter_debug_keys,
|
||||
G_N_ELEMENTS (clutter_debug_keys));
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
|
||||
GQuark
|
||||
clutter_init_error_quark (void)
|
||||
{
|
||||
@ -560,35 +521,17 @@ clutter_init_error_quark (void)
|
||||
}
|
||||
|
||||
static ClutterInitError
|
||||
clutter_init_real (GError **error)
|
||||
clutter_init_real (ClutterMainContext *clutter_context,
|
||||
GError **error)
|
||||
{
|
||||
ClutterMainContext *ctx;
|
||||
ClutterBackend *backend;
|
||||
|
||||
/* Note, creates backend if not already existing, though parse args will
|
||||
* have likely created it
|
||||
*/
|
||||
ctx = _clutter_context_get_default ();
|
||||
backend = ctx->backend;
|
||||
backend = clutter_context->backend;
|
||||
|
||||
if (!ctx->options_parsed)
|
||||
{
|
||||
if (error)
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_INTERNAL,
|
||||
"When using clutter_get_option_group_without_init() "
|
||||
"you must parse options before calling clutter_init()");
|
||||
else
|
||||
g_critical ("When using clutter_get_option_group_without_init() "
|
||||
"you must parse options before calling clutter_init()");
|
||||
|
||||
return CLUTTER_INIT_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Call backend post parse hooks.
|
||||
*/
|
||||
if (!_clutter_backend_post_parse (backend, error))
|
||||
if (!_clutter_backend_finish_init (backend, error))
|
||||
return CLUTTER_INIT_ERROR_BACKEND;
|
||||
|
||||
/* If we are displaying the regions that would get redrawn with clipped
|
||||
@ -617,7 +560,7 @@ clutter_init_real (GError **error)
|
||||
clutter_text_direction = clutter_get_text_direction ();
|
||||
|
||||
clutter_is_initialized = TRUE;
|
||||
ctx->is_initialized = TRUE;
|
||||
clutter_context->is_initialized = TRUE;
|
||||
|
||||
/* Initialize a11y */
|
||||
if (clutter_enable_accessibility)
|
||||
@ -629,52 +572,11 @@ clutter_init_real (GError **error)
|
||||
return CLUTTER_INIT_SUCCESS;
|
||||
}
|
||||
|
||||
static GOptionEntry clutter_args[] = {
|
||||
{ "clutter-show-fps", 0, 0, G_OPTION_ARG_NONE, &clutter_show_fps,
|
||||
N_("Show frames per second"), NULL },
|
||||
{ "clutter-default-fps", 0, 0, G_OPTION_ARG_INT, &clutter_default_fps,
|
||||
N_("Default frame rate"), "FPS" },
|
||||
{ "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &clutter_fatal_warnings,
|
||||
N_("Make all warnings fatal"), NULL },
|
||||
{ "clutter-text-direction", 0, 0, G_OPTION_ARG_CALLBACK,
|
||||
clutter_arg_direction_cb,
|
||||
N_("Direction for the text"), "DIRECTION" },
|
||||
{ "clutter-disable-mipmapped-text", 0, 0, G_OPTION_ARG_NONE,
|
||||
&clutter_disable_mipmap_text,
|
||||
N_("Disable mipmapping on text"), NULL },
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
{ "clutter-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_debug_cb,
|
||||
N_("Clutter debugging flags to set"), "FLAGS" },
|
||||
{ "clutter-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, clutter_arg_no_debug_cb,
|
||||
N_("Clutter debugging flags to unset"), "FLAGS" },
|
||||
#endif /* CLUTTER_ENABLE_DEBUG */
|
||||
{ "clutter-enable-accessibility", 0, 0, G_OPTION_ARG_NONE, &clutter_enable_accessibility,
|
||||
N_("Enable accessibility"), NULL },
|
||||
{ NULL, },
|
||||
};
|
||||
|
||||
/* pre_parse_hook: initialise variables depending on environment
|
||||
* variables; these variables might be overridden by the command
|
||||
* line arguments that are going to be parsed after.
|
||||
*/
|
||||
static gboolean
|
||||
pre_parse_hook (GOptionContext *context,
|
||||
GOptionGroup *group,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
static void
|
||||
init_clutter_debug (ClutterMainContext *clutter_context)
|
||||
{
|
||||
ClutterMainContext *clutter_context;
|
||||
ClutterBackend *backend;
|
||||
const char *env_string;
|
||||
|
||||
if (clutter_is_initialized)
|
||||
return TRUE;
|
||||
|
||||
clutter_context = _clutter_context_get_default ();
|
||||
|
||||
backend = clutter_context->backend;
|
||||
g_assert (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
#ifdef CLUTTER_ENABLE_DEBUG
|
||||
env_string = g_getenv ("CLUTTER_DEBUG");
|
||||
if (env_string != NULL)
|
||||
@ -722,253 +624,29 @@ pre_parse_hook (GOptionContext *context,
|
||||
env_string = g_getenv ("CLUTTER_DISABLE_MIPMAPPED_TEXT");
|
||||
if (env_string)
|
||||
clutter_disable_mipmap_text = TRUE;
|
||||
|
||||
return _clutter_backend_pre_parse (backend, error);
|
||||
}
|
||||
|
||||
/* post_parse_hook: initialise the context and data structures
|
||||
* and opens the X display
|
||||
*/
|
||||
static gboolean
|
||||
post_parse_hook (GOptionContext *context,
|
||||
GOptionGroup *group,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
ClutterMainContext *clutter_context;
|
||||
ClutterBackend *backend;
|
||||
|
||||
if (clutter_is_initialized)
|
||||
return TRUE;
|
||||
|
||||
clutter_context = _clutter_context_get_default ();
|
||||
backend = clutter_context->backend;
|
||||
g_assert (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
if (clutter_fatal_warnings)
|
||||
{
|
||||
GLogLevelFlags fatal_mask;
|
||||
|
||||
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
|
||||
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
|
||||
g_log_set_always_fatal (fatal_mask);
|
||||
}
|
||||
|
||||
clutter_context->frame_rate = clutter_default_fps;
|
||||
clutter_context->show_fps = clutter_show_fps;
|
||||
clutter_context->options_parsed = TRUE;
|
||||
|
||||
/* If not asked to defer display setup, call clutter_init_real(),
|
||||
* which in turn calls the backend post parse hooks.
|
||||
*/
|
||||
if (!clutter_context->defer_display_setup)
|
||||
return clutter_init_real (error) == CLUTTER_INIT_SUCCESS;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_get_option_group: (skip)
|
||||
*
|
||||
* Returns a #GOptionGroup for the command line arguments recognized
|
||||
* by Clutter. You should add this group to your #GOptionContext with
|
||||
* g_option_context_add_group(), if you are using g_option_context_parse()
|
||||
* to parse your commandline arguments.
|
||||
*
|
||||
* Calling g_option_context_parse() with Clutter's #GOptionGroup will result
|
||||
* in Clutter's initialization. That is, the following code:
|
||||
*
|
||||
* |[
|
||||
* g_option_context_set_main_group (context, clutter_get_option_group ());
|
||||
* res = g_option_context_parse (context, &argc, &argc, NULL);
|
||||
* ]|
|
||||
*
|
||||
* is functionally equivalent to:
|
||||
*
|
||||
* |[
|
||||
* clutter_init (&argc, &argv);
|
||||
* ]|
|
||||
*
|
||||
* After g_option_context_parse() on a #GOptionContext containing the
|
||||
* Clutter #GOptionGroup has returned %TRUE, Clutter is guaranteed to be
|
||||
* initialized.
|
||||
*
|
||||
* Return value: (transfer full): a #GOptionGroup for the commandline arguments
|
||||
* recognized by Clutter
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
GOptionGroup *
|
||||
clutter_get_option_group (void)
|
||||
{
|
||||
ClutterMainContext *context;
|
||||
GOptionGroup *group;
|
||||
|
||||
clutter_base_init ();
|
||||
|
||||
context = _clutter_context_get_default ();
|
||||
|
||||
group = g_option_group_new ("clutter",
|
||||
"Clutter Options",
|
||||
"Show Clutter Options",
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
|
||||
g_option_group_add_entries (group, clutter_args);
|
||||
|
||||
/* add backend-specific options */
|
||||
_clutter_backend_add_options (context->backend, group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_get_option_group_without_init: (skip)
|
||||
*
|
||||
* Returns a #GOptionGroup for the command line arguments recognized
|
||||
* by Clutter. You should add this group to your #GOptionContext with
|
||||
* g_option_context_add_group(), if you are using g_option_context_parse()
|
||||
* to parse your commandline arguments.
|
||||
*
|
||||
* Unlike clutter_get_option_group(), calling g_option_context_parse() with
|
||||
* the #GOptionGroup returned by this function requires a subsequent explicit
|
||||
* call to clutter_init(); use this function when needing to set foreign
|
||||
* display connection with clutter_x11_set_display(), or with
|
||||
* `gtk_clutter_init()`.
|
||||
*
|
||||
* Return value: (transfer full): a #GOptionGroup for the commandline arguments
|
||||
* recognized by Clutter
|
||||
*
|
||||
* Since: 0.8
|
||||
*/
|
||||
GOptionGroup *
|
||||
clutter_get_option_group_without_init (void)
|
||||
{
|
||||
ClutterMainContext *context;
|
||||
GOptionGroup *group;
|
||||
|
||||
clutter_base_init ();
|
||||
|
||||
context = _clutter_context_get_default ();
|
||||
context->defer_display_setup = TRUE;
|
||||
|
||||
group = clutter_get_option_group ();
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/* Note that the gobject-introspection annotations for the argc/argv
|
||||
* parameters do not produce the right result; however, they do
|
||||
* allow the common case of argc=NULL, argv=NULL to work.
|
||||
*/
|
||||
|
||||
|
||||
static gboolean
|
||||
clutter_parse_args (int *argc,
|
||||
char ***argv,
|
||||
GError **error)
|
||||
{
|
||||
GOptionContext *option_context;
|
||||
GOptionGroup *clutter_group, *cogl_group;
|
||||
GError *internal_error = NULL;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
if (clutter_is_initialized)
|
||||
return TRUE;
|
||||
|
||||
option_context = g_option_context_new (NULL);
|
||||
g_option_context_set_ignore_unknown_options (option_context, TRUE);
|
||||
g_option_context_set_help_enabled (option_context, FALSE);
|
||||
|
||||
/* Initiate any command line options from the backend */
|
||||
clutter_group = clutter_get_option_group ();
|
||||
g_option_context_set_main_group (option_context, clutter_group);
|
||||
|
||||
cogl_group = cogl_get_option_group ();
|
||||
g_option_context_add_group (option_context, cogl_group);
|
||||
|
||||
if (!g_option_context_parse (option_context, argc, argv, &internal_error))
|
||||
{
|
||||
g_propagate_error (error, internal_error);
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
g_option_context_free (option_context);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_init:
|
||||
* @argc: (inout): The number of arguments in @argv
|
||||
* @argv: (array length=argc) (inout) (allow-none): A pointer to an array
|
||||
* of arguments.
|
||||
*
|
||||
* Initialises everything needed to operate with Clutter and parses some
|
||||
* standard command line options; @argc and @argv are adjusted accordingly
|
||||
* so your own code will never see those standard arguments.
|
||||
*
|
||||
* It is safe to call this function multiple times.
|
||||
*
|
||||
* This function will not abort in case of errors during
|
||||
* initialization; clutter_init() will print out the error message on
|
||||
* stderr, and will return an error code. It is up to the application
|
||||
* code to handle this case.
|
||||
*
|
||||
* If this function fails, and returns an error code, any subsequent
|
||||
* Clutter API will have undefined behaviour - including segmentation
|
||||
* faults and assertion failures. Make sure to handle the returned
|
||||
* #ClutterInitError enumeration value.
|
||||
*
|
||||
* Return value: a #ClutterInitError value
|
||||
* clutter_init: (skip)
|
||||
*/
|
||||
ClutterInitError
|
||||
clutter_init (int *argc,
|
||||
char ***argv)
|
||||
clutter_init (GError **error)
|
||||
{
|
||||
ClutterMainContext *ctx;
|
||||
GError *error = NULL;
|
||||
ClutterInitError res;
|
||||
ClutterMainContext *clutter_context;
|
||||
|
||||
if (clutter_is_initialized)
|
||||
return CLUTTER_INIT_SUCCESS;
|
||||
|
||||
clutter_base_init ();
|
||||
|
||||
ctx = _clutter_context_get_default ();
|
||||
clutter_context = _clutter_context_get_default ();
|
||||
|
||||
if (!ctx->defer_display_setup)
|
||||
{
|
||||
#if 0
|
||||
if (argc && *argc > 0 && *argv)
|
||||
g_set_prgname ((*argv)[0]);
|
||||
#endif
|
||||
init_clutter_debug (clutter_context);
|
||||
|
||||
/* parse_args will trigger backend creation and things like
|
||||
* DISPLAY connection etc.
|
||||
*/
|
||||
if (!clutter_parse_args (argc, argv, &error))
|
||||
{
|
||||
g_critical ("Unable to initialize Clutter: %s", error->message);
|
||||
g_error_free (error);
|
||||
clutter_context->frame_rate = clutter_default_fps;
|
||||
clutter_context->show_fps = clutter_show_fps;
|
||||
|
||||
res = CLUTTER_INIT_ERROR_INTERNAL;
|
||||
}
|
||||
else
|
||||
res = CLUTTER_INIT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = clutter_init_real (&error);
|
||||
if (error != NULL)
|
||||
{
|
||||
g_critical ("Unable to initialize Clutter: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return clutter_init_real (clutter_context, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -125,8 +125,7 @@ GQuark clutter_init_error_quark (void);
|
||||
CLUTTER_EXPORT
|
||||
void clutter_base_init (void);
|
||||
CLUTTER_EXPORT
|
||||
ClutterInitError clutter_init (int *argc,
|
||||
char ***argv) G_GNUC_WARN_UNUSED_RESULT;
|
||||
ClutterInitError clutter_init (GError **error) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
GOptionGroup * clutter_get_option_group (void);
|
||||
|
@ -154,7 +154,6 @@ struct _ClutterMainContext
|
||||
|
||||
/* boolean flags */
|
||||
guint is_initialized : 1;
|
||||
guint defer_display_setup : 1;
|
||||
guint options_parsed : 1;
|
||||
guint show_fps : 1;
|
||||
};
|
||||
|
@ -1061,12 +1061,8 @@ init_clutter (MetaBackend *backend,
|
||||
|
||||
clutter_set_custom_backend_func (meta_get_clutter_backend);
|
||||
|
||||
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Unable to initialize Clutter");
|
||||
return FALSE;
|
||||
}
|
||||
if (clutter_init (error) != CLUTTER_INIT_SUCCESS)
|
||||
return FALSE;
|
||||
|
||||
priv->default_seat = meta_backend_create_default_seat (backend, error);
|
||||
if (!priv->default_seat)
|
||||
|
@ -75,8 +75,6 @@ static gboolean clutter_enable_stereo = FALSE;
|
||||
static Display *_foreign_dpy = NULL;
|
||||
|
||||
/* options */
|
||||
static gchar *clutter_display_name = NULL;
|
||||
static gint clutter_screen = -1;
|
||||
static gboolean clutter_synchronise = FALSE;
|
||||
|
||||
/* X error trap */
|
||||
@ -109,27 +107,8 @@ cogl_xlib_filter (XEvent *xevent,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_clutter_backend_x11_pre_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
const gchar *env_string;
|
||||
|
||||
/* we don't fail here if DISPLAY is not set, as the user
|
||||
* might pass the --display command line switch
|
||||
*/
|
||||
env_string = g_getenv ("DISPLAY");
|
||||
if (env_string)
|
||||
{
|
||||
clutter_display_name = g_strdup (env_string);
|
||||
env_string = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
meta_clutter_backend_x11_finish_init (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
|
||||
Atom atoms[N_ATOM_NAMES];
|
||||
@ -142,18 +121,20 @@ meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
*/
|
||||
if (backend_x11->xdisplay == NULL)
|
||||
{
|
||||
if (clutter_display_name != NULL &&
|
||||
*clutter_display_name != '\0')
|
||||
{
|
||||
g_debug ("XOpenDisplay on '%s'", clutter_display_name);
|
||||
const char *display_name;
|
||||
|
||||
backend_x11->xdisplay = XOpenDisplay (clutter_display_name);
|
||||
display_name = g_getenv ("DISPLAY");
|
||||
if (display_name && *display_name != '\0')
|
||||
{
|
||||
g_debug ("XOpenDisplay on '%s'", display_name);
|
||||
|
||||
backend_x11->xdisplay = XOpenDisplay (display_name);
|
||||
if (backend_x11->xdisplay == NULL)
|
||||
{
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_BACKEND,
|
||||
"Unable to open display '%s'",
|
||||
clutter_display_name);
|
||||
display_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -175,12 +156,7 @@ meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
/* add event filter for Cogl events */
|
||||
meta_clutter_x11_add_filter (cogl_xlib_filter, backend);
|
||||
|
||||
if (clutter_screen == -1)
|
||||
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdisplay);
|
||||
else
|
||||
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdisplay,
|
||||
clutter_screen);
|
||||
|
||||
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdisplay);
|
||||
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
|
||||
backend_x11->xscreen_width = WidthOfScreen (backend_x11->xscreen);
|
||||
backend_x11->xscreen_height = HeightOfScreen (backend_x11->xscreen);
|
||||
@ -206,8 +182,6 @@ meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
backend_x11->atom_NET_WM_NAME = atoms[8];
|
||||
backend_x11->atom_UTF8_STRING = atoms[9];
|
||||
|
||||
g_free (clutter_display_name);
|
||||
|
||||
g_debug ("X Display '%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
|
||||
g_getenv ("DISPLAY"),
|
||||
backend_x11->xdisplay,
|
||||
@ -218,35 +192,6 @@ meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const GOptionEntry entries[] =
|
||||
{
|
||||
{
|
||||
"display", 0,
|
||||
G_OPTION_FLAG_IN_MAIN,
|
||||
G_OPTION_ARG_STRING, &clutter_display_name,
|
||||
N_("X display to use"), "DISPLAY"
|
||||
},
|
||||
{
|
||||
"screen", 0,
|
||||
G_OPTION_FLAG_IN_MAIN,
|
||||
G_OPTION_ARG_INT, &clutter_screen,
|
||||
N_("X screen to use"), "SCREEN"
|
||||
},
|
||||
{ "synch", 0,
|
||||
0,
|
||||
G_OPTION_ARG_NONE, &clutter_synchronise,
|
||||
N_("Make X calls synchronous"), NULL
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
meta_clutter_backend_x11_add_options (ClutterBackend *backend,
|
||||
GOptionGroup *group)
|
||||
{
|
||||
g_option_group_add_entries (group, entries);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_clutter_backend_x11_finalize (GObject *gobject)
|
||||
{
|
||||
@ -515,9 +460,7 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
|
||||
|
||||
gobject_class->finalize = meta_clutter_backend_x11_finalize;
|
||||
|
||||
clutter_backend_class->pre_parse = meta_clutter_backend_x11_pre_parse;
|
||||
clutter_backend_class->post_parse = meta_clutter_backend_x11_post_parse;
|
||||
clutter_backend_class->add_options = meta_clutter_backend_x11_add_options;
|
||||
clutter_backend_class->finish_init = meta_clutter_backend_x11_finish_init;
|
||||
clutter_backend_class->get_features = meta_clutter_backend_x11_get_features;
|
||||
|
||||
clutter_backend_class->get_display = meta_clutter_backend_x11_get_display;
|
||||
|
Loading…
Reference in New Issue
Block a user