Move locate_pointer out.
Mon Jan 21 01:29:57 2002 Jonathan Blandford <jrb@redhat.com> * gnome-settings-keyboard.c: Move locate_pointer out. * gnome-settings-mouse.c: Move locate_pointer in. Clean up code. Remove print statements.
This commit is contained in:
parent
5a8613bc68
commit
d56503be2a
6 changed files with 123 additions and 156 deletions
|
@ -679,7 +679,8 @@ peditor_select_radio_value_changed (GConfClient *client,
|
|||
value_wid = peditor->p->conv_to_widget_cb (value);
|
||||
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (peditor->p->ui_control));
|
||||
group = g_slist_nth (group, gconf_value_get_int (value_wid));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE);
|
||||
if (group && group->data)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (group->data), TRUE);
|
||||
gconf_value_free (value_wid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ bell_guard (GtkWidget *toggle,
|
|||
gtk_widget_set_sensitive (WID ("bell_custom_fileentry"), GTK_TOGGLE_BUTTON (toggle)->active);
|
||||
}
|
||||
|
||||
gboolean
|
||||
static gboolean
|
||||
mnemonic_activate (GtkWidget *toggle,
|
||||
gboolean group_cycling,
|
||||
GtkWidget *entry)
|
||||
|
@ -191,37 +191,37 @@ setup_dialog (GladeXML *dialog,
|
|||
g_free (filename);
|
||||
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(NULL, "/desktop/gnome/peripherals/keyboard/repeat", WID ("repeat_toggle"), NULL);
|
||||
(changeset, "/desktop/gnome/peripherals/keyboard/repeat", WID ("repeat_toggle"), NULL);
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("repeat_table"));
|
||||
|
||||
gconf_peditor_new_select_menu
|
||||
(NULL, "/gnome/desktop/peripherals/keyboard/delay", WID ("repeat_delay_omenu"),
|
||||
(changeset, "/gnome/desktop/peripherals/keyboard/delay", WID ("repeat_delay_omenu"),
|
||||
"conv-to-widget-cb", delay_to_widget,
|
||||
"conv-from-widget-cb", delay_from_widget,
|
||||
NULL);
|
||||
|
||||
gconf_peditor_new_select_menu
|
||||
(NULL, "/gnome/desktop/peripherals/keyboard/rate", WID ("repeat_speed_omenu"),
|
||||
(changeset, "/gnome/desktop/peripherals/keyboard/rate", WID ("repeat_speed_omenu"),
|
||||
"conv-to-widget-cb", rate_to_widget,
|
||||
"conv-from-widget-cb", rate_from_widget,
|
||||
NULL);
|
||||
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(NULL, "/desktop/gnome/interface/cursor_blink", WID ("cursor_toggle"), NULL);
|
||||
(changeset, "/desktop/gnome/interface/cursor_blink", WID ("cursor_toggle"), NULL);
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("cursor_hbox"));
|
||||
gconf_peditor_new_numeric_range
|
||||
(NULL, "/desktop/gnome/interface/cursor_blink_time", WID ("cursor_blink_time_scale"), NULL);
|
||||
(changeset, "/desktop/gnome/interface/cursor_blink_time", WID ("cursor_blink_time_scale"), NULL);
|
||||
|
||||
|
||||
peditor = gconf_peditor_new_boolean
|
||||
(NULL, "/desktop/gnome/peripherals/keyboard/click", WID ("volume_toggle"), NULL);
|
||||
(changeset, "/desktop/gnome/peripherals/keyboard/click", WID ("volume_toggle"), NULL);
|
||||
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("volume_hbox"));
|
||||
gconf_peditor_new_numeric_range
|
||||
(NULL, "/desktop/gnome/peripherals/keyboard/clickvolume", WID ("volume_scale"), NULL);
|
||||
(changeset, "/desktop/gnome/peripherals/keyboard/clickvolume", WID ("volume_scale"), NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (WID ("bell_custom_radio")), "toggled", (GCallback) bell_guard, dialog);
|
||||
peditor = gconf_peditor_new_select_radio
|
||||
(NULL, "/desktop/gnome/peripherals/keyboard/bell_mode",
|
||||
(changeset, "/desktop/gnome/peripherals/keyboard/bell_mode",
|
||||
gtk_radio_button_get_group (GTK_RADIO_BUTTON (WID ("bell_disabled_radio"))),
|
||||
"conv-to-widget-cb", bell_to_widget,
|
||||
"conv-from-widget-cb", bell_from_widget,
|
||||
|
@ -254,9 +254,7 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
GConfClient *client;
|
||||
GConfChangeSet *changeset;
|
||||
GladeXML *dialog;
|
||||
GtkWidget *dialog_win;
|
||||
|
||||
static gboolean apply_only;
|
||||
static gboolean get_legacy;
|
||||
|
@ -286,14 +284,11 @@ main (int argc, char **argv)
|
|||
if (get_legacy) {
|
||||
get_legacy_settings ();
|
||||
} else {
|
||||
changeset = gconf_change_set_new ();
|
||||
dialog = create_dialog ();
|
||||
setup_dialog (dialog, changeset);
|
||||
setup_dialog (dialog, NULL);
|
||||
|
||||
gtk_widget_show_all (WID ("keyboard_dialog"));
|
||||
gtk_main ();
|
||||
|
||||
gconf_change_set_unref (changeset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
Mon Jan 21 01:29:57 2002 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gnome-settings-keyboard.c: Move locate_pointer out.
|
||||
|
||||
* gnome-settings-mouse.c: Move locate_pointer in. Clean up code.
|
||||
Remove print statements.
|
||||
|
||||
2002-01-14 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* Makefile.am (INCLUDES): Added missing -I$(top_srcdir)
|
||||
|
|
|
@ -32,22 +32,11 @@
|
|||
|
||||
#include "gnome-settings-keyboard.h"
|
||||
#include "gnome-settings-daemon.h"
|
||||
#include "gnome-settings-locate-pointer.h"
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
||||
# include <X11/extensions/xf86misc.h>
|
||||
#endif
|
||||
|
||||
#undef HAVE_XKB
|
||||
#ifdef HAVE_XKB
|
||||
# include <X11/XKBlib.h>
|
||||
#endif
|
||||
|
||||
static gboolean use_xkb = FALSE;
|
||||
static gint xkb_event_type = 0;
|
||||
|
||||
static void
|
||||
apply_settings (void)
|
||||
{
|
||||
|
@ -83,7 +72,6 @@ apply_settings (void)
|
|||
{
|
||||
kbdsettings.type = 0;
|
||||
kbdsettings.rate = rate;
|
||||
g_message ("Setting rate to %d", kbdsettings.rate);
|
||||
kbdsettings.delay = delay;
|
||||
kbdsettings.servnumlock = False;
|
||||
XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings);
|
||||
|
@ -105,106 +93,10 @@ apply_settings (void)
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//def HAVE_XKB
|
||||
/* XKB support
|
||||
*/
|
||||
static GdkFilterReturn
|
||||
gnome_settings_keyboard_xkb_filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (((XEvent *) xevent)->type == xkb_event_type) {
|
||||
XkbEvent *xkb_event = (XkbEvent *)xevent;
|
||||
if (xkb_event->any.xkb_type == XkbStateNotify) {
|
||||
/* gnome_settings_locate_pointer (); */
|
||||
}
|
||||
}
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define KEYBOARD_GROUP_SHIFT 13
|
||||
#define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14))
|
||||
/* Owen magic */
|
||||
static GdkFilterReturn
|
||||
filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
XEvent *xev = (XEvent *) xevent;
|
||||
guint keyval;
|
||||
gint group;
|
||||
|
||||
if (xev->type == KeyPress ||
|
||||
xev->type == KeyRelease) {
|
||||
|
||||
/* get the keysym */
|
||||
group = (xev->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
|
||||
gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
|
||||
xev->xkey.keycode,
|
||||
xev->xkey.state,
|
||||
group,
|
||||
&keyval,
|
||||
NULL, NULL, NULL);
|
||||
if (keyval == GDK_Control_L) {
|
||||
if (xev->type == KeyPress) {
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
SyncKeyboard,
|
||||
xev->xkey.time);
|
||||
} else {
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
AsyncKeyboard,
|
||||
xev->xkey.time);
|
||||
gnome_settings_locate_pointer ();
|
||||
}
|
||||
} else {
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
ReplayKeyboard,
|
||||
xev->xkey.time);
|
||||
XUngrabKeyboard (gdk_x11_get_default_xdisplay (),
|
||||
xev->xkey.time);
|
||||
}
|
||||
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
return GDK_FILTER_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_settings_keyboard_init_xkb (void)
|
||||
{
|
||||
GdkKeymapKey *keys;
|
||||
int n_keys;
|
||||
|
||||
if (gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
|
||||
GDK_Control_L,
|
||||
&keys,
|
||||
&n_keys)) {
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_keys; i++) {
|
||||
XGrabKey (gdk_x11_get_default_xdisplay (),
|
||||
keys[i].keycode,
|
||||
AnyModifier,
|
||||
GDK_ROOT_WINDOW (),
|
||||
False,
|
||||
GrabModeAsync,
|
||||
GrabModeSync);
|
||||
}
|
||||
g_free (keys);
|
||||
gdk_window_add_filter (gdk_get_default_root_window (), filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
gnome_settings_keyboard_init (GConfClient *client)
|
||||
{
|
||||
gnome_settings_daemon_register_callback ("/desktop/gnome/peripherals/keyboard", (KeyCallbackFunc) apply_settings);
|
||||
gnome_settings_keyboard_init_xkb ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -213,25 +105,3 @@ gnome_settings_keyboard_load (GConfClient *client)
|
|||
apply_settings ();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//def HAVE_XKB
|
||||
gint xkb_major = XkbMajorVersion;
|
||||
gint xkb_minor = XkbMinorVersion;
|
||||
g_print ("foo1\n");
|
||||
if (XkbLibraryVersion (&xkb_major, &xkb_minor)) {
|
||||
xkb_major = XkbMajorVersion;
|
||||
xkb_minor = XkbMinorVersion;
|
||||
g_print ("foo2\n");
|
||||
|
||||
if (XkbQueryExtension (gdk_display, NULL, &xkb_event_type, NULL,
|
||||
&xkb_major, &xkb_minor)) {
|
||||
g_print ("foo3\n");
|
||||
XkbSelectEvents (gdk_display,
|
||||
XkbUseCoreKbd,
|
||||
XkbMapNotifyMask | XkbStateNotifyMask,
|
||||
XkbMapNotifyMask | XkbStateNotifyMask);
|
||||
gdk_window_add_filter (NULL, gnome_settings_keyboard_xkb_filter, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
#include <gdk/gdkx.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <string.h>
|
||||
#include "gnome-settings-locate-pointer.h"
|
||||
#include "gnome-settings-daemon.h"
|
||||
|
||||
#define MAX_BUTTONS 10
|
||||
|
@ -14,7 +17,6 @@ set_left_handed (gboolean left_handed)
|
|||
gint n_buttons, i;
|
||||
gint idx_1 = 0, idx_3 = 1;
|
||||
|
||||
g_print ("daemon: set_left_handed %d\n", left_handed);
|
||||
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS);
|
||||
|
||||
for (i = 0; i < n_buttons; i++)
|
||||
|
@ -76,6 +78,7 @@ set_motion_acceleration (gfloat motion_acceleration)
|
|||
numerator = -1;
|
||||
denominator = -1;
|
||||
}
|
||||
g_print ("%d/%d\n", numerator, denominator);
|
||||
XChangePointerControl (GDK_DISPLAY (), True, False,
|
||||
numerator, denominator,
|
||||
0);
|
||||
|
@ -88,23 +91,107 @@ set_motion_threshold (gint motion_threshold)
|
|||
0, 0, motion_threshold);
|
||||
}
|
||||
|
||||
static void
|
||||
set_drag_threshold (gint drag_threshold)
|
||||
{
|
||||
|
||||
#define KEYBOARD_GROUP_SHIFT 13
|
||||
#define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14))
|
||||
|
||||
/* Owen magic */
|
||||
static GdkFilterReturn
|
||||
filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
XEvent *xev = (XEvent *) xevent;
|
||||
guint keyval;
|
||||
gint group;
|
||||
|
||||
if (xev->type == KeyPress ||
|
||||
xev->type == KeyRelease)
|
||||
{
|
||||
/* get the keysym */
|
||||
group = (xev->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
|
||||
gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
|
||||
xev->xkey.keycode,
|
||||
xev->xkey.state,
|
||||
group,
|
||||
&keyval,
|
||||
NULL, NULL, NULL);
|
||||
if (keyval == GDK_Control_L)
|
||||
{
|
||||
if (xev->type == KeyPress)
|
||||
{
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
SyncKeyboard,
|
||||
xev->xkey.time);
|
||||
}
|
||||
else
|
||||
{
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
AsyncKeyboard,
|
||||
xev->xkey.time);
|
||||
gnome_settings_locate_pointer ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XAllowEvents (gdk_x11_get_default_xdisplay (),
|
||||
ReplayKeyboard,
|
||||
xev->xkey.time);
|
||||
XUngrabKeyboard (gdk_x11_get_default_xdisplay (),
|
||||
xev->xkey.time);
|
||||
}
|
||||
|
||||
return GDK_FILTER_REMOVE;
|
||||
}
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_locate_pointer (gboolean locate_pointer)
|
||||
{
|
||||
GdkKeymapKey *keys;
|
||||
int n_keys;
|
||||
gboolean has_entries;
|
||||
|
||||
has_entries = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
|
||||
GDK_Control_L,
|
||||
&keys,
|
||||
&n_keys);
|
||||
if (has_entries)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_keys; i++)
|
||||
{
|
||||
if (locate_pointer)
|
||||
XGrabKey (gdk_x11_get_default_xdisplay (),
|
||||
keys[i].keycode,
|
||||
AnyModifier,
|
||||
GDK_ROOT_WINDOW (),
|
||||
False,
|
||||
GrabModeAsync,
|
||||
GrabModeSync);
|
||||
else
|
||||
XUngrabKey (gdk_x11_get_default_xdisplay (),
|
||||
keys[i].keycode,
|
||||
AnyModifier,
|
||||
GDK_ROOT_WINDOW ());
|
||||
}
|
||||
g_free (keys);
|
||||
if (locate_pointer)
|
||||
gdk_window_add_filter (gdk_get_default_root_window (), filter, NULL);
|
||||
else
|
||||
gdk_window_remove_filter (gdk_get_default_root_window (), filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_callback (GConfEntry *entry)
|
||||
{
|
||||
g_print ("daemon: gconf callback %s\n", entry->key);
|
||||
if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/left_handed"))
|
||||
{
|
||||
if (entry->value->type == GCONF_VALUE_BOOL)
|
||||
set_left_handed (gconf_value_get_bool (entry->value));
|
||||
else
|
||||
g_warning ("wrong type!\n");
|
||||
}
|
||||
else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/motion_acceleration"))
|
||||
{
|
||||
|
@ -116,6 +203,11 @@ mouse_callback (GConfEntry *entry)
|
|||
if (entry->value->type == GCONF_VALUE_INT)
|
||||
set_motion_threshold (gconf_value_get_int (entry->value));
|
||||
}
|
||||
else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/locate_pointer"))
|
||||
{
|
||||
if (entry->value->type == GCONF_VALUE_BOOL)
|
||||
set_locate_pointer (gconf_value_get_bool (entry->value));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -128,5 +220,8 @@ gnome_settings_mouse_init (GConfClient *client)
|
|||
void
|
||||
gnome_settings_mouse_load (GConfClient *client)
|
||||
{
|
||||
|
||||
set_left_handed (gconf_client_get_bool (client, "/desktop/gnome/peripherals/mouse/left_handed", NULL));
|
||||
set_motion_acceleration (gconf_client_get_float (client, "/desktop/gnome/peripherals/mouse/motion_acceleration", NULL));
|
||||
set_motion_threshold (gconf_client_get_int (client, "/desktop/gnome/peripherals/mouse/motion_threshold", NULL));
|
||||
set_locate_pointer (gconf_client_get_bool (client, "/desktop/gnome/peripherals/mouse/locate_pointer", NULL));
|
||||
}
|
||||
|
|
|
@ -141,7 +141,6 @@ xsettings_callback (GConfEntry *entry)
|
|||
TranslationEntry *trans;
|
||||
trans = find_translation_entry (entry->key);
|
||||
|
||||
g_print ("daemon: notified on %s\n", entry->key);
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue