gnome-settings-daemon/gsd-patches-behdad-f10.patch
Matthias Clasen 91ffc14878 2.24.1
2008-11-25 18:25:48 +00:00

1876 lines
69 KiB
Diff

diff --git a/data/gnome-settings-daemon.schemas.in b/data/gnome-settings-daemon.schemas.in
index 3f6a426..9b7d711 100644
--- a/data/gnome-settings-daemon.schemas.in
+++ b/data/gnome-settings-daemon.schemas.in
@@ -41,7 +41,7 @@
<applyto>/apps/gnome_settings_daemon/plugins/background/priority</applyto>
<owner>gnome-settings-daemon</owner>
<type>int</type>
- <default>5</default>
+ <default>97</default>
<locale name="C">
<short></short>
<long></long>
@@ -64,7 +64,7 @@
<applyto>/apps/gnome_settings_daemon/plugins/clipboard/priority</applyto>
<owner>gnome-settings-daemon</owner>
<type>int</type>
- <default>100</default>
+ <default>99</default>
<locale name="C">
<short></short>
<long></long>
@@ -179,7 +179,7 @@
<applyto>/apps/gnome_settings_daemon/plugins/media-keys/priority</applyto>
<owner>gnome-settings-daemon</owner>
<type>int</type>
- <default>20</default>
+ <default>98</default>
<locale name="C">
<short></short>
<long></long>
@@ -306,7 +306,7 @@
<applyto>/apps/gnome_settings_daemon/plugins/xrdb/active</applyto>
<owner>gnome-settings-daemon</owner>
<type>bool</type>
- <default>TRUE</default>
+ <default>FALSE</default>
<locale name="C">
<short>Enable xrdb plugin</short>
<long>Set to True to enable the plugin to manage xrdb settings.</long>
diff --git a/gnome-settings-daemon/gnome-settings-manager.c b/gnome-settings-daemon/gnome-settings-manager.c
index 0bc3f61..475c883 100644
--- a/gnome-settings-daemon/gnome-settings-manager.c
+++ b/gnome-settings-daemon/gnome-settings-manager.c
@@ -49,6 +49,7 @@
struct GnomeSettingsManagerPrivate
{
DBusGConnection *connection;
+ GConfClient *gconf_client;
char *settings_prefix;
GSList *plugins;
};
@@ -157,24 +158,21 @@ _load_file (GnomeSettingsManager *manager,
{
GnomeSettingsPluginInfo *info;
char *key_name;
- GConfClient *client;
int priority;
GError *error;
GSList *l;
g_debug ("Loading plugin: %s", filename);
- gnome_settings_profile_start (NULL);
+ gnome_settings_profile_start ("%s", filename);
info = gnome_settings_plugin_info_new_from_file (filename);
if (info == NULL) {
goto out;
}
- gnome_settings_profile_start ("seeing if already loaded");
l = g_slist_find_custom (manager->priv->plugins,
info,
(GCompareFunc) compare_location);
- gnome_settings_profile_end ("seeing if already loaded");
if (l != NULL) {
goto out;
}
@@ -187,21 +185,17 @@ _load_file (GnomeSettingsManager *manager,
g_signal_connect (info, "deactivated",
G_CALLBACK (on_plugin_deactivated), manager);
- gnome_settings_profile_start ("setting active property");
key_name = g_strdup_printf ("%s/%s/active",
manager->priv->settings_prefix,
gnome_settings_plugin_info_get_location (info));
gnome_settings_plugin_info_set_enabled_key_name (info, key_name);
g_free (key_name);
- gnome_settings_profile_end ("setting active property");
- gnome_settings_profile_start ("setting priority property");
key_name = g_strdup_printf ("%s/%s/priority",
manager->priv->settings_prefix,
gnome_settings_plugin_info_get_location (info));
- client = gconf_client_get_default ();
error = NULL;
- priority = gconf_client_get_int (client, key_name, &error);
+ priority = gconf_client_get_int (manager->priv->gconf_client, key_name, &error);
if (error == NULL) {
if (priority > 0) {
gnome_settings_plugin_info_set_priority (info, priority);
@@ -210,15 +204,13 @@ _load_file (GnomeSettingsManager *manager,
g_error_free (error);
}
g_free (key_name);
- g_object_unref (client);
- gnome_settings_profile_end ("setting priority property");
out:
if (info != NULL) {
g_object_unref (info);
}
- gnome_settings_profile_end (NULL);
+ gnome_settings_profile_end ("%s", filename);
}
static void
@@ -345,6 +337,15 @@ gnome_settings_manager_start (GnomeSettingsManager *manager,
goto out;
}
+ manager->priv->gconf_client = gconf_client_get_default ();
+
+ gnome_settings_profile_start ("preloading gconf keys");
+ gconf_client_add_dir (manager->priv->gconf_client,
+ manager->priv->settings_prefix,
+ GCONF_CLIENT_PRELOAD_RECURSIVE,
+ NULL);
+ gnome_settings_profile_end ("preloading gconf keys");
+
_load_all (manager);
ret = TRUE;
@@ -379,6 +380,12 @@ gnome_settings_manager_stop (GnomeSettingsManager *manager)
#endif
_unload_all (manager);
+
+ gconf_client_remove_dir (manager->priv->gconf_client,
+ manager->priv->settings_prefix,
+ NULL);
+ g_object_unref (manager->priv->gconf_client);
+ manager->priv->gconf_client = NULL;
}
static void
diff --git a/gnome-settings-daemon/gnome-settings-plugin-info.c b/gnome-settings-daemon/gnome-settings-plugin-info.c
index 983a3e1..a4a10a8 100644
--- a/gnome-settings-daemon/gnome-settings-plugin-info.c
+++ b/gnome-settings-daemon/gnome-settings-plugin-info.c
@@ -185,7 +185,7 @@ gnome_settings_plugin_info_fill_from_file (GnomeSettingsPluginInfo *info,
int priority;
gboolean ret;
- gnome_settings_profile_start (NULL);
+ gnome_settings_profile_start ("%s", filename);
ret = FALSE;
@@ -290,7 +290,7 @@ gnome_settings_plugin_info_fill_from_file (GnomeSettingsPluginInfo *info,
ret = TRUE;
out:
- gnome_settings_profile_end (NULL);
+ gnome_settings_profile_end ("%s", filename);
return ret;
}
@@ -312,15 +312,6 @@ void
gnome_settings_plugin_info_set_enabled_key_name (GnomeSettingsPluginInfo *info,
const char *key_name)
{
- char *dirname;
-
- dirname = g_path_get_dirname (key_name);
- if (dirname != NULL) {
- g_debug ("Monitoring dir %s for changes", dirname);
- gconf_client_add_dir (info->priv->client, dirname, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- g_free (dirname);
- }
-
info->priv->enabled_notification_id = gconf_client_notify_add (info->priv->client,
key_name,
(GConfClientNotifyFunc)plugin_enabled_cb,
@@ -388,7 +379,7 @@ load_plugin_module (GnomeSettingsPluginInfo *info)
g_return_val_if_fail (info->priv->plugin == NULL, FALSE);
g_return_val_if_fail (info->priv->available, FALSE);
- gnome_settings_profile_start (NULL);
+ gnome_settings_profile_start ("%s", info->priv->location);
switch (info->priv->loader) {
case GNOME_SETTINGS_PLUGIN_LOADER_C:
@@ -484,7 +475,7 @@ load_plugin_module (GnomeSettingsPluginInfo *info)
g_type_module_unuse (info->priv->module);
ret = TRUE;
out:
- gnome_settings_profile_end (NULL);
+ gnome_settings_profile_end ("%s", info->priv->location);
return ret;
}
diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c
index b4c43d2..c96381b 100644
--- a/gnome-settings-daemon/main.c
+++ b/gnome-settings-daemon/main.c
@@ -24,6 +24,9 @@
#include <libintl.h>
#include <errno.h>
#include <locale.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/wait.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
@@ -44,6 +47,7 @@
static char *gconf_prefix = NULL;
static gboolean no_daemon = FALSE;
static gboolean debug = FALSE;
+static int pipefds[2];
static GOptionEntry entries[] = {
{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -187,10 +191,10 @@ set_session_over_handler (DBusGConnection *bus, GnomeSettingsManager *manager)
GNOME_SESSION_DBUS_OBJECT,
GNOME_SESSION_DBUS_INTERFACE);
- dbus_g_object_register_marshaller (
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ G_TYPE_INVALID);
dbus_g_proxy_add_signal (session_proxy,
"SessionOver",
@@ -223,6 +227,119 @@ gsd_log_default_handler (const gchar *log_domain,
unused_data);
}
+
+/* We want the parent process to quit after initializing all plugins,
+ * but we have to do all the work in the child process. We can't
+ * initialize in parent and then fork here: that is not clean with
+ * X display and DBUS where we would make the connection from one
+ * process and continue using it from the other. So, we just make the
+ * parent to fork early and wait. */
+
+static void
+daemon_start (void)
+{
+ int child_pid;
+ char buf[1];
+
+ if (no_daemon)
+ return;
+
+ gnome_settings_profile_msg ("forking daemon");
+
+ signal (SIGPIPE, SIG_IGN);
+ if (-1 == pipe (pipefds)) {
+ g_error ("Could not create pipe: %s", g_strerror (errno));
+ exit (EXIT_FAILURE);
+ }
+
+ child_pid = fork ();
+
+ switch (child_pid) {
+ case -1:
+ g_error ("Could not daemonize: %s", g_strerror (errno));
+ exit (EXIT_FAILURE);
+
+ case 0:
+ /* child */
+
+ close (pipefds[0]);
+
+ return;
+
+ default:
+ /* parent */
+
+ close (pipefds[1]);
+
+ /* Wait for child to signal that we are good to go. */
+ read (pipefds[0], buf, 1);
+
+ exit (EXIT_SUCCESS);
+ }
+}
+
+static void
+daemon_detach (void)
+{
+ if (no_daemon)
+ return;
+
+ gnome_settings_profile_msg ("detaching daemon");
+
+ /* disconnect */
+ setsid ();
+ close (0);
+ close (1);
+ open ("/dev/null", O_RDONLY);
+ open ("/dev/null", O_WRONLY);
+
+ /* get outta the way */
+ chdir ("/");
+ umask (0117);
+}
+
+static void
+daemon_terminate_parent (void)
+{
+ if (no_daemon)
+ return;
+
+ gnome_settings_profile_msg ("terminating parent");
+
+ write (pipefds[1], "1", 1);
+ close (pipefds[1]);
+}
+
+static void
+parse_args (int *argc, char ***argv)
+{
+ GError *error;
+ GOptionContext *context;
+
+ gnome_settings_profile_start (NULL);
+
+
+ context = g_option_context_new (NULL);
+
+ g_option_context_add_main_entries (context, entries, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (FALSE));
+
+ error = NULL;
+ if (!g_option_context_parse (context, argc, argv, &error)) {
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ } else {
+ g_warning ("Unable to initialize GTK+");
+ }
+ exit (EXIT_FAILURE);
+ }
+
+ g_option_context_free (context);
+
+ gnome_settings_profile_end (NULL);
+}
+
int
main (int argc, char *argv[])
{
@@ -238,29 +355,25 @@ main (int argc, char *argv[])
bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
-
setlocale (LC_ALL, "");
+ parse_args (&argc, &argv);
+
+ daemon_start ();
+
g_type_init ();
- gnome_settings_profile_start ("gtk init");
- error = NULL;
- if (! gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error)) {
- if (error != NULL) {
- g_warning (error->message);
- g_error_free (error);
- } else {
- g_warning ("Unable to initialize GTK+");
- }
- exit (1);
+ gnome_settings_profile_start ("opening gtk display");
+ if (! gtk_init_check (NULL, NULL)) {
+ g_warning ("Unable to initialize GTK+");
+ daemon_terminate_parent ();
+ exit (EXIT_FAILURE);
}
- gnome_settings_profile_end ("gtk init");
+ gnome_settings_profile_end ("opening gtk display");
- g_log_set_default_handler (gsd_log_default_handler, NULL);
+ daemon_detach ();
- if (! no_daemon && daemon (0, 0)) {
- g_error ("Could not daemonize: %s", g_strerror (errno));
- }
+ g_log_set_default_handler (gsd_log_default_handler, NULL);
bus = get_session_bus ();
if (bus == NULL) {
@@ -298,6 +411,8 @@ main (int argc, char *argv[])
}
}
+ daemon_terminate_parent ();
+
gtk_main ();
out:
diff --git a/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c b/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
index eaea1a3..3a990db 100644
--- a/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
+++ b/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
@@ -71,15 +71,10 @@ struct GsdA11yKeyboardManagerPrivate
#endif /* HAVE_LIBNOTIFY */
};
-#define GSD_KBD_A11Y_ERROR gsd_kbd_a11y_error_quark ()
-
-enum {
- GSD_KBD_A11Y_ERROR_NOT_AVAILABLE
-};
-
static void gsd_a11y_keyboard_manager_class_init (GsdA11yKeyboardManagerClass *klass);
static void gsd_a11y_keyboard_manager_init (GsdA11yKeyboardManager *a11y_keyboard_manager);
static void gsd_a11y_keyboard_manager_finalize (GObject *object);
+static void gsd_a11y_keyboard_manager_ensure_status_icon (GsdA11yKeyboardManager *manager);
G_DEFINE_TYPE (GsdA11yKeyboardManager, gsd_a11y_keyboard_manager, G_TYPE_OBJECT)
@@ -92,19 +87,12 @@ static gpointer manager_object = NULL;
#define d(str) do { } while (0)
#endif
-static GQuark
-gsd_kbd_a11y_error_quark (void)
-{
- return g_quark_from_static_string ("gsd-kbd-a11y-error-quark");
-}
-
static gboolean
xkb_enabled (GsdA11yKeyboardManager *manager)
{
gboolean have_xkb;
int opcode, errorBase, major, minor;
- gdk_error_trap_push ();
have_xkb = XkbQueryExtension (GDK_DISPLAY (),
&opcode,
&manager->priv->xkbEventBase,
@@ -112,8 +100,6 @@ xkb_enabled (GsdA11yKeyboardManager *manager)
&major,
&minor)
&& XkbUseExtension (GDK_DISPLAY (), &major, &minor);
- XSync (GDK_DISPLAY (), FALSE);
- gdk_error_trap_pop ();
return have_xkb;
}
@@ -130,7 +116,6 @@ get_xkb_desc_rec (GsdA11yKeyboardManager *manager)
desc->ctrls = NULL;
status = XkbGetControls (GDK_DISPLAY (), XkbAllControlsMask, desc);
}
- XSync (GDK_DISPLAY (), FALSE);
gdk_error_trap_pop ();
g_return_val_if_fail (desc != NULL, NULL);
@@ -449,6 +434,10 @@ maybe_show_status_icon (GsdA11yKeyboardManager *manager)
show = gconf_client_get_bool (client, CONFIG_ROOT "/enable", NULL);
g_object_unref (client);
+ if (!show && manager->priv->status_icon == NULL)
+ return;
+
+ gsd_a11y_keyboard_manager_ensure_status_icon (manager);
gtk_status_icon_set_visible (manager->priv->status_icon, show);
}
@@ -538,7 +527,7 @@ ax_slowkeys_warning_post_bubble (GsdA11yKeyboardManager *manager,
message = _("You just held down the Shift key for 8 seconds. This is the shortcut "
"for the Slow Keys feature, which affects the way your keyboard works.");
- if (! gtk_status_icon_is_embedded (manager->priv->status_icon)) {
+ if (manager->priv->status_icon == NULL || ! gtk_status_icon_is_embedded (manager->priv->status_icon)) {
return FALSE;
}
@@ -553,6 +542,7 @@ ax_slowkeys_warning_post_bubble (GsdA11yKeyboardManager *manager,
manager->priv->notification = NULL;
}
+ gsd_a11y_keyboard_manager_ensure_status_icon (manager);
manager->priv->notification = notify_notification_new_with_status_icon (title,
message,
"preferences-desktop-accessibility",
@@ -681,7 +671,7 @@ ax_stickykeys_warning_post_bubble (GsdA11yKeyboardManager *manager,
_("You just pressed two keys at once, or pressed the Shift key 5 times in a row. "
"This turns off the Sticky Keys feature, which affects the way your keyboard works.");
- if (! gtk_status_icon_is_embedded (manager->priv->status_icon)) {
+ if (manager->priv->status_icon == NULL || ! gtk_status_icon_is_embedded (manager->priv->status_icon)) {
return FALSE;
}
@@ -696,6 +686,7 @@ ax_stickykeys_warning_post_bubble (GsdA11yKeyboardManager *manager,
manager->priv->notification = NULL;
}
+ gsd_a11y_keyboard_manager_ensure_status_icon (manager);
manager->priv->notification = notify_notification_new_with_status_icon (title,
message,
"preferences-desktop-accessibility",
@@ -997,27 +988,21 @@ register_config_callback (GsdA11yKeyboardManager *manager,
GConfClientNotifyFunc func,
guint *notify)
{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
*notify = gconf_client_notify_add (client, path, func, manager, NULL, NULL);
}
-gboolean
-gsd_a11y_keyboard_manager_start (GsdA11yKeyboardManager *manager,
- GError **error)
+static gboolean
+start_a11y_keyboard_idle_cb (GsdA11yKeyboardManager *manager)
{
guint event_mask;
GConfClient *client;
- gboolean ret = FALSE;
g_debug ("Starting a11y_keyboard manager");
gnome_settings_profile_start (NULL);
- if (!xkb_enabled (manager)) {
- g_set_error (error, GSD_KBD_A11Y_ERROR,
- GSD_KBD_A11Y_ERROR_NOT_AVAILABLE,
- "XKB functionality is disabled.");
+ if (!xkb_enabled (manager))
goto out;
- }
client = gconf_client_get_default ();
@@ -1036,26 +1021,35 @@ gsd_a11y_keyboard_manager_start (GsdA11yKeyboardManager *manager,
set_server_from_gconf (manager, client);
g_object_unref (client);
- gdk_error_trap_push ();
XkbSelectEvents (GDK_DISPLAY (),
XkbUseCoreKbd,
event_mask,
event_mask);
- XSync (GDK_DISPLAY (), FALSE);
- gdk_error_trap_pop ();
-
gdk_window_add_filter (NULL,
(GdkFilterFunc) cb_xkb_event_filter,
manager);
maybe_show_status_icon (manager);
- ret = TRUE;
-
out:
gnome_settings_profile_end (NULL);
- return ret;
+
+ return FALSE;
+}
+
+
+gboolean
+gsd_a11y_keyboard_manager_start (GsdA11yKeyboardManager *manager,
+ GError **error)
+{
+ gnome_settings_profile_start (NULL);
+
+ g_idle_add ((GSourceFunc) start_a11y_keyboard_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+
+ return TRUE;
}
void
@@ -1065,7 +1059,8 @@ gsd_a11y_keyboard_manager_stop (GsdA11yKeyboardManager *manager)
g_debug ("Stopping a11y_keyboard manager");
- gtk_status_icon_set_visible (manager->priv->status_icon, FALSE);
+ if (manager->priv->status_icon)
+ gtk_status_icon_set_visible (manager->priv->status_icon, FALSE);
if (p->gconf_notify != 0) {
GConfClient *client = gconf_client_get_default ();
@@ -1199,16 +1194,27 @@ on_status_icon_activate (GtkStatusIcon *status_icon,
}
static void
+gsd_a11y_keyboard_manager_ensure_status_icon (GsdA11yKeyboardManager *manager)
+{
+ gnome_settings_profile_start (NULL);
+
+ if (!manager->priv->status_icon) {
+
+ manager->priv->status_icon = gtk_status_icon_new_from_icon_name ("preferences-desktop-accessibility");
+ g_signal_connect (manager->priv->status_icon,
+ "activate",
+ G_CALLBACK (on_status_icon_activate),
+ manager);
+ }
+
+ gnome_settings_profile_end (NULL);
+}
+
+static void
gsd_a11y_keyboard_manager_init (GsdA11yKeyboardManager *manager)
{
manager->priv = GSD_A11Y_KEYBOARD_MANAGER_GET_PRIVATE (manager);
- manager->priv->status_icon = gtk_status_icon_new_from_icon_name ("preferences-desktop-accessibility");
- g_signal_connect (manager->priv->status_icon,
- "activate",
- G_CALLBACK (on_status_icon_activate),
- manager);
-
#ifdef HAVE_LIBNOTIFY
notify_init ("gnome-settings-daemon");
#endif /* HAVE_LIBNOTIFY */
diff --git a/plugins/clipboard/gsd-clipboard-manager.c b/plugins/clipboard/gsd-clipboard-manager.c
index 5f407df..f8cb7ec 100644
--- a/plugins/clipboard/gsd-clipboard-manager.c
+++ b/plugins/clipboard/gsd-clipboard-manager.c
@@ -82,13 +82,6 @@ typedef struct
int offset;
} IncrConversion;
-#define GSD_CLIPBOARD_ERROR gsd_clipboard_error_quark ()
-
-enum {
- GSD_CLIPBOARD_ERROR_RUNNING,
- GSD_CLIPBOARD_ERROR_FAILED
-};
-
static void gsd_clipboard_manager_class_init (GsdClipboardManagerClass *klass);
static void gsd_clipboard_manager_init (GsdClipboardManager *clipboard_manager);
static void gsd_clipboard_manager_finalize (GObject *object);
@@ -103,12 +96,6 @@ G_DEFINE_TYPE (GsdClipboardManager, gsd_clipboard_manager, G_TYPE_OBJECT)
static gpointer manager_object = NULL;
-static GQuark
-gsd_clipboard_error_quark (void)
-{
- return g_quark_from_static_string ("gsd-clipboard-error-quark");
-}
-
/* We need to use reference counting for the target data, since we may
* need to keep the data around after loosing the CLIPBOARD ownership
* to complete incremental transfers.
@@ -858,22 +845,19 @@ clipboard_manager_watch_cb (GsdClipboardManager *manager,
}
}
-gboolean
-gsd_clipboard_manager_start (GsdClipboardManager *manager,
- GError **error)
+static gboolean
+start_clipboard_idle_cb (GsdClipboardManager *manager)
{
XClientMessageEvent xev;
- g_debug ("Starting clipboard manager");
+
gnome_settings_profile_start (NULL);
init_atoms (manager->priv->display);
/* check if there is a clipboard manager running */
if (XGetSelectionOwner (manager->priv->display, XA_CLIPBOARD_MANAGER)) {
- g_set_error (error, GSD_CLIPBOARD_ERROR,
- GSD_CLIPBOARD_ERROR_RUNNING,
- "Clipboard manager is already running.");
+ g_warning ("Clipboard manager is already running.");
return FALSE;
}
@@ -929,15 +913,23 @@ gsd_clipboard_manager_start (GsdClipboardManager *manager,
0,
NULL);
/* FIXME: manager->priv->terminate (manager->priv->cb_data); */
-
- g_set_error (error, GSD_CLIPBOARD_ERROR,
- GSD_CLIPBOARD_ERROR_FAILED,
- "Failed to claim selection.");
- return FALSE;
}
gnome_settings_profile_end (NULL);
+ return FALSE;
+}
+
+gboolean
+gsd_clipboard_manager_start (GsdClipboardManager *manager,
+ GError **error)
+{
+ gnome_settings_profile_start (NULL);
+
+ g_idle_add ((GSourceFunc) start_clipboard_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+
return TRUE;
}
diff --git a/plugins/common/gsd-keygrab.c b/plugins/common/gsd-keygrab.c
index 6f47b36..cdb7605 100644
--- a/plugins/common/gsd-keygrab.c
+++ b/plugins/common/gsd-keygrab.c
@@ -42,7 +42,7 @@ static GdkModifierType gsd_ignored_mods = 0;
static GdkModifierType gsd_used_mods = 0;
static void
-setup_modifiers ()
+setup_modifiers (void)
{
if (gsd_used_mods == 0 || gsd_ignored_mods == 0) {
GdkModifierType dynmods;
@@ -67,13 +67,12 @@ setup_modifiers ()
}
}
-static gboolean
+static void
grab_key_real (guint keycode,
GdkWindow *root,
gboolean grab,
int mask)
{
- gdk_error_trap_push ();
if (grab) {
XGrabKey (GDK_DISPLAY (),
keycode,
@@ -88,21 +87,33 @@ grab_key_real (guint keycode,
mask,
GDK_WINDOW_XID (root));
}
-
- gdk_flush ();
- return gdk_error_trap_pop () == 0;
}
/* Grab the key. In order to ignore GSD_IGNORED_MODS we need to grab
* all combinations of the ignored modifiers and those actually used
* for the binding (if any).
*
- * inspired by all_combinations from gnome-panel/gnome-panel/global-keys.c */
+ * inspired by all_combinations from gnome-panel/gnome-panel/global-keys.c
+ *
+ * This may generate X errors. The correct way to use this is like:
+ *
+ * gdk_error_trap_push ();
+ *
+ * grab_key_unsafe (key, grab, screens);
+ *
+ * gdk_flush ();
+ * if (gdk_error_trap_pop ())
+ * g_warning ("Grab failed, another application may already have access to key '%u'",
+ * key->keycode);
+ *
+ * This is not done in the function itself, to allow doing multiple grab_key
+ * operations with one flush only.
+ */
#define N_BITS 32
void
-grab_key (Key *key,
- gboolean grab,
- GSList *screens)
+grab_key_unsafe (Key *key,
+ gboolean grab,
+ GSList *screens)
{
int indexes[N_BITS]; /* indexes of bits we need to flip */
int i;
@@ -141,14 +152,10 @@ grab_key (Key *key,
for (l = screens; l; l = l->next) {
GdkScreen *screen = l->data;
- if (!grab_key_real (key->keycode,
- gdk_screen_get_root_window (screen),
- grab,
- result | key->state)) {
- g_warning ("Grab failed, another application may already have access to key '%u'",
- key->keycode);
- return;
- }
+ grab_key_real (key->keycode,
+ gdk_screen_get_root_window (screen),
+ grab,
+ result | key->state);
}
}
}
@@ -162,7 +169,6 @@ have_xkb (Display *dpy)
#ifdef HAVE_X11_EXTENSIONS_XKB_H
int opcode, error_base, major, minor, xkb_event_base;
- gdk_error_trap_push ();
have_xkb = XkbQueryExtension (dpy,
&opcode,
&xkb_event_base,
@@ -170,7 +176,6 @@ have_xkb (Display *dpy)
&major,
&minor)
&& XkbUseExtension (dpy, &major, &minor);
- gdk_error_trap_pop ();
#else
have_xkb = 0;
#endif
diff --git a/plugins/common/gsd-keygrab.h b/plugins/common/gsd-keygrab.h
index 6dde2a0..035aee8 100644
--- a/plugins/common/gsd-keygrab.h
+++ b/plugins/common/gsd-keygrab.h
@@ -32,7 +32,7 @@ typedef struct {
} Key;
-void grab_key (Key *key,
+void grab_key_unsafe (Key *key,
gboolean grab,
GSList *screens);
diff --git a/plugins/font/gsd-font-manager.c b/plugins/font/gsd-font-manager.c
index bb2fd28..7b6ce89 100644
--- a/plugins/font/gsd-font-manager.c
+++ b/plugins/font/gsd-font-manager.c
@@ -78,6 +78,7 @@ child_watch_cb (GPid pid,
{
char *command = user_data;
+ gnome_settings_profile_end ("%s", command);
if (!WIFEXITED (status) || WEXITSTATUS (status)) {
g_warning ("Command %s failed", command);
}
@@ -100,6 +101,7 @@ spawn_with_input (const char *command,
return;
}
+ gnome_settings_profile_start ("%s", command);
error = NULL;
res = g_spawn_async_with_pipes (NULL,
argv,
@@ -177,134 +179,185 @@ load_xcursor_theme (GConfClient *client)
gnome_settings_profile_end (NULL);
}
-static void
-load_cursor (GConfClient *client)
+static char*
+setup_dir (const char *font_dir_name, gboolean create)
{
- DIR *dir;
- char *font_dir_name;
- char *dir_name;
- struct dirent *file_dirent;
- char *cursor_font;
- char **font_path;
- char **new_font_path;
- int n_fonts;
- int new_n_fonts;
- int i;
- char *mkfontdir_cmd;
+ char *font_dir;
- gnome_settings_profile_start (NULL);
+ font_dir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "share", font_dir_name, NULL);
- /* setting up the dir */
- font_dir_name = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2/share/fonts", NULL);
- if (! g_file_test (font_dir_name, G_FILE_TEST_EXISTS)) {
- if (g_mkdir_with_parents (font_dir_name, 0755) != 0) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Cannot create the directory \"%s\".\n"\
- "This is needed to allow changing the mouse pointer theme."),
- font_dir_name);
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- NULL);
- gnome_settings_delayed_show_dialog (dialog);
- g_free (font_dir_name);
-
- return;
+ if (create) {
+ if (g_mkdir_with_parents (font_dir, 0755) != 0) {
+ g_warning ("Cannot create needed directory \"%s\".", font_dir);
+ g_free (font_dir);
+ font_dir = NULL;
}
+ } else if (! g_file_test (font_dir, G_FILE_TEST_EXISTS)) {
+ g_free (font_dir);
+ font_dir = NULL;
}
- dir_name = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2/share/cursor-fonts", NULL);
- if (! g_file_test (dir_name, G_FILE_TEST_EXISTS)) {
- if (g_mkdir_with_parents (dir_name, 0755) != 0) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- (_("Cannot create the directory \"%s\".\n"\
- "This is needed to allow changing cursors.")),
- dir_name);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gnome_settings_delayed_show_dialog (dialog);
- g_free (dir_name);
-
- return;
- }
- }
+ return font_dir;
+}
- dir = opendir (dir_name);
+static char *
+empty_check_dir (char *font_dir)
+{
+ char *file_name;
- while ((file_dirent = readdir (dir)) != NULL) {
- struct stat st;
- char *link_name;
+ if (!font_dir)
+ return NULL;
- link_name = g_build_filename (dir_name, file_dirent->d_name, NULL);
- if (lstat (link_name, &st)) {
- g_free (link_name);
- continue;
- }
- g_free (link_name);
+ /* remove the fonts.dir and fonts.scale files that mkfontdir generates. */
- if (S_ISLNK (st.st_mode))
- unlink (link_name);
+ file_name = g_build_filename (G_DIR_SEPARATOR_S, font_dir, "fonts.dir", NULL);
+ unlink (file_name);
+ g_free (file_name);
+
+ file_name = g_build_filename (G_DIR_SEPARATOR_S, font_dir, "fonts.scale", NULL);
+ unlink (file_name);
+ g_free (file_name);
+
+ /* if it's empty, get rid of it. */
+ if (0 == rmdir (font_dir)) {
+ g_free (font_dir);
+ font_dir = NULL;
}
- closedir (dir);
+ return font_dir;
+}
+
+static char*
+setup_font_dir (GConfClient *client)
+{
+ return empty_check_dir (setup_dir ("fonts", FALSE));
+}
+
+static char*
+setup_cursor_dir (GConfClient *client)
+{
+ char *cursor_dir;
+ char *cursor_font;
+ DIR *dir;
+ struct dirent *file_dirent;
cursor_font = gconf_client_get_string (client,
"/desktop/gnome/peripherals/mouse/cursor_font",
NULL);
+ if (cursor_font != NULL) {
+ if (!g_path_is_absolute (cursor_font) ||
+ !g_file_test (cursor_font, G_FILE_TEST_IS_REGULAR)) {
+ /* font file is not usable */
+ g_free (cursor_font);
+ cursor_font = NULL;
+ }
+ }
+
+ cursor_dir = setup_dir ("cursor-fonts", cursor_font != NULL);
+
+ /* remove previously made symlinks, if any */
+ if (cursor_dir) {
+ dir = opendir (cursor_dir);
+ while ((file_dirent = readdir (dir)) != NULL) {
+ struct stat st;
+ char *link_name;
+
+ link_name = g_build_filename (cursor_dir, file_dirent->d_name, NULL);
+ if (lstat (link_name, &st)) {
+ g_free (link_name);
+ continue;
+ }
+ g_free (link_name);
- if ((cursor_font != NULL) &&
- (g_file_test (cursor_font, G_FILE_TEST_IS_REGULAR)) &&
- (g_path_is_absolute (cursor_font))) {
+ if (S_ISLNK (st.st_mode))
+ unlink (link_name);
+ }
+ closedir (dir);
+ }
+
+ if (cursor_font && cursor_dir) {
char *newpath;
char *font_name;
font_name = strrchr (cursor_font, G_DIR_SEPARATOR);
- newpath = g_build_filename (dir_name, font_name, NULL);
+ newpath = g_build_filename (cursor_dir, font_name, NULL);
symlink (cursor_font, newpath);
g_free (newpath);
+ g_free (cursor_font);
+ cursor_font = NULL;
+ } else {
+ cursor_dir = empty_check_dir (cursor_dir);
}
- g_free (cursor_font);
+
+ return cursor_dir;
+}
+
+static void
+load_font_paths (GConfClient *client)
+{
+ char *font_dir_name;
+ char *cursor_dir_name;
+
+ char **font_path;
+ char **new_font_path;
+ int n_fonts;
+ int new_n_fonts;
+
+ int i;
+
+ const char *argv[4];
+ int argc = 0;
+
+ gnome_settings_profile_start (NULL);
+
+ font_dir_name = setup_font_dir (client);
+ cursor_dir_name = setup_cursor_dir (client);
+
+ if (font_dir_name == NULL && cursor_dir_name == NULL)
+ goto done;
/* run mkfontdir */
- mkfontdir_cmd = g_strdup_printf ("mkfontdir %s %s", dir_name, font_dir_name);
- /* maybe check for error...
- * also, it's not going to like that if there are spaces in dir_name/font_dir_name.
- */
- g_spawn_command_line_sync (mkfontdir_cmd, NULL, NULL, NULL, NULL);
- g_free (mkfontdir_cmd);
+ argv[argc++] = "mkfontdir";
+ if (font_dir_name)
+ argv[argc++] = font_dir_name;
+ if (cursor_dir_name)
+ argv[argc++] = cursor_dir_name;
+ argv[argc] = NULL;
+ g_spawn_sync (NULL, /* current dir */
+ (char **) (void *) argv, NULL /* envp */,
+ G_SPAWN_SEARCH_PATH,
+ NULL, NULL, /* child_setup */
+ NULL, NULL, NULL, NULL);
/* Set the font path */
font_path = XGetFontPath (gdk_x11_get_default_xdisplay (), &n_fonts);
new_n_fonts = n_fonts;
- if (n_fonts == 0 || strcmp (font_path[0], dir_name))
+ if (cursor_dir_name && (n_fonts == 0 || strcmp (font_path[0], cursor_dir_name)))
new_n_fonts++;
- if (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name))
+ if (font_dir_name && (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name)))
new_n_fonts++;
- new_font_path = g_new0 (char *, new_n_fonts);
- if (n_fonts == 0 || strcmp (font_path[0], dir_name)) {
- new_font_path[0] = dir_name;
- for (i = 0; i < n_fonts; i++)
- new_font_path [i+1] = font_path [i];
- } else {
- for (i = 0; i < n_fonts; i++)
- new_font_path [i] = font_path [i];
- }
+ if (new_n_fonts == n_fonts)
+ new_font_path = font_path;
+ else {
+ new_font_path = g_new0 (char *, new_n_fonts);
+
+ if (cursor_dir_name && (n_fonts == 0 || strcmp (font_path[0], cursor_dir_name))) {
+ new_font_path[0] = cursor_dir_name;
+ for (i = 0; i < n_fonts; i++)
+ new_font_path [i+1] = font_path [i];
+ } else {
+ for (i = 0; i < n_fonts; i++)
+ new_font_path [i] = font_path [i];
+ }
- if (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name)) {
- new_font_path[new_n_fonts-1] = font_dir_name;
+ if (font_dir_name && (n_fonts == 0 || strcmp (font_path[n_fonts-1], font_dir_name))) {
+ new_font_path[new_n_fonts-1] = font_dir_name;
+ }
}
+ /* We set font path even if it was not changed, to enforce dropping
+ * caches in the server */
gdk_error_trap_push ();
XSetFontPath (gdk_display, new_font_path, new_n_fonts);
gdk_flush ();
@@ -314,13 +367,16 @@ load_cursor (GConfClient *client)
XSetFontPath (gdk_display, font_path, n_fonts);
}
+ g_free (font_dir_name);
+ g_free (cursor_dir_name);
+
+ if (new_font_path != font_path)
+ g_free (new_font_path);
+
XFreeFontPath (font_path);
+done:
gnome_settings_profile_end (NULL);
-
- g_free (new_font_path);
- g_free (font_dir_name);
- g_free (dir_name);
}
gboolean
@@ -335,7 +391,7 @@ gsd_font_manager_start (GsdFontManager *manager,
client = gconf_client_get_default ();
load_xcursor_theme (client);
- load_cursor (client);
+ load_font_paths (client);
g_object_unref (client);
diff --git a/plugins/keybindings/gsd-keybindings-manager.c b/plugins/keybindings/gsd-keybindings-manager.c
index 509a721..9c75b3b 100644
--- a/plugins/keybindings/gsd-keybindings-manager.c
+++ b/plugins/keybindings/gsd-keybindings-manager.c
@@ -255,6 +255,7 @@ static void
binding_register_keys (GsdKeybindingsManager *manager)
{
GSList *li;
+ gboolean need_flush = FALSE;
gdk_error_trap_push ();
@@ -266,10 +267,11 @@ binding_register_keys (GsdKeybindingsManager *manager)
binding->previous_key.state != binding->key.state) {
/* Ungrab key if it changed and not clashing with previously set binding */
if (! key_already_used (manager, binding)) {
+ need_flush = TRUE;
if (binding->previous_key.keycode) {
- grab_key (&binding->previous_key, FALSE, manager->priv->screens);
+ grab_key_unsafe (&binding->previous_key, FALSE, manager->priv->screens);
}
- grab_key (&binding->key, TRUE, manager->priv->screens);
+ grab_key_unsafe (&binding->key, TRUE, manager->priv->screens);
binding->previous_key.keysym = binding->key.keysym;
binding->previous_key.state = binding->key.state;
@@ -278,8 +280,11 @@ binding_register_keys (GsdKeybindingsManager *manager)
g_warning ("Key binding (%s) is already in use", binding->binding_str);
}
}
- gdk_flush ();
- gdk_error_trap_pop ();
+
+ if (need_flush)
+ gdk_flush ();
+ if (gdk_error_trap_pop ())
+ g_warning ("Grab failed for some keys, another application may already have access the them.");
}
extern char **environ;
@@ -453,7 +458,7 @@ register_config_callback (GsdKeybindingsManager *manager,
const char *path,
GConfClientNotifyFunc func)
{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
}
@@ -472,6 +477,13 @@ gsd_keybindings_manager_start (GsdKeybindingsManager *manager,
g_debug ("Starting keybindings manager");
gnome_settings_profile_start (NULL);
+ client = gconf_client_get_default ();
+
+ manager->priv->notify = register_config_callback (manager,
+ client,
+ GCONF_BINDING_DIR,
+ (GConfClientNotifyFunc) bindings_callback);
+
dpy = gdk_display_get_default ();
screen_num = gdk_display_get_n_screens (dpy);
@@ -482,13 +494,6 @@ gsd_keybindings_manager_start (GsdKeybindingsManager *manager,
manager);
}
- client = gconf_client_get_default ();
-
- manager->priv->notify = register_config_callback (manager,
- client,
- GCONF_BINDING_DIR,
- (GConfClientNotifyFunc) bindings_callback);
-
list = gconf_client_all_dirs (client, GCONF_BINDING_DIR, NULL);
manager->priv->screens = get_screens_list ();
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index 2f08ec1..ae01b0b 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -59,16 +59,16 @@
#define GSD_KEYBOARD_KEY "/desktop/gnome/peripherals/keyboard"
-#define KEY_REPEAT "/desktop/gnome/peripherals/keyboard/repeat"
-#define KEY_CLICK "/desktop/gnome/peripherals/keyboard/click"
-#define KEY_RATE "/desktop/gnome/peripherals/keyboard/rate"
-#define KEY_DELAY "/desktop/gnome/peripherals/keyboard/delay"
-#define KEY_CLICK_VOLUME "/desktop/gnome/peripherals/keyboard/click_volume"
+#define KEY_REPEAT GSD_KEYBOARD_KEY "/repeat"
+#define KEY_CLICK GSD_KEYBOARD_KEY "/click"
+#define KEY_RATE GSD_KEYBOARD_KEY "/rate"
+#define KEY_DELAY GSD_KEYBOARD_KEY "/delay"
+#define KEY_CLICK_VOLUME GSD_KEYBOARD_KEY "/click_volume"
-#define KEY_BELL_VOLUME "/desktop/gnome/peripherals/keyboard/bell_volume"
-#define KEY_BELL_PITCH "/desktop/gnome/peripherals/keyboard/bell_pitch"
-#define KEY_BELL_DURATION "/desktop/gnome/peripherals/keyboard/bell_duration"
-#define KEY_BELL_MODE "/desktop/gnome/peripherals/keyboard/bell_mode"
+#define KEY_BELL_VOLUME GSD_KEYBOARD_KEY "/bell_volume"
+#define KEY_BELL_PITCH GSD_KEYBOARD_KEY "/bell_pitch"
+#define KEY_BELL_DURATION GSD_KEYBOARD_KEY "/bell_duration"
+#define KEY_BELL_MODE GSD_KEYBOARD_KEY "/bell_mode"
struct GsdKeyboardManagerPrivate
{
@@ -165,7 +165,6 @@ numlock_xkb_init (GsdKeyboardManager *manager)
gboolean have_xkb;
int opcode, error_base, major, minor;
- gdk_error_trap_push ();
have_xkb = XkbQueryExtension (dpy,
&opcode,
&manager->priv->xkb_event_base,
@@ -184,9 +183,6 @@ numlock_xkb_init (GsdKeyboardManager *manager)
g_warning ("XKB extension not available");
}
- XSync (dpy, FALSE);
- gdk_error_trap_pop ();
-
manager->priv->have_xkb = have_xkb;
}
@@ -374,19 +370,8 @@ apply_settings (GConfClient *client,
gdk_error_trap_pop ();
}
-static guint
-register_config_callback (GsdKeyboardManager *manager,
- GConfClient *client,
- const char *path,
- GConfClientNotifyFunc func)
-{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
- return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
-}
-
-gboolean
-gsd_keyboard_manager_start (GsdKeyboardManager *manager,
- GError **error)
+static gboolean
+start_keyboard_idle_cb (GsdKeyboardManager *manager)
{
GConfClient *client;
@@ -397,6 +382,8 @@ gsd_keyboard_manager_start (GsdKeyboardManager *manager,
manager->priv->have_xkb = 0;
client = gconf_client_get_default ();
+ gconf_client_add_dir (client, GSD_KEYBOARD_KEY, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
/* Essential - xkb initialization should happen before */
gsd_keyboard_xkb_set_post_activation_callback ((PostActivationCallback) gsd_load_modmap_files, NULL);
gsd_keyboard_xkb_init (client);
@@ -408,10 +395,9 @@ gsd_keyboard_manager_start (GsdKeyboardManager *manager,
/* apply current settings before we install the callback */
apply_settings (client, 0, NULL, manager);
- manager->priv->notify = register_config_callback (manager,
- client,
- GSD_KEYBOARD_KEY,
- (GConfClientNotifyFunc) apply_settings);
+ manager->priv->notify = gconf_client_notify_add (client, GSD_KEYBOARD_KEY,
+ (GConfClientNotifyFunc) apply_settings, manager,
+ NULL, NULL);
g_object_unref (client);
@@ -421,6 +407,19 @@ gsd_keyboard_manager_start (GsdKeyboardManager *manager,
gnome_settings_profile_end (NULL);
+ return FALSE;
+}
+
+gboolean
+gsd_keyboard_manager_start (GsdKeyboardManager *manager,
+ GError **error)
+{
+ gnome_settings_profile_start (NULL);
+
+ g_idle_add ((GSourceFunc) start_keyboard_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+
return TRUE;
}
diff --git a/plugins/keyboard/gsd-keyboard-xkb.c b/plugins/keyboard/gsd-keyboard-xkb.c
index 037f606..04608e2 100644
--- a/plugins/keyboard/gsd-keyboard-xkb.c
+++ b/plugins/keyboard/gsd-keyboard-xkb.c
@@ -37,6 +37,7 @@
#include "gsd-xmodmap.h"
#include "gsd-keyboard-xkb.h"
#include "delayed-dialog.h"
+#include "gnome-settings-profile.h"
static XklEngine *xkl_engine;
@@ -338,19 +339,22 @@ register_config_callback (GConfClient *client,
const char *path,
GConfClientNotifyFunc func)
{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
return gconf_client_notify_add (client, path, func, NULL, NULL, NULL);
}
void
gsd_keyboard_xkb_init (GConfClient *client)
{
+ gnome_settings_profile_start (NULL);
#ifdef GSDKX
xkl_set_debug_level (200);
logfile = fopen ("/tmp/gsdkx.log", "a");
xkl_set_log_appender (gsd_keyboard_log_appender);
#endif
+ gnome_settings_profile_start ("xkl_engine_get_instance");
xkl_engine = xkl_engine_get_instance (GDK_DISPLAY ());
+ gnome_settings_profile_end ("xkl_engine_get_instance");
if (xkl_engine) {
inited_ok = TRUE;
@@ -364,7 +368,9 @@ gsd_keyboard_xkb_init (GConfClient *client)
xkl_engine);
xkl_engine_backup_names_prop (xkl_engine);
gsd_keyboard_xkb_analyze_sysconfig ();
+ gnome_settings_profile_start ("gsd_keyboard_xkb_chk_lcl_xmm");
gsd_keyboard_xkb_chk_lcl_xmm ();
+ gnome_settings_profile_end ("gsd_keyboard_xkb_chk_lcl_xmm");
notify_desktop =
register_config_callback (client,
@@ -379,13 +385,21 @@ gsd_keyboard_xkb_init (GConfClient *client)
gdk_window_add_filter (NULL, (GdkFilterFunc)
gsd_keyboard_xkb_evt_filter,
NULL);
+
+ gnome_settings_profile_start ("xkl_engine_start_listen");
xkl_engine_start_listen (xkl_engine,
XKLL_MANAGE_LAYOUTS |
XKLL_MANAGE_WINDOW_STATES);
+ gnome_settings_profile_end ("xkl_engine_start_listen");
+ gnome_settings_profile_start ("apply_settings");
apply_settings ();
+ gnome_settings_profile_end ("apply_settings");
+ gnome_settings_profile_start ("apply_xkb_settings");
apply_xkb_settings ();
+ gnome_settings_profile_end ("apply_xkb_settings");
}
+ gnome_settings_profile_end (NULL);
}
void
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index a31cc61..964c95f 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -276,9 +276,12 @@ update_kbd_cb (GConfClient *client,
GsdMediaKeysManager *manager)
{
int i;
+ gboolean need_flush = TRUE;
g_return_if_fail (entry->key != NULL);
+ gdk_error_trap_push ();
+
/* Find the key that was modified */
for (i = 0; i < HANDLED_KEYS; i++) {
if (strcmp (entry->key, keys[i].gconf_key) == 0) {
@@ -286,7 +289,8 @@ update_kbd_cb (GConfClient *client,
Key *key;
if (keys[i].key != NULL) {
- grab_key (keys[i].key, FALSE, manager->priv->screens);
+ need_flush = TRUE;
+ grab_key_unsafe (keys[i].key, FALSE, manager->priv->screens);
}
g_free (keys[i].key);
@@ -308,7 +312,8 @@ update_kbd_cb (GConfClient *client,
break;
}
- grab_key (key, TRUE, manager->priv->screens);
+ need_flush = TRUE;
+ grab_key_unsafe (key, TRUE, manager->priv->screens);
keys[i].key = key;
g_free (tmp);
@@ -316,15 +321,23 @@ update_kbd_cb (GConfClient *client,
break;
}
}
+
+ if (need_flush)
+ gdk_flush ();
+ if (gdk_error_trap_pop ())
+ g_warning ("Grab failed for some keys, another application may already have access the them.");
}
static void
init_kbd (GsdMediaKeysManager *manager)
{
int i;
+ gboolean need_flush = FALSE;
gnome_settings_profile_start (NULL);
+ gdk_error_trap_push ();
+
for (i = 0; i < HANDLED_KEYS; i++) {
char *tmp;
Key *key;
@@ -340,6 +353,7 @@ init_kbd (GsdMediaKeysManager *manager)
tmp = gconf_client_get_string (manager->priv->conf_client,
keys[i].gconf_key,
NULL);
+
if (!is_valid_shortcut (tmp)) {
g_debug ("Not a valid shortcut: '%s'", tmp);
g_free (tmp);
@@ -367,9 +381,15 @@ init_kbd (GsdMediaKeysManager *manager)
keys[i].key = key;
- grab_key (key, TRUE, manager->priv->screens);
+ need_flush = TRUE;
+ grab_key_unsafe (key, TRUE, manager->priv->screens);
}
+ if (need_flush)
+ gdk_flush ();
+ if (gdk_error_trap_pop ())
+ g_warning ("Grab failed for some keys, another application may already have access the them.");
+
gnome_settings_profile_end (NULL);
}
@@ -894,9 +914,8 @@ acme_filter_events (GdkXEvent *xevent,
return GDK_FILTER_CONTINUE;
}
-gboolean
-gsd_media_keys_manager_start (GsdMediaKeysManager *manager,
- GError **error)
+static gboolean
+start_media_keys_idle_cb (GsdMediaKeysManager *manager)
{
GSList *l;
@@ -912,11 +931,6 @@ gsd_media_keys_manager_start (GsdMediaKeysManager *manager,
init_screens (manager);
init_kbd (manager);
- /* initialise Volume handler */
- gnome_settings_profile_start ("acme_volume_new");
- manager->priv->volume = acme_volume_new ();
- gnome_settings_profile_end ("acme_volume_new");
-
/* Start filtering the events */
for (l = manager->priv->screens; l != NULL; l = l->next) {
gnome_settings_profile_start ("gdk_window_add_filter");
@@ -932,6 +946,29 @@ gsd_media_keys_manager_start (GsdMediaKeysManager *manager,
gnome_settings_profile_end (NULL);
+ return FALSE;
+}
+
+gboolean
+gsd_media_keys_manager_start (GsdMediaKeysManager *manager,
+ GError **error)
+{
+ gnome_settings_profile_start (NULL);
+
+ /* initialise Volume handler
+ *
+ * We do this one here to force checking gstreamer cache, etc.
+ * The rest (grabbing and setting the keys) can happen in an
+ * idle.
+ */
+ gnome_settings_profile_start ("acme_volume_new");
+ manager->priv->volume = acme_volume_new ();
+ gnome_settings_profile_end ("acme_volume_new");
+
+ g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+
return TRUE;
}
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 8e930eb..3280cfe 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -55,17 +55,19 @@
#define GCONF_MOUSE_DIR "/desktop/gnome/peripherals/mouse"
#define GCONF_MOUSE_A11Y_DIR "/desktop/gnome/accessibility/mouse"
-#define KEY_LEFT_HANDED "/desktop/gnome/peripherals/mouse/left_handed"
-#define KEY_MOTION_ACCELERATION "/desktop/gnome/peripherals/mouse/motion_acceleration"
-#define KEY_MOTION_THRESHOLD "/desktop/gnome/peripherals/mouse/motion_threshold"
-#define KEY_LOCATE_POINTER "/desktop/gnome/peripherals/mouse/locate_pointer"
-#define KEY_DWELL_ENABLE "/desktop/gnome/accessibility/mouse/dwell_enable"
-#define KEY_DELAY_ENABLE "/desktop/gnome/accessibility/mouse/delay_enable"
+#define KEY_LEFT_HANDED GCONF_MOUSE_DIR "/left_handed"
+#define KEY_MOTION_ACCELERATION GCONF_MOUSE_DIR "/motion_acceleration"
+#define KEY_MOTION_THRESHOLD GCONF_MOUSE_DIR "/motion_threshold"
+#define KEY_LOCATE_POINTER GCONF_MOUSE_DIR "/locate_pointer"
+#define KEY_DWELL_ENABLE GCONF_MOUSE_A11Y_DIR "/dwell_enable"
+#define KEY_DELAY_ENABLE GCONF_MOUSE_A11Y_DIR "/delay_enable"
struct GsdMouseManagerPrivate
{
guint notify;
guint notify_a11y;
+
+ gboolean mousetweaks_daemon_running;
};
static void gsd_mouse_manager_class_init (GsdMouseManagerClass *klass);
@@ -583,9 +585,17 @@ set_mousetweaks_daemon (GsdMouseManager *manager,
{
GError *error = NULL;
gchar *comm;
+ gboolean run_daemon = dwell_enable || delay_enable;
+
+ if (run_daemon || manager->priv->mousetweaks_daemon_running)
+ comm = g_strdup_printf ("mousetweaks %s",
+ run_daemon ? "" : "-s");
+ else
+ return;
+
+ if (run_daemon)
+ manager->priv->mousetweaks_daemon_running = TRUE;
- comm = g_strdup_printf ("mousetweaks %s",
- (dwell_enable || delay_enable) ? "" : "-s");
if (! g_spawn_command_line_async (comm, &error)) {
if (error->code == G_SPAWN_ERROR_NOENT &&
@@ -678,7 +688,7 @@ register_config_callback (GsdMouseManager *manager,
const char *path,
GConfClientNotifyFunc func)
{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
}
@@ -688,13 +698,11 @@ gsd_mouse_manager_init (GsdMouseManager *manager)
manager->priv = GSD_MOUSE_MANAGER_GET_PRIVATE (manager);
}
-gboolean
-gsd_mouse_manager_start (GsdMouseManager *manager,
- GError **error)
+static gboolean
+gsd_mouse_manager_idle_cb (GsdMouseManager *manager)
{
GConfClient *client;
- g_debug ("Starting mouse manager");
gnome_settings_profile_start (NULL);
client = gconf_client_get_default ();
@@ -723,6 +731,19 @@ gsd_mouse_manager_start (GsdMouseManager *manager,
gnome_settings_profile_end (NULL);
+ return FALSE;
+}
+
+gboolean
+gsd_mouse_manager_start (GsdMouseManager *manager,
+ GError **error)
+{
+ gnome_settings_profile_start (NULL);
+
+ g_idle_add ((GSourceFunc) gsd_mouse_manager_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+
return TRUE;
}
diff --git a/plugins/typing-break/gsd-typing-break-manager.c b/plugins/typing-break/gsd-typing-break-manager.c
index d71d5c3..8d3a111 100644
--- a/plugins/typing-break/gsd-typing-break-manager.c
+++ b/plugins/typing-break/gsd-typing-break-manager.c
@@ -61,16 +61,6 @@ G_DEFINE_TYPE (GsdTypingBreakManager, gsd_typing_break_manager, G_TYPE_OBJECT)
static gpointer manager_object = NULL;
-static guint
-register_config_callback (GsdTypingBreakManager *manager,
- GConfClient *client,
- const char *path,
- GConfClientNotifyFunc func)
-{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
- return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
-}
-
static gboolean
typing_break_timeout (GsdTypingBreakManager *manager)
{
@@ -178,13 +168,14 @@ gsd_typing_break_manager_start (GsdTypingBreakManager *manager,
client = gconf_client_get_default ();
+ gconf_client_add_dir (client, GCONF_BREAK_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
manager->priv->notify =
- register_config_callback (manager,
- client,
- GCONF_BREAK_DIR,
- (GConfClientNotifyFunc) typing_break_callback);
+ gconf_client_notify_add (client,
+ GCONF_BREAK_DIR,
+ (GConfClientNotifyFunc) typing_break_callback, manager,
+ NULL, NULL);
- enabled = gconf_client_get_bool (client, "/desktop/gnome/typing_break/enabled", NULL);
+ enabled = gconf_client_get_bool (client, GCONF_BREAK_DIR "/enabled", NULL);
g_object_unref (client);
if (enabled) {
manager->priv->setup_id =
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index da7dbbe..1db5106 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -692,6 +692,7 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
GError **error)
{
g_debug ("Starting xrandr manager");
+ gnome_settings_profile_start (NULL);
manager->priv->rw_screen = gnome_rr_screen_new (
gdk_screen_get_default (), on_randr_event, manager);
@@ -707,7 +708,7 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
g_assert (manager->priv->notify_id == 0);
gconf_client_add_dir (manager->priv->client, CONF_DIR,
- GCONF_CLIENT_PRELOAD_NONE,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
manager->priv->notify_id =
@@ -745,6 +746,8 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
start_or_stop_icon (manager);
+ gnome_settings_profile_end (NULL);
+
return TRUE;
}
diff --git a/plugins/xsettings/fontconfig-monitor.c b/plugins/xsettings/fontconfig-monitor.c
index 7b6df2b..bfb15ed 100644
--- a/plugins/xsettings/fontconfig-monitor.c
+++ b/plugins/xsettings/fontconfig-monitor.c
@@ -33,6 +33,18 @@ stuff_changed (GFileMonitor *monitor,
GFileMonitorEvent event_type,
gpointer handle);
+void
+fontconfig_cache_init (void)
+{
+ FcInit ();
+}
+
+gboolean
+fontconfig_cache_update (void)
+{
+ return !FcConfigUptoDate (NULL) && FcInitReinitialize ();
+}
+
static void
monitor_files (GPtrArray *monitors,
FcStrList *list,
@@ -100,7 +112,7 @@ update (gpointer data)
handle->timeout = 0;
- if (!FcConfigUptoDate (NULL) && FcInitReinitialize ()) {
+ if (fontconfig_cache_update ()) {
notify = TRUE;
monitors_free (handle->monitors);
handle->monitors = monitors_create (data);
diff --git a/plugins/xsettings/fontconfig-monitor.h b/plugins/xsettings/fontconfig-monitor.h
index b3df8cd..eeeef7c 100644
--- a/plugins/xsettings/fontconfig-monitor.h
+++ b/plugins/xsettings/fontconfig-monitor.h
@@ -25,6 +25,9 @@
G_BEGIN_DECLS
+void fontconfig_cache_init (void);
+gboolean fontconfig_cache_update (void);
+
typedef struct _fontconfig_monitor_handle fontconfig_monitor_handle_t;
fontconfig_monitor_handle_t *
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index e847e74..56e3a0d 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -424,6 +424,7 @@ child_watch_cb (GPid pid,
{
char *command = user_data;
+ gnome_settings_profile_end ("%s", command);
if (!WIFEXITED (status) || WEXITSTATUS (status)) {
g_warning ("Command %s failed", command);
}
@@ -446,6 +447,7 @@ spawn_with_input (const char *command,
return;
}
+ gnome_settings_profile_start ("%s", command);
error = NULL;
res = g_spawn_async_with_pipes (NULL,
argv,
@@ -563,6 +565,38 @@ fontconfig_callback (fontconfig_monitor_handle_t *handle,
gnome_settings_profile_end (NULL);
}
+static gboolean
+start_fontconfig_monitor_idle_cb (GnomeXSettingsManager *manager)
+{
+ gnome_settings_profile_start (NULL);
+
+ manager->priv->fontconfig_handle = fontconfig_monitor_start ((GFunc) fontconfig_callback, manager);
+
+ gnome_settings_profile_end (NULL);
+
+ return FALSE;
+}
+
+static void
+start_fontconfig_monitor (GnomeXSettingsManager *manager)
+{
+ gnome_settings_profile_start (NULL);
+
+ fontconfig_cache_init ();
+
+ g_idle_add ((GSourceFunc) start_fontconfig_monitor_idle_cb, manager);
+
+ gnome_settings_profile_end (NULL);
+}
+
+static void
+stop_fontconfig_monitor (GnomeXSettingsManager *manager)
+{
+ if (manager->priv->fontconfig_handle) {
+ fontconfig_monitor_stop (manager->priv->fontconfig_handle);
+ manager->priv->fontconfig_handle = NULL;
+ }
+}
#endif /* HAVE_FONTCONFIG */
static const char *
@@ -747,7 +781,6 @@ register_config_callback (GnomeXSettingsManager *manager,
const char *path,
GConfClientNotifyFunc func)
{
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
}
@@ -824,6 +857,13 @@ gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
client = gconf_client_get_default ();
+ gconf_client_add_dir (client, MOUSE_SETTINGS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (client, GTK_SETTINGS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (client, INTERFACE_SETTINGS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (client, SOUND_SETTINGS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (client, GTK_MODULES_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ gconf_client_add_dir (client, FONT_RENDER_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
for (i = 0; i < G_N_ELEMENTS (translations); i++) {
GConfValue *val;
GError *err;
@@ -876,7 +916,7 @@ gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
(GConfClientNotifyFunc) xft_callback);
update_xft_settings (manager, client);
- manager->priv->fontconfig_handle = fontconfig_monitor_start ((GFunc) fontconfig_callback, manager);
+ start_fontconfig_monitor (manager);
#endif /* HAVE_FONTCONFIG */
g_object_unref (client);
@@ -923,8 +963,7 @@ gnome_xsettings_manager_stop (GnomeXSettingsManager *manager)
#ifdef HAVE_FONTCONFIG
gconf_client_remove_dir (client, FONT_RENDER_DIR, NULL);
- fontconfig_monitor_stop (manager->priv->fontconfig_handle);
- manager->priv->fontconfig_handle = NULL;
+ stop_fontconfig_monitor (manager);
#endif /* HAVE_FONTCONFIG */
for (i = 0; i < G_N_ELEMENTS (p->notify); ++i) {