From 44bdb6aa636106bc01a03b797ea3e0e2497556d1 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 30 Mar 2011 18:00:35 +0100 Subject: keyboard: Clarify actual units used for repeat rate We designed for the repeat rate being a delay between repeated keys, in milliseconds, so we could have 0.5 characters per second (a character every 2 seconds) for a11y purposes. Except that: * the schema kind of mentioned it, but it wasn't clear * XF86Misc doesn't support less than one character per second * Parts of the API seemed to expect the rate being in number of chars per second. https://bugzilla.gnome.org/show_bug.cgi?id=646241 --- ...e.settings-daemon.peripherals.gschema.xml.in.in | 12 ++--- plugins/keyboard/gsd-keyboard-manager.c | 60 ++++++---------------- 2 files changed, 23 insertions(+), 49 deletions(-) diff --git a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in index 7c9fbff1..1ea534fb 100644 --- a/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in +++ b/data/org.gnome.settings-daemon.peripherals.gschema.xml.in.in @@ -62,15 +62,15 @@ true - + 30 - Repeat Rate - Key repeat rate in milliseconds. + Key Repeat Interval + Delay between repeats in milliseconds. - + 500 - Repeat Delay - Key repeat delay in milliseconds. + Initial Key Repeat Delay + Initial key repeat delay in milliseconds. 0 diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c index 9e995a82..f842f751 100644 --- a/plugins/keyboard/gsd-keyboard-manager.c +++ b/plugins/keyboard/gsd-keyboard-manager.c @@ -37,9 +37,6 @@ #include #include -#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H -# include -#endif #ifdef HAVE_X11_EXTENSIONS_XKB_H #include #include @@ -61,7 +58,7 @@ #define KEY_REPEAT "repeat" #define KEY_CLICK "click" -#define KEY_RATE "rate" +#define KEY_INTERVAL "repeat-interval" #define KEY_DELAY "delay" #define KEY_CLICK_VOLUME "click-volume" @@ -86,39 +83,10 @@ G_DEFINE_TYPE (GsdKeyboardManager, gsd_keyboard_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; -#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H -static gboolean -xfree86_set_keyboard_autorepeat_rate (int delay, int rate) -{ - gboolean res = FALSE; - int event_base_return; - int error_base_return; - - if (XF86MiscQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - &event_base_return, - &error_base_return) == True) { - /* load the current settings */ - XF86MiscKbdSettings kbdsettings; - XF86MiscGetKbdSettings (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &kbdsettings); - - /* assign the new values */ - kbdsettings.delay = delay; - kbdsettings.rate = rate; - XF86MiscSetKbdSettings (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &kbdsettings); - res = TRUE; - } - - 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) +xkb_set_keyboard_autorepeat_rate (guint delay, guint interval) { - int interval = (rate <= 0) ? 1000000 : 1000/rate; - if (delay <= 0) - delay = 1; return XkbSetAutoRepeatRate (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XkbUseCoreKbd, delay, @@ -276,6 +244,16 @@ numlock_install_xkb_callback (GsdKeyboardManager *manager) #endif /* HAVE_X11_EXTENSIONS_XKB_H */ +static guint +_gsd_settings_get_uint (GSettings *settings, + const char *key) +{ + guint value; + + g_settings_get (settings, key, "u", &value); + return value; +} + static void apply_settings (GSettings *settings, const char *key, @@ -284,8 +262,8 @@ apply_settings (GSettings *settings, XKeyboardControl kbdcontrol; gboolean repeat; gboolean click; - int rate; - int delay; + guint interval; + guint delay; int click_volume; int bell_volume; int bell_pitch; @@ -297,8 +275,8 @@ apply_settings (GSettings *settings, repeat = g_settings_get_boolean (settings, KEY_REPEAT); click = g_settings_get_boolean (settings, KEY_CLICK); - rate = g_settings_get_int (settings, KEY_RATE); - delay = g_settings_get_int (settings, KEY_DELAY); + interval = _gsd_settings_get_uint (settings, KEY_INTERVAL); + delay = _gsd_settings_get_uint (settings, KEY_DELAY); click_volume = g_settings_get_int (settings, KEY_CLICK_VOLUME); bell_pitch = g_settings_get_int (settings, KEY_BELL_PITCH); bell_duration = g_settings_get_int (settings, KEY_BELL_DURATION); @@ -317,11 +295,7 @@ apply_settings (GSettings *settings, XAutoRepeatOn (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); /* Use XKB in preference */ #ifdef HAVE_X11_EXTENSIONS_XKB_H - rate_set = xkb_set_keyboard_autorepeat_rate (delay, rate); -#endif -#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H - if (!rate_set) - rate_set = xfree86_set_keyboard_autorepeat_rate (delay, rate); + rate_set = xkb_set_keyboard_autorepeat_rate (delay, interval); #endif if (!rate_set) g_warning ("Neither XKeyboard not Xfree86's keyboard extensions are available,\n" -- cgit v1.2.1