2011-03-05 16:16:26 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 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.
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2011-03-05 16:16:26 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-11 20:42:06 -05:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2011-03-05 16:16:26 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include <glib.h>
|
2013-09-11 04:18:53 -04:00
|
|
|
#include <glib/gi18n-lib.h>
|
2021-09-20 03:02:49 -04:00
|
|
|
#include <glib-unix.h>
|
2018-07-10 04:36:24 -04:00
|
|
|
#include <stdlib.h>
|
2011-03-05 16:16:26 -05:00
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "compositor/meta-plugin-manager.h"
|
|
|
|
#include "meta/main.h"
|
2021-03-03 05:40:55 -05:00
|
|
|
#include "meta/meta-context.h"
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "meta/util.h"
|
2011-03-05 16:16:26 -05:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
print_version (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
2021-02-07 06:48:20 -05:00
|
|
|
g_print ("mutter %s\n", VERSION);
|
2011-03-05 16:16:26 -05:00
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2018-07-12 16:20:20 -04:00
|
|
|
static const char *plugin = "libdefault";
|
2011-03-05 16:16:26 -05:00
|
|
|
|
|
|
|
GOptionEntry mutter_options[] = {
|
|
|
|
{
|
|
|
|
"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
print_version,
|
|
|
|
N_("Print version"),
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
{
|
2012-04-05 00:50:21 -04:00
|
|
|
"mutter-plugin", 0, 0, G_OPTION_ARG_STRING,
|
|
|
|
&plugin,
|
|
|
|
N_("Mutter plugin to use"),
|
|
|
|
"PLUGIN",
|
2011-03-05 16:16:26 -05:00
|
|
|
},
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2021-09-20 03:02:49 -04:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
on_sigterm (gpointer user_data)
|
|
|
|
{
|
|
|
|
MetaContext *context = META_CONTEXT (user_data);
|
|
|
|
|
|
|
|
meta_context_terminate (context);
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_signal_handlers (MetaContext *context)
|
|
|
|
{
|
|
|
|
struct sigaction act = { 0 };
|
|
|
|
sigset_t empty_mask;
|
|
|
|
|
|
|
|
sigemptyset (&empty_mask);
|
|
|
|
act.sa_handler = SIG_IGN;
|
|
|
|
act.sa_mask = empty_mask;
|
|
|
|
act.sa_flags = 0;
|
|
|
|
if (sigaction (SIGPIPE, &act, NULL) < 0)
|
|
|
|
g_warning ("Failed to register SIGPIPE handler: %s", g_strerror (errno));
|
|
|
|
#ifdef SIGXFSZ
|
|
|
|
if (sigaction (SIGXFSZ, &act, NULL) < 0)
|
|
|
|
g_warning ("Failed to register SIGXFSZ handler: %s", g_strerror (errno));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_unix_signal_add (SIGTERM, on_sigterm, context);
|
|
|
|
}
|
|
|
|
|
2011-03-05 16:16:26 -05:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2021-03-03 05:40:55 -05:00
|
|
|
g_autoptr (MetaContext) context = NULL;
|
|
|
|
g_autoptr (GError) error = NULL;
|
2011-03-05 16:16:26 -05:00
|
|
|
|
2021-03-03 05:40:55 -05:00
|
|
|
context = meta_create_context ("Mutter");
|
|
|
|
|
|
|
|
meta_context_add_option_entries (context, mutter_options, GETTEXT_PACKAGE);
|
|
|
|
if (!meta_context_configure (context, &argc, &argv, &error))
|
|
|
|
{
|
|
|
|
g_printerr ("Failed to configure: %s", error->message);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_context_set_plugin_name (context, plugin);
|
|
|
|
|
2021-09-20 03:02:49 -04:00
|
|
|
init_signal_handlers (context);
|
|
|
|
|
2021-03-03 05:40:55 -05:00
|
|
|
if (!meta_context_setup (context, &error))
|
2011-03-05 16:16:26 -05:00
|
|
|
{
|
2021-03-03 05:40:55 -05:00
|
|
|
g_printerr ("Failed to setup: %s", error->message);
|
|
|
|
return EXIT_FAILURE;
|
2011-03-05 16:16:26 -05:00
|
|
|
}
|
|
|
|
|
2021-03-03 05:40:55 -05:00
|
|
|
if (!meta_context_start (context, &error))
|
|
|
|
{
|
|
|
|
g_printerr ("Failed to start: %s", error->message);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_context_notify_ready (context);
|
|
|
|
|
|
|
|
if (!meta_context_run_main_loop (context, &error))
|
|
|
|
{
|
|
|
|
g_printerr ("Mutter terminated with a failure: %s", error->message);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2011-03-05 16:16:26 -05:00
|
|
|
|
2021-03-03 05:40:55 -05:00
|
|
|
return EXIT_SUCCESS;
|
2011-03-05 16:16:26 -05:00
|
|
|
}
|