gnome-settings-daemon r267 - in trunk: . plugins/keyboard
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r267 - in trunk: . plugins/keyboard
- Date: Sun, 6 Apr 2008 18:29:08 +0100 (BST)
Author: jensg
Date: Sun Apr 6 18:29:08 2008
New Revision: 267
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=267&view=rev
Log:
2008-04-06 Jens Granseuer <jensgr gmx net>
* plugins/keyboard/gsd-keyboard-manager.c:
(gsd_keyboard_get_hostname_key), (numlock_set_xkb_state),
(numlock_gconf_state_key), (numlock_get_gconf_state),
(numlock_set_gconf_state), (numlock_xkb_callback),
(numlock_install_xkb_callback), (apply_settings),
(gsd_keyboard_manager_start), (gsd_keyboard_manager_init):
* plugins/keyboard/gsd-keyboard-xkb.c: (gsd_keyboard_xkb_init):
* plugins/keyboard/gsd-keyboard-xkb.h: continued attempt at making XKB
setup and error handling a bit less arcane and crufty
Modified:
trunk/ChangeLog
trunk/plugins/keyboard/gsd-keyboard-manager.c
trunk/plugins/keyboard/gsd-keyboard-xkb.c
trunk/plugins/keyboard/gsd-keyboard-xkb.h
Modified: trunk/plugins/keyboard/gsd-keyboard-manager.c
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-manager.c (original)
+++ trunk/plugins/keyboard/gsd-keyboard-manager.c Sun Apr 6 18:29:08 2008
@@ -53,6 +53,10 @@
#define GSD_KEYBOARD_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBOARD_MANAGER, GsdKeyboardManagerPrivate))
+#ifndef HOST_NAME_MAX
+# define HOST_NAME_MAX 255
+#endif
+
#define GSD_KEYBOARD_KEY "/desktop/gnome/peripherals/keyboard"
#define KEY_REPEAT "/desktop/gnome/peripherals/keyboard/repeat"
@@ -68,11 +72,7 @@
struct GsdKeyboardManagerPrivate
{
- gboolean dummy;
-};
-
-enum {
- PROP_0,
+ gboolean have_xkb;
};
static void gsd_keyboard_manager_class_init (GsdKeyboardManagerClass *klass);
@@ -109,6 +109,7 @@
return res;
}
#endif /* HAVE_X11_EXTENSIONS_XF86MISC_H */
+
#ifdef HAVE_X11_EXTENSIONS_XKB_H
static gboolean
xkb_set_keyboard_autorepeat_rate (int delay, int rate)
@@ -126,11 +127,7 @@
static char *
gsd_keyboard_get_hostname_key (const char *subkey)
{
-#ifdef HOST_NAME_MAX
char hostname[HOST_NAME_MAX + 1];
-#else
- char hostname[256];
-#endif
if (gethostname (hostname, sizeof (hostname)) == 0 &&
strcmp (hostname, "localhost") != 0 &&
@@ -144,7 +141,7 @@
escaped,
"/0/",
subkey,
- (char *)NULL);
+ NULL);
g_free (escaped);
return key;
} else
@@ -153,18 +150,11 @@
#ifdef HAVE_X11_EXTENSIONS_XKB_H
-enum {
+typedef enum {
NUMLOCK_STATE_OFF = 0,
NUMLOCK_STATE_ON = 1,
NUMLOCK_STATE_UNKNOWN = 2
-};
-
-/* something fatal has happened so that it makes no
- * sense to try to remember anything.
- * that means: no calls to the set_state functions!
- */
-static gboolean
-numlock_setup_error = FALSE;
+} NumLockState;
/* we didn't apply GConf settings yet
* don't overwrite them with the initial state from
@@ -182,7 +172,7 @@
}
static void
-numlock_set_xkb_state (gboolean new_state)
+numlock_set_xkb_state (int new_state)
{
unsigned int num_mask;
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
@@ -197,13 +187,12 @@
{
char *key = gsd_keyboard_get_hostname_key ("numlock_on");
if (!key) {
- numlock_setup_error = TRUE;
g_warning ("numlock: Numlock remembering disabled because your hostname is set to \"localhost\".");
}
return key;
}
-static int
+static NumLockState
numlock_get_gconf_state (GConfClient *client)
{
int curr_state;
@@ -217,29 +206,28 @@
curr_state = gconf_client_get_bool (client, key, &err);
if (err) {
curr_state = NUMLOCK_STATE_UNKNOWN;
+ g_error_free (err);
}
- g_clear_error (&err);
g_free (key);
return curr_state;
}
static void
numlock_set_gconf_state (GConfClient *client,
- gboolean new_state)
+ NumLockState new_state)
{
char *key;
if (new_state != NUMLOCK_STATE_ON && new_state != NUMLOCK_STATE_OFF) {
return;
}
+
key = numlock_gconf_state_key ();
- if (!key) {
- return;
+ if (key) {
+ gconf_client_set_bool (client, key, new_state, NULL);
+ g_free (key);
}
-
- gconf_client_set_bool (client, key, new_state, NULL);
- g_free (key);
}
static GdkFilterReturn
@@ -247,7 +235,7 @@
GdkEvent *gdkev_,
gpointer xkb_event_code)
{
- XEvent *xev = (XEvent *)xev_;
+ XEvent *xev = (XEvent *) xev_;
if (xev->type == GPOINTER_TO_INT (xkb_event_code)) {
XkbEvent *xkbev = (XkbEvent *)xev;
@@ -257,7 +245,7 @@
unsigned locked_mods = xkbev->state.locked_mods;
int numlock_state = !! (num_mask & locked_mods);
- if (!numlock_starting_up && !numlock_setup_error) {
+ if (!numlock_starting_up) {
GConfClient *client;
client = gconf_client_get_default ();
numlock_set_gconf_state (client, numlock_state);
@@ -268,7 +256,7 @@
return GDK_FILTER_CONTINUE;
}
-static void
+static gboolean
numlock_install_xkb_callback (void)
{
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
@@ -284,9 +272,8 @@
&major,
&minor);
if (have_xkb != True) {
- numlock_setup_error = TRUE;
g_warning ("numlock: XkbQueryExtension returned an error");
- return;
+ return FALSE;
}
XkbSelectEventDetails (dpy,
@@ -298,6 +285,8 @@
gdk_window_add_filter (NULL,
numlock_xkb_callback,
GINT_TO_POINTER (xkb_event_code));
+
+ return TRUE;
}
#endif /* HAVE_X11_EXTENSIONS_XKB_H */
@@ -347,7 +336,7 @@
XAutoRepeatOn (GDK_DISPLAY ());
/* Use XKB in preference */
-#if defined (HAVE_X11_EXTENSIONS_XKB_H)
+#ifdef HAVE_X11_EXTENSIONS_XKB_H
rate_set = xkb_set_keyboard_autorepeat_rate (delay, rate);
#endif
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
@@ -375,13 +364,9 @@
KBKeyClickPercent | KBBellPercent | KBBellPitch | KBBellDuration,
&kbdcontrol);
-
#ifdef HAVE_X11_EXTENSIONS_XKB_H
- if (!numlock_setup_error && rnumlock) {
- GConfClient *client;
- client = gconf_client_get_default ();
+ if (manager->priv->have_xkb && rnumlock) {
numlock_set_xkb_state (numlock_get_gconf_state (client));
- g_object_unref (client);
}
numlock_starting_up = FALSE;
#endif /* HAVE_X11_EXTENSIONS_XKB_H */
@@ -418,13 +403,12 @@
/* Essential - xkb initialization should happen before */
gsd_keyboard_xkb_set_post_activation_callback ((PostActivationCallback) gsd_load_modmap_files, NULL);
gsd_keyboard_xkb_init (client);
- gsd_keyboard_xkb_load (client);
register_config_callback (manager,
GSD_KEYBOARD_KEY,
(GConfClientNotifyFunc) apply_settings);
#ifdef HAVE_X11_EXTENSIONS_XKB_H
- numlock_install_xkb_callback ();
+ manager->priv->have_xkb = numlock_install_xkb_callback ();
#endif /* HAVE_X11_EXTENSIONS_XKB_H */
apply_settings (client, 0, NULL, manager);
@@ -520,7 +504,6 @@
gsd_keyboard_manager_init (GsdKeyboardManager *manager)
{
manager->priv = GSD_KEYBOARD_MANAGER_GET_PRIVATE (manager);
-
}
static void
Modified: trunk/plugins/keyboard/gsd-keyboard-xkb.c
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-xkb.c (original)
+++ trunk/plugins/keyboard/gsd-keyboard-xkb.c Sun Apr 6 18:29:08 2008
@@ -331,12 +331,8 @@
xkl_engine_start_listen (xkl_engine,
XKLL_MANAGE_LAYOUTS |
XKLL_MANAGE_WINDOW_STATES);
- }
-}
-void
-gsd_keyboard_xkb_load (GConfClient * client)
-{
- apply_settings ();
- apply_xkb_settings ();
+ apply_settings ();
+ apply_xkb_settings ();
+ }
}
Modified: trunk/plugins/keyboard/gsd-keyboard-xkb.h
==============================================================================
--- trunk/plugins/keyboard/gsd-keyboard-xkb.h (original)
+++ trunk/plugins/keyboard/gsd-keyboard-xkb.h Sun Apr 6 18:29:08 2008
@@ -30,7 +30,6 @@
#include <libxklavier/xklavier.h>
void gsd_keyboard_xkb_init (GConfClient * client);
-void gsd_keyboard_xkb_load (GConfClient * client);
typedef void (*PostActivationCallback) (void *userData);
@@ -38,6 +37,4 @@
gsd_keyboard_xkb_set_post_activation_callback (PostActivationCallback fun,
void *userData);
-GType keyboard_config_registry_get_type (void);
-
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]