diff options
author | Jody Goldberg <jody@src.gnome.org> | 2002-04-25 04:59:10 +0000 |
---|---|---|
committer | Jody Goldberg <jody@src.gnome.org> | 2002-04-25 04:59:10 +0000 |
commit | 65d7e935356b8b5e262216ba47973bf84ed3341b (patch) | |
tree | 4b968275dd25f009066495f4965fa73223259b68 /gnome-settings-daemon | |
parent | 68884480e6ece920b4055d4e3320172ae1db1959 (diff) | |
download | gnome-control-center-65d7e935356b8b5e262216ba47973bf84ed3341b.tar.gz |
*** empty log message ***
Diffstat (limited to 'gnome-settings-daemon')
-rw-r--r-- | gnome-settings-daemon/gnome-settings-keyboard.c | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/gnome-settings-daemon/gnome-settings-keyboard.c b/gnome-settings-daemon/gnome-settings-keyboard.c index 7abd16a86..eda7fd675 100644 --- a/gnome-settings-daemon/gnome-settings-keyboard.c +++ b/gnome-settings-daemon/gnome-settings-keyboard.c @@ -36,6 +36,43 @@ #ifdef HAVE_X11_EXTENSIONS_XF86MISC_H # include <X11/extensions/xf86misc.h> #endif +#ifdef HAVE_X11_EXTENSIONS_XKB_H +#include <X11/XKBlib.h> +#endif + +#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H +static gboolean +xfree86_set_keyboard_autorepeat_rate (int delay, int rate) +{ + gboolean res = FALSE; + int event_base_return, error_base_return; + + if (XF86MiscQueryExtension (GDK_DISPLAY (), + &event_base_return, + &error_base_return) == True) + { + /* load the current settings */ + XF86MiscKbdSettings kbdsettings; + XF86MiscGetKbdSettings (GDK_DISPLAY (), &kbdsettings); + + /* assign the new values */ + kbdsettings.delay = delay; + kbdsettings.rate = rate; + XF86MiscSetKbdSettings (GDK_DISPLAY (), &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) +{ + return XkbSetAutoRepeatRate (GDK_DISPLAY (), XkbUseCoreKbd, + delay, 1000/rate); +} +#endif static void apply_settings (void) @@ -47,7 +84,6 @@ apply_settings (void) int click_volume, bell_volume, bell_pitch, bell_duration; XKeyboardControl kbdcontrol; - int event_base_return, error_base_return; client = gconf_client_get_default (); @@ -62,27 +98,24 @@ apply_settings (void) gdk_error_trap_push (); if (repeat) { + gboolean rate_set = FALSE; + XAutoRepeatOn (GDK_DISPLAY ()); + /* Use XKB in preference */ +#if defined (HAVE_X11_EXTENSIONS_XKB_H) + rate_set = xkb_set_keyboard_autorepeat_rate (delay, rate); +#endif #ifdef HAVE_X11_EXTENSIONS_XF86MISC_H - if (XF86MiscQueryExtension (GDK_DISPLAY (), - &event_base_return, - &error_base_return) == True) - { - /* load the current settings */ - XF86MiscKbdSettings kbdsettings; - XF86MiscGetKbdSettings (GDK_DISPLAY (), &kbdsettings); - - /* assign the new values */ - kbdsettings.rate = rate; - kbdsettings.delay = delay; - XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings); - } else { - XAutoRepeatOff (GDK_DISPLAY ()); - } + if (!rate_set) + rate_set = xfree86_set_keyboard_autorepeat_rate (delay, rate); #endif - } else { + if (!rate_set) { + g_warning ("Neither XKeyboard not Xfree86's keyboard extensions are available,\n" + "no way to support keyboard autorepeat settings"); + XAutoRepeatOff (GDK_DISPLAY ()); + } + } else XAutoRepeatOff (GDK_DISPLAY ()); - } /* as percentage from 0..100 inclusive */ if (click_volume < 0) |