a bit of optimization - no more redundant xkb reconfigurations

This commit is contained in:
Sergey V. Udaltsov 2005-01-07 03:48:15 +00:00
parent 2c817e4d7a
commit 9b8a663c05
2 changed files with 33 additions and 13 deletions

View file

@ -1,3 +1,8 @@
2005-01-07 Sergey V. Udaltsov <svu@gnome.org>
* gnome-settings-keyboard-xkb.c: optimization - only update the
configuration when necessary
2005-01-04 Dennis Cranston <dennis_cranston@yahoo.com>
* gnome-settings-multimedia-keys.c: (execute): use g_spawn_sync()

View file

@ -59,7 +59,7 @@ typedef enum {
RESPONSE_USE_GNOME
} SysConfigChangedMsgResponse;
#define noGSDKX
#define GSDKX
#ifdef GSDKX
static FILE *logfile;
@ -114,13 +114,16 @@ activation_error (void)
}
static void
apply_settings (void)
apply_settings (GConfEntry *entry)
{
GConfClient *confClient;
if (!initedOk)
return;
if (entry != NULL)
XklDebug (150, "Modified configuration in gconf: [%s]\n",
gconf_entry_get_key (entry));
confClient = gconf_client_get_default ();
GSwitchItConfigInit (&gswic, confClient);
g_object_unref (confClient);
@ -132,15 +135,20 @@ apply_settings (void)
}
static void
apply_xkb_settings (void)
apply_xkb_settings (GConfEntry *entry)
{
GConfClient *confClient;
GSwitchItKbdConfig gswikcs;
if (!initedOk)
return;
if (entry != NULL)
XklDebug (150, "Modified KBD configuration in gconf: [%s]\n",
gconf_entry_get_key (entry));
confClient = gconf_client_get_default ();
GSwitchItKbdConfigInit (&gswikc, confClient);
GSwitchItKbdConfigInit (&gswikcs, confClient);
g_object_unref (confClient);
GSwitchItKbdConfigLoad (&gswikc);
@ -151,6 +159,10 @@ apply_xkb_settings (void)
gswikc.overrideSettings = FALSE;
GSwitchItKbdConfigSave (&gswikc);
} else {
GSwitchItKbdConfigLoadCurrent (&gswikcs);
/* Activate - only if different! */
if (!GSwitchItKbdConfigEquals (&gswikc, &gswikcs))
{
if (GSwitchItKbdConfigActivate (&gswikc)) {
if (paCallback != NULL) {
(*paCallback) (paCallbackUserData);
@ -160,8 +172,11 @@ apply_xkb_settings (void)
("Could not activate the XKB configuration");
activation_error ();
}
} else
XklDebug (100, "Actual KBD configuration was not changed: redundant notification\n");
}
GSwitchItKbdConfigTerm (&gswikcs);
GSwitchItKbdConfigTerm (&gswikc);
}
@ -328,6 +343,6 @@ gnome_settings_keyboard_xkb_init (GConfClient * client)
void
gnome_settings_keyboard_xkb_load (GConfClient * client)
{
apply_settings ();
apply_xkb_settings ();
apply_settings (NULL);
apply_xkb_settings (NULL);
}