2001-12-20 14:11:59 +00:00
|
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
|
|
/* gnome-settings-keyboard.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright <EFBFBD> 2001 Ximian, Inc.
|
|
|
|
|
*
|
|
|
|
|
* Written by Bradford Hovinen <hovinen@ximian.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
* 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
|
|
|
|
|
|
#include "gnome-settings-keyboard.h"
|
|
|
|
|
#include "gnome-settings-daemon.h"
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
|
|
|
|
# include <X11/extensions/xf86misc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
apply_settings (void)
|
|
|
|
|
{
|
|
|
|
|
GConfClient *client;
|
|
|
|
|
|
|
|
|
|
gboolean repeat, click;
|
2002-03-12 01:35:40 +00:00
|
|
|
|
int rate, delay;
|
2002-03-29 17:21:23 +00:00
|
|
|
|
int click_volume, bell_volume, bell_pitch, bell_duration;
|
2001-12-20 14:11:59 +00:00
|
|
|
|
|
|
|
|
|
XKeyboardControl kbdcontrol;
|
|
|
|
|
int event_base_return, error_base_return;
|
|
|
|
|
|
|
|
|
|
client = gconf_client_get_default ();
|
|
|
|
|
|
2002-03-12 01:35:40 +00:00
|
|
|
|
repeat = gconf_client_get_bool (client, "/desktop/gnome/peripherals/keyboard/repeat", NULL);
|
|
|
|
|
click = gconf_client_get_bool (client, "/desktop/gnome/peripherals/keyboard/click", NULL);
|
|
|
|
|
rate = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/rate", NULL);
|
|
|
|
|
delay = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/delay", NULL);
|
2002-03-29 17:21:23 +00:00
|
|
|
|
click_volume = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/click_volume", NULL);
|
2002-03-12 01:35:40 +00:00
|
|
|
|
bell_volume = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_volume", NULL);
|
|
|
|
|
bell_pitch = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_pitch", NULL);
|
|
|
|
|
bell_duration = gconf_client_get_int (client, "/desktop/gnome/peripherals/keyboard/bell_duration", NULL);
|
2001-12-20 14:11:59 +00:00
|
|
|
|
|
2002-03-30 03:25:26 +00:00
|
|
|
|
gdk_error_trap_push ();
|
2001-12-20 14:11:59 +00:00
|
|
|
|
if (repeat) {
|
|
|
|
|
XAutoRepeatOn (GDK_DISPLAY ());
|
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
|
|
|
|
if (XF86MiscQueryExtension (GDK_DISPLAY (),
|
|
|
|
|
&event_base_return,
|
|
|
|
|
&error_base_return) == True)
|
|
|
|
|
{
|
2002-03-30 03:25:26 +00:00
|
|
|
|
/* load the current settings */
|
|
|
|
|
XF86MiscKbdSettings kbdsettings;
|
|
|
|
|
XF86MiscGetKbdSettings (GDK_DISPLAY (), &kbdsettings);
|
|
|
|
|
|
|
|
|
|
/* assign the new values */
|
2001-12-20 14:11:59 +00:00
|
|
|
|
kbdsettings.rate = rate;
|
|
|
|
|
kbdsettings.delay = delay;
|
|
|
|
|
XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings);
|
|
|
|
|
} else {
|
|
|
|
|
XAutoRepeatOff (GDK_DISPLAY ());
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
XAutoRepeatOff (GDK_DISPLAY ());
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-29 17:21:23 +00:00
|
|
|
|
/* as percentage from 0..100 inclusive */
|
|
|
|
|
if (click_volume < 0)
|
|
|
|
|
click_volume = 0;
|
|
|
|
|
else if (click_volume > 100)
|
|
|
|
|
click_volume = 100;
|
|
|
|
|
kbdcontrol.key_click_percent = click ? click_volume : 0;
|
2001-12-20 14:11:59 +00:00
|
|
|
|
kbdcontrol.bell_percent = bell_volume;
|
|
|
|
|
kbdcontrol.bell_pitch = bell_pitch;
|
|
|
|
|
kbdcontrol.bell_duration = bell_duration;
|
|
|
|
|
XChangeKeyboardControl (GDK_DISPLAY (), KBKeyClickPercent,
|
|
|
|
|
&kbdcontrol);
|
2002-03-30 03:25:26 +00:00
|
|
|
|
|
2002-04-10 23:30:45 +00:00
|
|
|
|
XSync (GDK_DISPLAY (), FALSE);
|
2002-03-30 03:25:26 +00:00
|
|
|
|
gdk_error_trap_pop ();
|
2001-12-20 14:11:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-10 02:26:59 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gnome_settings_keyboard_init (GConfClient *client)
|
|
|
|
|
{
|
|
|
|
|
gnome_settings_daemon_register_callback ("/desktop/gnome/peripherals/keyboard", (KeyCallbackFunc) apply_settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gnome_settings_keyboard_load (GConfClient *client)
|
|
|
|
|
{
|
|
|
|
|
apply_settings ();
|
|
|
|
|
}
|
|
|
|
|
|