summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2011-03-30 18:00:35 +0100
committerBastien Nocera <hadess@hadess.net>2011-03-31 12:16:46 +0100
commit44bdb6aa636106bc01a03b797ea3e0e2497556d1 (patch)
treef1fa1e29cfe38ff45a99026cbbc881a52de01a4f /plugins
parentbf9a8264337dddcd0db76470887fdaca35eda7b6 (diff)
downloadgnome-settings-daemon-44bdb6aa636106bc01a03b797ea3e0e2497556d1.tar.gz
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/keyboard/gsd-keyboard-manager.c60
1 files changed, 17 insertions, 43 deletions
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 <gdk/gdkx.h>
#include <gtk/gtk.h>
-#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
-# include <X11/extensions/xf86misc.h>
-#endif
#ifdef HAVE_X11_EXTENSIONS_XKB_H
#include <X11/XKBlib.h>
#include <X11/keysym.h>
@@ -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"