2011-02-25 11:20:27 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2021-03-31 19:08:12 -04:00
|
|
|
#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
|
2011-02-25 11:20:27 -05:00
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-12-22 23:14:14 -05:00
|
|
|
#include <cogl-pango/cogl-pango.h>
|
2011-02-25 11:20:27 -05:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
#include <girepository.h>
|
2011-03-05 10:49:24 -05:00
|
|
|
#include <meta/main.h>
|
|
|
|
#include <meta/meta-plugin.h>
|
|
|
|
#include <meta/prefs.h>
|
2012-06-14 07:57:09 -04:00
|
|
|
#include <atk-bridge.h>
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2011-06-21 10:09:09 -04:00
|
|
|
#include "shell-global.h"
|
2011-08-28 01:32:12 -04:00
|
|
|
#include "shell-global-private.h"
|
2011-02-25 11:20:27 -05:00
|
|
|
#include "shell-perf-log.h"
|
|
|
|
#include "st.h"
|
|
|
|
|
|
|
|
extern GType gnome_shell_plugin_get_type (void);
|
|
|
|
|
|
|
|
#define SHELL_DBUS_SERVICE "org.gnome.Shell"
|
|
|
|
|
2011-10-20 16:28:59 -04:00
|
|
|
#define WM_NAME "GNOME Shell"
|
2012-11-05 08:54:33 -05:00
|
|
|
#define GNOME_WM_KEYBINDINGS "Mutter,GNOME Shell"
|
2011-10-20 16:28:59 -04:00
|
|
|
|
2011-06-21 10:09:09 -04:00
|
|
|
static gboolean is_gdm_mode = FALSE;
|
2012-05-16 16:56:27 -04:00
|
|
|
static char *session_mode = NULL;
|
2017-10-20 06:41:59 -04:00
|
|
|
static int caught_signal = 0;
|
2011-06-21 10:09:09 -04:00
|
|
|
|
2011-08-16 08:19:59 -04:00
|
|
|
#define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
|
|
|
|
#define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4
|
|
|
|
|
2012-11-28 13:45:52 -05:00
|
|
|
enum {
|
|
|
|
SHELL_DEBUG_BACKTRACE_WARNINGS = 1,
|
2017-10-20 06:41:59 -04:00
|
|
|
SHELL_DEBUG_BACKTRACE_SEGFAULTS = 2,
|
2012-11-28 13:45:52 -05:00
|
|
|
};
|
|
|
|
static int _shell_debug;
|
2017-10-24 01:28:33 -04:00
|
|
|
static gboolean _tracked_signals[NSIG] = { 0 };
|
2012-11-28 13:45:52 -05:00
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
static void
|
2015-09-23 14:40:42 -04:00
|
|
|
shell_dbus_acquire_name (GDBusProxy *bus,
|
|
|
|
guint32 request_name_flags,
|
|
|
|
guint32 *request_name_result,
|
|
|
|
const gchar *name,
|
|
|
|
gboolean fatal)
|
2011-02-25 11:20:27 -05:00
|
|
|
{
|
|
|
|
GError *error = NULL;
|
2011-08-16 08:19:59 -04:00
|
|
|
GVariant *request_name_variant;
|
|
|
|
|
|
|
|
if (!(request_name_variant = g_dbus_proxy_call_sync (bus,
|
|
|
|
"RequestName",
|
|
|
|
g_variant_new ("(su)", name, request_name_flags),
|
|
|
|
0, /* call flags */
|
|
|
|
-1, /* timeout */
|
|
|
|
NULL, /* cancellable */
|
|
|
|
&error)))
|
2011-09-23 13:57:46 -04:00
|
|
|
{
|
2011-11-12 18:37:47 -05:00
|
|
|
g_printerr ("failed to acquire %s: %s\n", name, error->message);
|
2015-09-24 13:16:56 -04:00
|
|
|
g_clear_error (&error);
|
2011-11-12 18:37:47 -05:00
|
|
|
if (!fatal)
|
|
|
|
return;
|
2011-08-16 08:19:59 -04:00
|
|
|
exit (1);
|
2011-09-23 13:57:46 -04:00
|
|
|
}
|
2011-08-16 08:19:59 -04:00
|
|
|
g_variant_get (request_name_variant, "(u)", request_name_result);
|
2015-09-24 13:17:36 -04:00
|
|
|
g_variant_unref (request_name_variant);
|
2011-09-23 13:57:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_dbus_init (gboolean replace)
|
|
|
|
{
|
2011-08-16 08:19:59 -04:00
|
|
|
GDBusConnection *session;
|
|
|
|
GDBusProxy *bus;
|
|
|
|
GError *error = NULL;
|
2011-03-23 13:15:17 -04:00
|
|
|
guint32 request_name_flags;
|
2011-02-25 11:20:27 -05:00
|
|
|
guint32 request_name_result;
|
|
|
|
|
2011-08-16 08:19:59 -04:00
|
|
|
session = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2011-08-16 08:19:59 -04:00
|
|
|
if (error) {
|
|
|
|
g_printerr ("Failed to connect to session bus: %s", error->message);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bus = g_dbus_proxy_new_sync (session,
|
|
|
|
G_DBUS_PROXY_FLAGS_NONE,
|
|
|
|
NULL, /* interface info */
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
"/org/freedesktop/DBus",
|
|
|
|
"org.freedesktop.DBus",
|
|
|
|
NULL, /* cancellable */
|
|
|
|
&error);
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2015-09-24 13:31:07 -04:00
|
|
|
if (!bus)
|
|
|
|
{
|
|
|
|
g_printerr ("Failed to get a session bus proxy: %s", error->message);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2011-08-16 08:19:59 -04:00
|
|
|
request_name_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
|
2011-03-23 13:15:17 -04:00
|
|
|
if (replace)
|
2017-03-10 10:20:25 -05:00
|
|
|
request_name_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
|
2011-08-16 08:19:59 -04:00
|
|
|
|
2011-09-23 13:57:46 -04:00
|
|
|
shell_dbus_acquire_name (bus,
|
|
|
|
request_name_flags,
|
|
|
|
&request_name_result,
|
|
|
|
SHELL_DBUS_SERVICE, TRUE);
|
2011-03-23 13:15:17 -04:00
|
|
|
if (!(request_name_result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
|
|
|
|
|| request_name_result == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER))
|
|
|
|
{
|
2011-08-16 08:19:59 -04:00
|
|
|
g_printerr (SHELL_DBUS_SERVICE " already exists on bus and --replace not specified\n");
|
2011-03-23 13:15:17 -04:00
|
|
|
exit (1);
|
2011-02-25 11:20:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (bus);
|
2011-08-16 08:19:59 -04:00
|
|
|
g_object_unref (session);
|
2011-02-25 11:20:27 -05:00
|
|
|
}
|
|
|
|
|
2012-05-17 21:52:57 -04:00
|
|
|
static void
|
|
|
|
shell_introspection_init (void)
|
|
|
|
{
|
|
|
|
|
|
|
|
g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
|
|
|
|
g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR);
|
2017-08-10 14:47:59 -04:00
|
|
|
|
|
|
|
/* We need to explicitly add the directories where the private libraries are
|
|
|
|
* installed to the GIR's library path, so that they can be found at runtime
|
|
|
|
* when linking using DT_RUNPATH (instead of DT_RPATH), which is the default
|
|
|
|
* for some linkers (e.g. gold) and in some distros (e.g. Debian).
|
|
|
|
*/
|
|
|
|
g_irepository_prepend_library_path (MUTTER_TYPELIB_DIR);
|
|
|
|
g_irepository_prepend_library_path (GNOME_SHELL_PKGLIBDIR);
|
2012-05-17 21:52:57 -04:00
|
|
|
}
|
|
|
|
|
2012-12-22 23:14:14 -05:00
|
|
|
static void
|
|
|
|
shell_fonts_init (void)
|
|
|
|
{
|
|
|
|
CoglPangoFontMap *fontmap;
|
|
|
|
|
|
|
|
/* Disable text mipmapping; it causes problems on pre-GEM Intel
|
|
|
|
* drivers and we should just be rendering text at the right
|
|
|
|
* size rather than scaling it. If we do effects where we dynamically
|
|
|
|
* zoom labels, then we might want to reconsider.
|
|
|
|
*/
|
|
|
|
fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
|
|
|
|
cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
|
|
|
|
}
|
|
|
|
|
2019-06-05 19:12:47 -04:00
|
|
|
static void
|
|
|
|
shell_profiler_init (void)
|
|
|
|
{
|
|
|
|
ShellGlobal *global;
|
|
|
|
GjsProfiler *profiler;
|
|
|
|
GjsContext *context;
|
|
|
|
const char *enabled;
|
|
|
|
const char *fd_str;
|
|
|
|
int fd = -1;
|
|
|
|
|
|
|
|
/* Sysprof uses the "GJS_TRACE_FD=N" environment variable to connect GJS
|
|
|
|
* profiler data to the combined Sysprof capture. Since we are in control of
|
|
|
|
* the GjsContext, we need to proxy this FD across to the GJS profiler.
|
|
|
|
*/
|
|
|
|
|
|
|
|
fd_str = g_getenv ("GJS_TRACE_FD");
|
|
|
|
enabled = g_getenv ("GJS_ENABLE_PROFILER");
|
|
|
|
if (fd_str == NULL || enabled == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
global = shell_global_get ();
|
|
|
|
g_return_if_fail (global);
|
|
|
|
|
|
|
|
context = _shell_global_get_gjs_context (global);
|
|
|
|
g_return_if_fail (context);
|
|
|
|
|
|
|
|
profiler = gjs_context_get_profiler (context);
|
|
|
|
g_return_if_fail (profiler);
|
|
|
|
|
|
|
|
if (fd_str)
|
|
|
|
{
|
|
|
|
fd = atoi (fd_str);
|
|
|
|
|
|
|
|
if (fd > 2)
|
|
|
|
{
|
|
|
|
gjs_profiler_set_fd (profiler, fd);
|
|
|
|
gjs_profiler_start (profiler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_profiler_shutdown (void)
|
|
|
|
{
|
|
|
|
ShellGlobal *global;
|
|
|
|
GjsProfiler *profiler;
|
|
|
|
GjsContext *context;
|
|
|
|
|
|
|
|
global = shell_global_get ();
|
|
|
|
context = _shell_global_get_gjs_context (global);
|
|
|
|
profiler = gjs_context_get_profiler (context);
|
|
|
|
|
|
|
|
if (profiler)
|
|
|
|
gjs_profiler_stop (profiler);
|
|
|
|
}
|
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
static void
|
|
|
|
malloc_statistics_callback (ShellPerfLog *perf_log,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2021-03-31 19:08:12 -04:00
|
|
|
#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
|
|
|
|
#ifdef HAVE_MALLINFO2
|
|
|
|
struct mallinfo2 info = mallinfo2 ();
|
|
|
|
#else
|
2011-02-25 11:20:27 -05:00
|
|
|
struct mallinfo info = mallinfo ();
|
2021-03-31 19:08:12 -04:00
|
|
|
#endif
|
2011-02-25 11:20:27 -05:00
|
|
|
|
|
|
|
shell_perf_log_update_statistic_i (perf_log,
|
|
|
|
"malloc.arenaSize",
|
|
|
|
info.arena);
|
|
|
|
shell_perf_log_update_statistic_i (perf_log,
|
|
|
|
"malloc.mmapSize",
|
|
|
|
info.hblkhd);
|
|
|
|
shell_perf_log_update_statistic_i (perf_log,
|
|
|
|
"malloc.usedSize",
|
|
|
|
info.uordblks);
|
2021-03-31 19:08:12 -04:00
|
|
|
#endif /* defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2) */
|
2011-02-25 11:20:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shell_perf_log_init (void)
|
|
|
|
{
|
|
|
|
ShellPerfLog *perf_log = shell_perf_log_get_default ();
|
|
|
|
|
|
|
|
/* For probably historical reasons, mallinfo() defines the returned values,
|
|
|
|
* even those in bytes as int, not size_t. We're determined not to use
|
|
|
|
* more than 2G of malloc'ed memory, so are OK with that.
|
|
|
|
*/
|
|
|
|
shell_perf_log_define_statistic (perf_log,
|
|
|
|
"malloc.arenaSize",
|
|
|
|
"Amount of memory allocated by malloc() with brk(), in bytes",
|
|
|
|
"i");
|
|
|
|
shell_perf_log_define_statistic (perf_log,
|
|
|
|
"malloc.mmapSize",
|
|
|
|
"Amount of memory allocated by malloc() with mmap(), in bytes",
|
|
|
|
"i");
|
|
|
|
shell_perf_log_define_statistic (perf_log,
|
|
|
|
"malloc.usedSize",
|
|
|
|
"Amount of malloc'ed memory currently in use",
|
|
|
|
"i");
|
|
|
|
|
|
|
|
shell_perf_log_add_statistics_callback (perf_log,
|
|
|
|
malloc_statistics_callback,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-14 07:57:09 -04:00
|
|
|
static void
|
|
|
|
shell_a11y_init (void)
|
|
|
|
{
|
2014-09-03 12:45:32 -04:00
|
|
|
cally_accessibility_init ();
|
|
|
|
|
2012-06-14 07:57:09 -04:00
|
|
|
if (clutter_get_accessibility_enabled () == FALSE)
|
|
|
|
{
|
|
|
|
g_warning ("Accessibility: clutter has no accessibility enabled"
|
|
|
|
" skipping the atk-bridge load");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
atk_bridge_adaptor_init (NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 13:45:52 -05:00
|
|
|
static void
|
|
|
|
shell_init_debug (const char *debug_env)
|
|
|
|
{
|
|
|
|
static const GDebugKey keys[] = {
|
2017-10-20 06:41:59 -04:00
|
|
|
{ "backtrace-warnings", SHELL_DEBUG_BACKTRACE_WARNINGS },
|
|
|
|
{ "backtrace-segfaults", SHELL_DEBUG_BACKTRACE_SEGFAULTS },
|
2012-11-28 13:45:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
_shell_debug = g_parse_debug_string (debug_env, keys,
|
|
|
|
G_N_ELEMENTS (keys));
|
|
|
|
}
|
|
|
|
|
2011-06-20 09:01:54 -04:00
|
|
|
static void
|
|
|
|
default_log_handler (const char *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const char *message,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2012-10-26 12:52:07 -04:00
|
|
|
if (!log_domain || !g_str_has_prefix (log_domain, "tp-glib"))
|
2011-06-20 09:01:54 -04:00
|
|
|
g_log_default_handler (log_domain, log_level, message, data);
|
2012-11-28 13:45:52 -05:00
|
|
|
|
|
|
|
/* Filter out Gjs logs, those already have the stack */
|
|
|
|
if (log_domain && strcmp (log_domain, "Gjs") == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((_shell_debug & SHELL_DEBUG_BACKTRACE_WARNINGS) &&
|
|
|
|
((log_level & G_LOG_LEVEL_CRITICAL) ||
|
|
|
|
(log_level & G_LOG_LEVEL_WARNING)))
|
|
|
|
gjs_dumpstack ();
|
2011-06-20 09:01:54 -04:00
|
|
|
}
|
|
|
|
|
2012-05-17 21:52:57 -04:00
|
|
|
static void
|
|
|
|
shut_up (const char *domain,
|
|
|
|
GLogLevelFlags level,
|
|
|
|
const char *message,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-10-20 06:41:59 -04:00
|
|
|
static void
|
2017-10-24 01:28:33 -04:00
|
|
|
dump_gjs_stack_alarm_sigaction (int signo)
|
2017-10-20 06:41:59 -04:00
|
|
|
{
|
2017-10-24 01:28:33 -04:00
|
|
|
g_log_set_default_handler (g_log_default_handler, NULL);
|
2017-10-20 06:41:59 -04:00
|
|
|
g_warning ("Failed to dump Javascript stack, got stuck");
|
2017-10-24 01:28:33 -04:00
|
|
|
g_log_set_default_handler (default_log_handler, NULL);
|
2017-10-20 06:41:59 -04:00
|
|
|
|
|
|
|
raise (caught_signal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dump_gjs_stack_on_signal_handler (int signo)
|
|
|
|
{
|
2019-07-20 04:28:53 -04:00
|
|
|
struct sigaction sa = { .sa_handler = dump_gjs_stack_alarm_sigaction };
|
2017-10-24 01:28:33 -04:00
|
|
|
gsize i;
|
|
|
|
|
|
|
|
/* Ignore all the signals starting this point, a part the one we'll raise
|
|
|
|
* (which is implicitly ignored here through SA_RESETHAND), this is needed
|
|
|
|
* not to get this handler being called by other signals that we were
|
|
|
|
* tracking and that might be emitted by code called starting from now.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_tracked_signals); ++i)
|
|
|
|
{
|
|
|
|
if (_tracked_signals[i] && i != signo)
|
|
|
|
signal (i, SIG_IGN);
|
|
|
|
}
|
2017-10-20 06:41:59 -04:00
|
|
|
|
2017-10-24 01:28:33 -04:00
|
|
|
/* Waiting at least 5 seconds for the dumpstack, if it fails, we raise the error */
|
2017-10-20 06:41:59 -04:00
|
|
|
caught_signal = signo;
|
|
|
|
sigemptyset (&sa.sa_mask);
|
|
|
|
sigaction (SIGALRM, &sa, NULL);
|
|
|
|
|
|
|
|
alarm (5);
|
|
|
|
gjs_dumpstack ();
|
|
|
|
alarm (0);
|
|
|
|
|
|
|
|
raise (signo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dump_gjs_stack_on_signal (int signo)
|
|
|
|
{
|
2019-07-20 04:28:53 -04:00
|
|
|
struct sigaction sa = {
|
|
|
|
.sa_flags = SA_RESETHAND | SA_NODEFER,
|
|
|
|
.sa_handler = dump_gjs_stack_on_signal_handler,
|
|
|
|
};
|
2017-10-20 06:41:59 -04:00
|
|
|
|
2017-10-24 01:28:33 -04:00
|
|
|
sigemptyset (&sa.sa_mask);
|
2017-10-20 06:41:59 -04:00
|
|
|
|
|
|
|
sigaction (signo, &sa, NULL);
|
2017-10-24 01:28:33 -04:00
|
|
|
_tracked_signals[signo] = TRUE;
|
2017-10-20 06:41:59 -04:00
|
|
|
}
|
|
|
|
|
2012-05-17 21:52:57 -04:00
|
|
|
static gboolean
|
|
|
|
list_modes (const char *option_name,
|
|
|
|
const char *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ShellGlobal *global;
|
|
|
|
GjsContext *context;
|
|
|
|
const char *script;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
/* Many of our imports require global to be set, so rather than
|
|
|
|
* tayloring our imports carefully here to avoid that dependency,
|
|
|
|
* we just set it.
|
|
|
|
* ShellGlobal has some GTK+ dependencies, so initialize GTK+; we
|
|
|
|
* don't really care if it fails though (e.g. when running from a tty),
|
|
|
|
* so we mute all warnings */
|
|
|
|
g_log_set_default_handler (shut_up, NULL);
|
|
|
|
gtk_init_check (NULL, NULL);
|
|
|
|
|
|
|
|
_shell_global_init (NULL);
|
|
|
|
global = shell_global_get ();
|
|
|
|
context = _shell_global_get_gjs_context (global);
|
|
|
|
|
|
|
|
shell_introspection_init ();
|
|
|
|
|
|
|
|
script = "imports.ui.environment.init();"
|
|
|
|
"imports.ui.sessionMode.listModes();";
|
|
|
|
if (!gjs_context_eval (context, script, -1, "<main>", &status, NULL))
|
|
|
|
g_message ("Retrieving list of available modes failed.");
|
|
|
|
|
2017-02-09 21:09:21 -05:00
|
|
|
g_object_unref (context);
|
2012-05-17 21:52:57 -04:00
|
|
|
exit (status);
|
|
|
|
}
|
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
static gboolean
|
|
|
|
print_version (const gchar *option_name,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
g_print ("GNOME Shell %s\n", VERSION);
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
GOptionEntry gnome_shell_options[] = {
|
|
|
|
{
|
|
|
|
"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
print_version,
|
|
|
|
N_("Print version"),
|
|
|
|
NULL
|
|
|
|
},
|
2011-06-21 10:09:09 -04:00
|
|
|
{
|
2012-05-16 16:56:27 -04:00
|
|
|
"gdm-mode", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
|
2011-06-21 10:09:09 -04:00
|
|
|
&is_gdm_mode,
|
|
|
|
N_("Mode used by GDM for login screen"),
|
|
|
|
NULL
|
|
|
|
},
|
2012-05-16 16:56:27 -04:00
|
|
|
{
|
|
|
|
"mode", 0, 0, G_OPTION_ARG_STRING,
|
|
|
|
&session_mode,
|
2016-09-29 18:00:13 -04:00
|
|
|
N_("Use a specific mode, e.g. “gdm” for login screen"),
|
2012-05-16 16:56:27 -04:00
|
|
|
"MODE"
|
|
|
|
},
|
2012-05-17 21:52:57 -04:00
|
|
|
{
|
|
|
|
"list-modes", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
|
|
|
list_modes,
|
|
|
|
N_("List possible modes"),
|
|
|
|
NULL
|
|
|
|
},
|
2011-02-25 11:20:27 -05:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GOptionContext *ctx;
|
|
|
|
GError *error = NULL;
|
2011-05-05 18:09:59 -04:00
|
|
|
int ecode;
|
2011-02-25 11:20:27 -05:00
|
|
|
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
2011-04-30 10:34:51 -04:00
|
|
|
textdomain (GETTEXT_PACKAGE);
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2014-01-07 13:14:31 -05:00
|
|
|
session_mode = (char *) g_getenv ("GNOME_SHELL_SESSION_MODE");
|
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
ctx = meta_get_option_context ();
|
|
|
|
g_option_context_add_main_entries (ctx, gnome_shell_options, GETTEXT_PACKAGE);
|
2013-08-16 09:47:17 -04:00
|
|
|
g_option_context_add_group (ctx, g_irepository_get_option_group ());
|
2011-02-25 11:20:27 -05:00
|
|
|
if (!g_option_context_parse (ctx, &argc, &argv, &error))
|
|
|
|
{
|
|
|
|
g_printerr ("%s: %s\n", argv[0], error->message);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2011-07-09 17:07:46 -04:00
|
|
|
g_option_context_free (ctx);
|
|
|
|
|
2012-06-05 13:21:51 -04:00
|
|
|
meta_plugin_manager_set_plugin_type (gnome_shell_plugin_get_type ());
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2011-10-20 16:28:59 -04:00
|
|
|
meta_set_wm_name (WM_NAME);
|
|
|
|
meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS);
|
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
meta_init ();
|
|
|
|
|
|
|
|
/* FIXME: Add gjs API to set this stuff and don't depend on the
|
|
|
|
* environment. These propagate to child processes.
|
|
|
|
*/
|
|
|
|
g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
|
|
|
|
g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);
|
|
|
|
|
2012-11-28 13:45:52 -05:00
|
|
|
shell_init_debug (g_getenv ("SHELL_DEBUG"));
|
|
|
|
|
2011-03-23 13:15:17 -04:00
|
|
|
shell_dbus_init (meta_get_replace_current_wm ());
|
2011-02-25 11:20:27 -05:00
|
|
|
shell_a11y_init ();
|
|
|
|
shell_perf_log_init ();
|
2012-05-17 21:52:57 -04:00
|
|
|
shell_introspection_init ();
|
2012-12-22 23:14:14 -05:00
|
|
|
shell_fonts_init ();
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2016-09-21 17:28:54 -04:00
|
|
|
g_log_set_default_handler (default_log_handler, NULL);
|
2011-06-20 09:01:54 -04:00
|
|
|
|
2011-02-25 11:20:27 -05:00
|
|
|
/* Initialize the global object */
|
2012-05-16 17:11:57 -04:00
|
|
|
if (session_mode == NULL)
|
2015-09-23 14:40:42 -04:00
|
|
|
session_mode = is_gdm_mode ? (char *)"gdm" : (char *)"user";
|
2012-05-16 17:11:57 -04:00
|
|
|
|
|
|
|
_shell_global_init ("session-mode", session_mode, NULL);
|
2011-02-25 11:20:27 -05:00
|
|
|
|
2017-10-20 06:41:59 -04:00
|
|
|
dump_gjs_stack_on_signal (SIGABRT);
|
|
|
|
dump_gjs_stack_on_signal (SIGFPE);
|
|
|
|
dump_gjs_stack_on_signal (SIGIOT);
|
|
|
|
dump_gjs_stack_on_signal (SIGTRAP);
|
|
|
|
|
|
|
|
if ((_shell_debug & SHELL_DEBUG_BACKTRACE_SEGFAULTS))
|
|
|
|
{
|
|
|
|
dump_gjs_stack_on_signal (SIGBUS);
|
|
|
|
dump_gjs_stack_on_signal (SIGSEGV);
|
|
|
|
}
|
|
|
|
|
2019-06-05 19:12:47 -04:00
|
|
|
shell_profiler_init ();
|
2011-05-05 18:09:59 -04:00
|
|
|
ecode = meta_run ();
|
2019-06-05 19:12:47 -04:00
|
|
|
shell_profiler_shutdown ();
|
2011-05-05 18:09:59 -04:00
|
|
|
|
2016-12-05 20:31:08 -05:00
|
|
|
g_debug ("Doing final cleanup");
|
|
|
|
_shell_global_destroy_gjs_context (shell_global_get ());
|
|
|
|
g_object_unref (shell_global_get ());
|
2011-06-20 09:01:54 -04:00
|
|
|
|
2011-05-05 18:09:59 -04:00
|
|
|
return ecode;
|
2011-02-25 11:20:27 -05:00
|
|
|
}
|