Blame SOURCES/0001-global-Allow-overriding-the-override-schema.patch

42f94a
From 96c97daca0db1ef56125873a8eebef86bdc8087a Mon Sep 17 00:00:00 2001
42f94a
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
42f94a
Date: Mon, 4 Jun 2018 13:45:06 -0400
42f94a
Subject: [PATCH] global: Allow overriding the override schema
42f94a
42f94a
---
42f94a
 src/main.c         | 11 ++++++++++-
42f94a
 src/shell-global.c | 20 +++++++++++++++++++-
42f94a
 2 files changed, 29 insertions(+), 2 deletions(-)
42f94a
42f94a
diff --git a/src/main.c b/src/main.c
42f94a
index 857877b0b..9d51ee5d1 100644
42f94a
--- a/src/main.c
42f94a
+++ b/src/main.c
42f94a
@@ -12,60 +12,61 @@
42f94a
 #include <clutter/clutter.h>
42f94a
 #include <clutter/x11/clutter-x11.h>
42f94a
 #include <gdk/gdk.h>
42f94a
 #include <gdk/gdkx.h>
42f94a
 #include <gtk/gtk.h>
42f94a
 #include <glib/gi18n-lib.h>
42f94a
 #include <girepository.h>
42f94a
 #include <meta/main.h>
42f94a
 #include <meta/meta-plugin.h>
42f94a
 #include <meta/prefs.h>
42f94a
 #include <atk-bridge.h>
42f94a
 
42f94a
 #include "shell-global.h"
42f94a
 #include "shell-global-private.h"
42f94a
 #include "shell-perf-log.h"
42f94a
 #include "st.h"
42f94a
 
42f94a
 extern GType gnome_shell_plugin_get_type (void);
42f94a
 
42f94a
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
42f94a
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
42f94a
 
42f94a
 #define OVERRIDES_SCHEMA "org.gnome.shell.overrides"
42f94a
 
42f94a
 #define WM_NAME "GNOME Shell"
42f94a
 #define GNOME_WM_KEYBINDINGS "Mutter,GNOME Shell"
42f94a
 
42f94a
 static gboolean is_gdm_mode = FALSE;
42f94a
 static char *session_mode = NULL;
42f94a
 static int caught_signal = 0;
42f94a
+static char *override_schema = NULL;
42f94a
 
42f94a
 #define DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1
42f94a
 #define DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4
42f94a
 
42f94a
 enum {
42f94a
   SHELL_DEBUG_BACKTRACE_WARNINGS = 1,
42f94a
   SHELL_DEBUG_BACKTRACE_SEGFAULTS = 2,
42f94a
 };
42f94a
 static int _shell_debug;
42f94a
 static gboolean _tracked_signals[NSIG] = { 0 };
42f94a
 
42f94a
 static void
42f94a
 shell_dbus_acquire_name (GDBusProxy  *bus,
42f94a
                          guint32      request_name_flags,
42f94a
                          guint32     *request_name_result,
42f94a
                          const gchar *name,
42f94a
                          gboolean     fatal)
42f94a
 {
42f94a
   GError *error = NULL;
42f94a
   GVariant *request_name_variant;
42f94a
 
42f94a
   if (!(request_name_variant = g_dbus_proxy_call_sync (bus,
42f94a
                                                        "RequestName",
42f94a
                                                        g_variant_new ("(su)", name, request_name_flags),
42f94a
                                                        0, /* call flags */
42f94a
                                                        -1, /* timeout */
42f94a
                                                        NULL, /* cancellable */
42f94a
                                                        &error)))
42f94a
     {
42f94a
       g_printerr ("failed to acquire %s: %s\n", name, error->message);
42f94a
@@ -423,110 +424,118 @@ print_version (const gchar    *option_name,
42f94a
 {
42f94a
   g_print ("GNOME Shell %s\n", VERSION);
42f94a
   exit (0);
42f94a
 }
42f94a
 
42f94a
 GOptionEntry gnome_shell_options[] = {
42f94a
   {
42f94a
     "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
42f94a
     print_version,
42f94a
     N_("Print version"),
42f94a
     NULL
42f94a
   },
42f94a
   {
42f94a
     "gdm-mode", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
42f94a
     &is_gdm_mode,
42f94a
     N_("Mode used by GDM for login screen"),
42f94a
     NULL
42f94a
   },
42f94a
   {
42f94a
     "mode", 0, 0, G_OPTION_ARG_STRING,
42f94a
     &session_mode,
42f94a
     N_("Use a specific mode, e.g. “gdm” for login screen"),
42f94a
     "MODE"
42f94a
   },
42f94a
   {
42f94a
     "list-modes", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
42f94a
     list_modes,
42f94a
     N_("List possible modes"),
42f94a
     NULL
42f94a
   },
42f94a
+  {
42f94a
+    "override-schema", 0, 0, G_OPTION_ARG_STRING,
42f94a
+    &override_schema,
42f94a
+    N_("Override the override schema"),
42f94a
+    "SCHEMA"
42f94a
+  },
42f94a
   { NULL }
42f94a
 };
42f94a
 
42f94a
 int
42f94a
 main (int argc, char **argv)
42f94a
 {
42f94a
   GOptionContext *ctx;
42f94a
   GError *error = NULL;
42f94a
   int ecode;
42f94a
 
42f94a
   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
42f94a
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
42f94a
   textdomain (GETTEXT_PACKAGE);
42f94a
 
42f94a
   session_mode = (char *) g_getenv ("GNOME_SHELL_SESSION_MODE");
42f94a
 
42f94a
   ctx = meta_get_option_context ();
42f94a
   g_option_context_add_main_entries (ctx, gnome_shell_options, GETTEXT_PACKAGE);
42f94a
   g_option_context_add_group (ctx, g_irepository_get_option_group ());
42f94a
   if (!g_option_context_parse (ctx, &argc, &argv, &error))
42f94a
     {
42f94a
       g_printerr ("%s: %s\n", argv[0], error->message);
42f94a
       exit (1);
42f94a
     }
42f94a
 
42f94a
   g_option_context_free (ctx);
42f94a
 
42f94a
   meta_plugin_manager_set_plugin_type (gnome_shell_plugin_get_type ());
42f94a
 
42f94a
   meta_set_wm_name (WM_NAME);
42f94a
   meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS);
42f94a
 
42f94a
   /* Prevent meta_init() from causing gtk to load the atk-bridge*/
42f94a
   g_setenv ("NO_AT_BRIDGE", "1", TRUE);
42f94a
   meta_init ();
42f94a
   g_unsetenv ("NO_AT_BRIDGE");
42f94a
 
42f94a
   /* FIXME: Add gjs API to set this stuff and don't depend on the
42f94a
    * environment.  These propagate to child processes.
42f94a
    */
42f94a
   g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
42f94a
   g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);
42f94a
 
42f94a
   shell_init_debug (g_getenv ("SHELL_DEBUG"));
42f94a
 
42f94a
   shell_dbus_init (meta_get_replace_current_wm ());
42f94a
   shell_a11y_init ();
42f94a
   shell_perf_log_init ();
42f94a
   shell_introspection_init ();
42f94a
   shell_fonts_init ();
42f94a
 
42f94a
   g_log_set_default_handler (default_log_handler, NULL);
42f94a
 
42f94a
   /* Initialize the global object */
42f94a
   if (session_mode == NULL)
42f94a
     session_mode = is_gdm_mode ? (char *)"gdm" : (char *)"user";
42f94a
 
42f94a
-  _shell_global_init ("session-mode", session_mode, NULL);
42f94a
+  _shell_global_init ("session-mode", session_mode,
42f94a
+                      "override-schema", override_schema,
42f94a
+                      NULL);
42f94a
 
42f94a
   shell_prefs_init ();
42f94a
 
42f94a
   dump_gjs_stack_on_signal (SIGABRT);
42f94a
   dump_gjs_stack_on_signal (SIGFPE);
42f94a
   dump_gjs_stack_on_signal (SIGIOT);
42f94a
   dump_gjs_stack_on_signal (SIGTRAP);
42f94a
 
42f94a
   if ((_shell_debug & SHELL_DEBUG_BACKTRACE_SEGFAULTS))
42f94a
     {
42f94a
       dump_gjs_stack_on_signal (SIGBUS);
42f94a
       dump_gjs_stack_on_signal (SIGSEGV);
42f94a
     }
42f94a
 
42f94a
   ecode = meta_run ();
42f94a
 
42f94a
   g_debug ("Doing final cleanup");
42f94a
   _shell_global_destroy_gjs_context (shell_global_get ());
42f94a
   g_object_unref (shell_global_get ());
42f94a
 
42f94a
   return ecode;
42f94a
 }
42f94a
diff --git a/src/shell-global.c b/src/shell-global.c
42f94a
index c67ac4e4a..961fd3a70 100644
42f94a
--- a/src/shell-global.c
42f94a
+++ b/src/shell-global.c
42f94a
@@ -38,158 +38,167 @@
42f94a
 /* Memory report bits */
42f94a
 #ifdef HAVE_MALLINFO
42f94a
 #include <malloc.h>
42f94a
 #endif
42f94a
 
42f94a
 #if defined __OpenBSD__ || defined __FreeBSD__
42f94a
 #include <sys/sysctl.h>
42f94a
 #endif
42f94a
 
42f94a
 #include "shell-enum-types.h"
42f94a
 #include "shell-global-private.h"
42f94a
 #include "shell-perf-log.h"
42f94a
 #include "shell-window-tracker.h"
42f94a
 #include "shell-wm.h"
42f94a
 #include "st.h"
42f94a
 
42f94a
 static ShellGlobal *the_object = NULL;
42f94a
 
42f94a
 struct _ShellGlobal {
42f94a
   GObject parent;
42f94a
 
42f94a
   ClutterStage *stage;
42f94a
   Window stage_xwindow;
42f94a
 
42f94a
   MetaDisplay *meta_display;
42f94a
   GdkDisplay *gdk_display;
42f94a
   Display *xdisplay;
42f94a
   MetaScreen *meta_screen;
42f94a
 
42f94a
   char *session_mode;
42f94a
+  char *override_schema;
42f94a
 
42f94a
   XserverRegion input_region;
42f94a
 
42f94a
   GjsContext *js_context;
42f94a
   MetaPlugin *plugin;
42f94a
   ShellWM *wm;
42f94a
   GSettings *settings;
42f94a
   const char *datadir;
42f94a
   char *imagedir;
42f94a
   char *userdatadir;
42f94a
   GFile *userdatadir_path;
42f94a
   GFile *runtime_state_path;
42f94a
 
42f94a
   StFocusManager *focus_manager;
42f94a
 
42f94a
   guint work_count;
42f94a
   GSList *leisure_closures;
42f94a
   guint leisure_function_id;
42f94a
 
42f94a
   /* For sound notifications */
42f94a
   ca_context *sound_context;
42f94a
 
42f94a
   gboolean has_modal;
42f94a
   gboolean frame_timestamps;
42f94a
   gboolean frame_finish_timestamp;
42f94a
 };
42f94a
 
42f94a
 enum {
42f94a
   PROP_0,
42f94a
 
42f94a
   PROP_SESSION_MODE,
42f94a
+  PROP_OVERRIDE_SCHEMA,
42f94a
   PROP_SCREEN,
42f94a
   PROP_DISPLAY,
42f94a
   PROP_SCREEN_WIDTH,
42f94a
   PROP_SCREEN_HEIGHT,
42f94a
   PROP_STAGE,
42f94a
   PROP_WINDOW_GROUP,
42f94a
   PROP_TOP_WINDOW_GROUP,
42f94a
   PROP_WINDOW_MANAGER,
42f94a
   PROP_SETTINGS,
42f94a
   PROP_DATADIR,
42f94a
   PROP_IMAGEDIR,
42f94a
   PROP_USERDATADIR,
42f94a
   PROP_FOCUS_MANAGER,
42f94a
   PROP_FRAME_TIMESTAMPS,
42f94a
   PROP_FRAME_FINISH_TIMESTAMP,
42f94a
 };
42f94a
 
42f94a
 /* Signals */
42f94a
 enum
42f94a
 {
42f94a
  NOTIFY_ERROR,
42f94a
  LAST_SIGNAL
42f94a
 };
42f94a
 
42f94a
 G_DEFINE_TYPE(ShellGlobal, shell_global, G_TYPE_OBJECT);
42f94a
 
42f94a
 static guint shell_global_signals [LAST_SIGNAL] = { 0 };
42f94a
 
42f94a
 static void
42f94a
 shell_global_set_property(GObject         *object,
42f94a
                           guint            prop_id,
42f94a
                           const GValue    *value,
42f94a
                           GParamSpec      *pspec)
42f94a
 {
42f94a
   ShellGlobal *global = SHELL_GLOBAL (object);
42f94a
 
42f94a
   switch (prop_id)
42f94a
     {
42f94a
     case PROP_SESSION_MODE:
42f94a
       g_clear_pointer (&global->session_mode, g_free);
42f94a
       global->session_mode = g_ascii_strdown (g_value_get_string (value), -1);
42f94a
       break;
42f94a
+    case PROP_OVERRIDE_SCHEMA:
42f94a
+      g_clear_pointer (&global->override_schema, g_free);
42f94a
+      global->override_schema = g_value_dup_string (value);
42f94a
+      break;
42f94a
     case PROP_FRAME_TIMESTAMPS:
42f94a
       global->frame_timestamps = g_value_get_boolean (value);
42f94a
       break;
42f94a
     case PROP_FRAME_FINISH_TIMESTAMP:
42f94a
       global->frame_finish_timestamp = g_value_get_boolean (value);
42f94a
       break;
42f94a
     default:
42f94a
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
42f94a
       break;
42f94a
     }
42f94a
 }
42f94a
 
42f94a
 static void
42f94a
 shell_global_get_property(GObject         *object,
42f94a
                           guint            prop_id,
42f94a
                           GValue          *value,
42f94a
                           GParamSpec      *pspec)
42f94a
 {
42f94a
   ShellGlobal *global = SHELL_GLOBAL (object);
42f94a
 
42f94a
   switch (prop_id)
42f94a
     {
42f94a
     case PROP_SESSION_MODE:
42f94a
       g_value_set_string (value, shell_global_get_session_mode (global));
42f94a
       break;
42f94a
+    case PROP_OVERRIDE_SCHEMA:
42f94a
+      g_value_set_string (value, global->override_schema);
42f94a
+      break;
42f94a
     case PROP_SCREEN:
42f94a
       g_value_set_object (value, global->meta_screen);
42f94a
       break;
42f94a
     case PROP_DISPLAY:
42f94a
       g_value_set_object (value, global->meta_display);
42f94a
       break;
42f94a
     case PROP_SCREEN_WIDTH:
42f94a
       {
42f94a
         int width, height;
42f94a
 
42f94a
         meta_screen_get_size (global->meta_screen, &width, &height);
42f94a
         g_value_set_int (value, width);
42f94a
       }
42f94a
       break;
42f94a
     case PROP_SCREEN_HEIGHT:
42f94a
       {
42f94a
         int width, height;
42f94a
 
42f94a
         meta_screen_get_size (global->meta_screen, &width, &height);
42f94a
         g_value_set_int (value, height);
42f94a
       }
42f94a
       break;
42f94a
     case PROP_STAGE:
42f94a
       g_value_set_object (value, global->stage);
42f94a
       break;
42f94a
     case PROP_WINDOW_GROUP:
42f94a
       g_value_set_object (value, meta_get_window_group_for_screen (global->meta_screen));
42f94a
       break;
42f94a
     case PROP_TOP_WINDOW_GROUP:
42f94a
       g_value_set_object (value, meta_get_top_window_group_for_screen (global->meta_screen));
42f94a
@@ -341,60 +350,67 @@ shell_global_finalize (GObject *object)
42f94a
   g_free (global->imagedir);
42f94a
   g_free (global->userdatadir);
42f94a
 
42f94a
   G_OBJECT_CLASS(shell_global_parent_class)->finalize (object);
42f94a
 }
42f94a
 
42f94a
 static void
42f94a
 shell_global_class_init (ShellGlobalClass *klass)
42f94a
 {
42f94a
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
42f94a
 
42f94a
   gobject_class->get_property = shell_global_get_property;
42f94a
   gobject_class->set_property = shell_global_set_property;
42f94a
   gobject_class->finalize = shell_global_finalize;
42f94a
 
42f94a
   shell_global_signals[NOTIFY_ERROR] =
42f94a
       g_signal_new ("notify-error",
42f94a
                     G_TYPE_FROM_CLASS (klass),
42f94a
                     G_SIGNAL_RUN_LAST,
42f94a
                     0,
42f94a
                     NULL, NULL, NULL,
42f94a
                     G_TYPE_NONE, 2,
42f94a
                     G_TYPE_STRING,
42f94a
                     G_TYPE_STRING);
42f94a
 
42f94a
   g_object_class_install_property (gobject_class,
42f94a
                                    PROP_SESSION_MODE,
42f94a
                                    g_param_spec_string ("session-mode",
42f94a
                                                         "Session Mode",
42f94a
                                                         "The session mode to use",
42f94a
+                                                        NULL,
42f94a
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
42f94a
+  g_object_class_install_property (gobject_class,
42f94a
+                                   PROP_OVERRIDE_SCHEMA,
42f94a
+                                   g_param_spec_string ("override-schema",
42f94a
+                                                        "Override Schema",
42f94a
+                                                        "The override schema to use",
42f94a
                                                         "user",
42f94a
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
42f94a
   g_object_class_install_property (gobject_class,
42f94a
                                    PROP_SCREEN,
42f94a
                                    g_param_spec_object ("screen",
42f94a
                                                         "Screen",
42f94a
                                                         "Metacity screen object for the shell",
42f94a
                                                         META_TYPE_SCREEN,
42f94a
                                                         G_PARAM_READABLE));
42f94a
 
42f94a
   g_object_class_install_property (gobject_class,
42f94a
                                    PROP_SCREEN_WIDTH,
42f94a
                                    g_param_spec_int ("screen-width",
42f94a
                                                      "Screen Width",
42f94a
                                                      "Screen width, in pixels",
42f94a
                                                      0, G_MAXINT, 1,
42f94a
                                                      G_PARAM_READABLE));
42f94a
 
42f94a
   g_object_class_install_property (gobject_class,
42f94a
                                    PROP_SCREEN_HEIGHT,
42f94a
                                    g_param_spec_int ("screen-height",
42f94a
                                                      "Screen Height",
42f94a
                                                      "Screen height, in pixels",
42f94a
                                                      0, G_MAXINT, 1,
42f94a
                                                      G_PARAM_READABLE));
42f94a
   g_object_class_install_property (gobject_class,
42f94a
                                    PROP_DISPLAY,
42f94a
                                    g_param_spec_object ("display",
42f94a
                                                         "Display",
42f94a
                                                         "Metacity display object for the shell",
42f94a
@@ -1333,61 +1349,63 @@ shell_global_sync_pointer (ShellGlobal *global)
42f94a
  * @global: A #ShellGlobal
42f94a
  *
42f94a
  * Get the global GSettings instance.
42f94a
  *
42f94a
  * Return value: (transfer none): The GSettings object
42f94a
  */
42f94a
 GSettings *
42f94a
 shell_global_get_settings (ShellGlobal *global)
42f94a
 {
42f94a
   return global->settings;
42f94a
 }
42f94a
 
42f94a
 /**
42f94a
  * shell_global_get_overrides_settings:
42f94a
  * @global: A #ShellGlobal
42f94a
  *
42f94a
  * Get the session overrides GSettings instance.
42f94a
  *
42f94a
  * Return value: (transfer none): The GSettings object
42f94a
  */
42f94a
 GSettings *
42f94a
 shell_global_get_overrides_settings (ShellGlobal *global)
42f94a
 {
42f94a
   static GSettings *settings = NULL;
42f94a
   const char *schema;
42f94a
 
42f94a
   g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
42f94a
 
42f94a
   if (!settings)
42f94a
     {
42f94a
-      if (strcmp (global->session_mode, "classic") == 0)
42f94a
+      if (global->override_schema != NULL)
42f94a
+        schema = global->override_schema;
42f94a
+      else if (strcmp (global->session_mode, "classic") == 0)
42f94a
         schema = "org.gnome.shell.extensions.classic-overrides";
42f94a
       else if (strcmp (global->session_mode, "user") == 0)
42f94a
         schema = "org.gnome.shell.overrides";
42f94a
       else
42f94a
         return NULL;
42f94a
 
42f94a
       settings = g_settings_new (schema);
42f94a
     }
42f94a
 
42f94a
   return settings;
42f94a
 }
42f94a
 
42f94a
 /**
42f94a
  * shell_global_get_current_time:
42f94a
  * @global: A #ShellGlobal
42f94a
  *
42f94a
  * Returns: the current X server time from the current Clutter, Gdk, or X
42f94a
  * event. If called from outside an event handler, this may return
42f94a
  * %Clutter.CURRENT_TIME (aka 0), or it may return a slightly
42f94a
  * out-of-date timestamp.
42f94a
  */
42f94a
 guint32
42f94a
 shell_global_get_current_time (ShellGlobal *global)
42f94a
 {
42f94a
   guint32 time;
42f94a
 
42f94a
   /* meta_display_get_current_time() will return the correct time
42f94a
      when handling an X or Gdk event, but will return CurrentTime
42f94a
      from some Clutter event callbacks.
42f94a
 
42f94a
-- 
42f94a
2.17.1
42f94a