[g-a-devel]at-spi patch for key strings
- From: Bill Haneman <bill haneman sun com>
- To: gnome-accessibility-devel gnome org
- Subject: [g-a-devel]at-spi patch for key strings
- Date: Mon, 17 Dec 2001 17:53:29 +0000
Attached is a patch for at-spi that will be applied to CVS HEAD.
It provides an event_string member for Accessibility_DeviceEvent events
from key presses.
This string member is available via the AccessibleKeystroke->keystring
member in CSPI.
This string contains either a textual name for the current keypress, or
if the current keypress results in the production of a composed
keystring (for instance, in international text input methods), then the
composed string is returned.
-Bill
? at-spi-1.0.pc
? atspi-101201-1.diff
? atspi-111101-1.diff
? atspi-111201-1.diff
? atspi-121201-2.diff
? atspi-121201-1.diff
? atspi-121201-3.diff
? atspi-121201-4.diff
? atspi-121201-5.diff
? bootstrap.txt
? atspi-151201-1.diff
? atspi-171201-1.diff
? docs/reference/cspi/tmpl/at-spi-cspi-unused.sgml
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.123
diff -u -r1.123 ChangeLog
--- ChangeLog 2001/12/15 22:53:56 1.123
+++ ChangeLog 2001/12/17 17:53:43
@@ -1,3 +1,24 @@
+2001-12-17 Bill Haneman <bill haneman sun com>
+
+ * at-bridge/bridge.c:
+ Namespaced local static methods to spi_atk_bridge_* where
+ previously named bridge_*, and spi_* elsewhere.
+
+ * at-bridge/bridge.c:
+ * cspi/bonobo/cspi-bonobo-listener.c:
+ Added demarshalling/conversion for string member of
+ Accessibility_DeviceEvent to AccessibleKeystroke.
+
+ * registryd/deviceeventcontroller.c:
+ Added code to fill the Accessibility_DeviceEvent key string value
+ member for global key events (i.e. from XGrabKey), to match
+ behavior of Accessibility_DeviceEvent from the toolkit key events
+ from the bridge. Fixed timestamp in global key event notifications.
+
+ * test/simple-at.c:
+ Added printout of key event's string value to
+ report_ordinary_key_event, for demo/debugging purposes.
+
2001-12-15 Bill Haneman <bill haneman sun com>
* idl/Accessibility_Registry.idl:
Index: at-bridge/bridge.c
===================================================================
RCS file: /cvs/gnome/at-spi/at-bridge/bridge.c,v
retrieving revision 1.24
diff -u -r1.24 bridge.c
--- at-bridge/bridge.c 2001/12/15 22:53:57 1.24
+++ at-bridge/bridge.c 2001/12/17 17:53:44
@@ -38,25 +38,24 @@
static Accessibility_Registry registry;
static SpiApplication *this_app = NULL;
-static gboolean bridge_idle_init (gpointer user_data);
-static void bridge_focus_tracker (AtkObject *object);
-static void bridge_exit_func (void);
-static void register_atk_event_listeners (void);
-static gboolean bridge_property_event_listener (GSignalInvocationHint *signal_hint,
+static gboolean spi_atk_bridge_idle_init (gpointer user_data);
+static void spi_atk_bridge_focus_tracker (AtkObject *object);
+static void spi_atk_bridge_exit_func (void);
+static void spi_atk_register_event_listeners (void);
+static gboolean spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data);
+static gboolean spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data);
+static gboolean spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
guint n_param_values,
const GValue *param_values,
gpointer data);
-static gboolean bridge_state_event_listener (GSignalInvocationHint *signal_hint,
- guint n_param_values,
- const GValue *param_values,
- gpointer data);
-static gboolean bridge_signal_listener (GSignalInvocationHint *signal_hint,
- guint n_param_values,
- const GValue *param_values,
- gpointer data);
-
-static gint bridge_key_listener (AtkKeyEventStruct *event,
- gpointer data);
+static gint spi_atk_bridge_key_listener (AtkKeyEventStruct *event,
+ gpointer data);
int
gtk_module_init (gint *argc, gchar **argv[])
@@ -98,17 +97,17 @@
BONOBO_OBJREF (this_app),
&ev);
- g_atexit (bridge_exit_func);
+ g_atexit (spi_atk_bridge_exit_func);
- g_idle_add (bridge_idle_init, NULL);
+ g_idle_add (spi_atk_bridge_idle_init, NULL);
return 0;
}
static gboolean
-bridge_idle_init (gpointer user_data)
+spi_atk_bridge_idle_init (gpointer user_data)
{
- register_atk_event_listeners ();
+ spi_atk_register_event_listeners ();
fprintf (stderr, "Application registered & listening\n");
@@ -116,7 +115,7 @@
}
static void
-register_atk_event_listeners (void)
+spi_atk_register_event_listeners (void)
{
/*
* kludge to make sure the Atk interface types are registered, otherwise
@@ -127,35 +126,35 @@
/* Register for focus event notifications, and register app with central registry */
- atk_add_focus_tracker (bridge_focus_tracker);
- atk_add_global_event_listener (bridge_property_event_listener, "Gtk:AtkObject:property-change");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:children-changed");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkObject:visible-data-changed");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkSelection:selection-changed");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-selection-changed");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-changed");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkText:text-caret-moved");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-inserted");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-reordered");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:row-deleted");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-inserted");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-reordered");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:column-deleted");
- atk_add_global_event_listener (bridge_signal_listener, "Gtk:AtkTable:model-changed");
+ atk_add_focus_tracker (spi_atk_bridge_focus_tracker);
+ atk_add_global_event_listener (spi_atk_bridge_property_event_listener, "Gtk:AtkObject:property-change");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkObject:children-changed");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkObject:visible-data-changed");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkSelection:selection-changed");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkText:text-selection-changed");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkText:text-changed");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkText:text-caret-moved");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:row-inserted");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:row-reordered");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:row-deleted");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:column-inserted");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:column-reordered");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:column-deleted");
+ atk_add_global_event_listener (spi_atk_bridge_signal_listener, "Gtk:AtkTable:model-changed");
/*
* May add the following listeners to implement preemptive key listening for GTK+
*
- * atk_add_global_event_listener (bridge_widgetkey_listener, "Gtk:GtkWidget:key-press-event");
- * atk_add_global_event_listener (bridge_widgetkey_listener, "Gtk:GtkWidget:key-release-event");
+ * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-press-event");
+ * atk_add_global_event_listener (spi_atk_bridge_widgetkey_listener, "Gtk:GtkWidget:key-release-event");
*/
- atk_add_key_event_listener (bridge_key_listener, NULL);
+ atk_add_key_event_listener (spi_atk_bridge_key_listener, NULL);
g_object_unref (G_OBJECT (bo));
g_object_unref (ao);
}
static void
-bridge_exit_func (void)
+spi_atk_bridge_exit_func (void)
{
BonoboObject *app = (BonoboObject *) this_app;
@@ -195,7 +194,7 @@
}
static void
-bridge_focus_tracker (AtkObject *object)
+spi_atk_bridge_focus_tracker (AtkObject *object)
{
SpiAccessible *source;
Accessibility_Event e;
@@ -213,10 +212,10 @@
}
static void
-emit_eventv (GObject *gobject,
- unsigned long detail1,
- unsigned long detail2,
- const char *format, ...)
+spi_atk_emit_eventv (GObject *gobject,
+ unsigned long detail1,
+ unsigned long detail2,
+ const char *format, ...)
{
va_list args;
Accessibility_Event e;
@@ -271,10 +270,10 @@
}
static gboolean
-bridge_property_event_listener (GSignalInvocationHint *signal_hint,
- guint n_param_values,
- const GValue *param_values,
- gpointer data)
+spi_atk_bridge_property_event_listener (GSignalInvocationHint *signal_hint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data)
{
AtkPropertyValues *values;
GObject *gobject;
@@ -296,16 +295,16 @@
gobject = g_value_get_object (param_values + 0);
values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
- emit_eventv (gobject, 0, 0, "object:property-change:%s", values->property_name);
+ spi_atk_emit_eventv (gobject, 0, 0, "object:property-change:%s", values->property_name);
return TRUE;
}
static gboolean
-bridge_state_event_listener (GSignalInvocationHint *signal_hint,
- guint n_param_values,
- const GValue *param_values,
- gpointer data)
+spi_atk_bridge_state_event_listener (GSignalInvocationHint *signal_hint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data)
{
GObject *gobject;
AtkPropertyValues *values;
@@ -322,17 +321,17 @@
gobject = g_value_get_object (param_values + 0);
values = (AtkPropertyValues*) g_value_get_pointer (param_values + 1);
- emit_eventv (gobject,
- (unsigned long) values->old_value.data[0].v_ulong,
- (unsigned long) values->new_value.data[0].v_ulong,
- "object:%s:?", values->property_name);
-
+ spi_atk_emit_eventv (gobject,
+ (unsigned long) values->old_value.data[0].v_ulong,
+ (unsigned long) values->new_value.data[0].v_ulong,
+ "object:%s:?", values->property_name);
+
return TRUE;
}
static void
-accessibility_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
- AtkKeyEventStruct *event)
+spi_init_keystroke_from_atk_key_event (Accessibility_DeviceEvent *keystroke,
+ AtkKeyEventStruct *event)
{
#ifdef SPI_DEBUG
if (event)
@@ -350,7 +349,14 @@
keystroke->hw_code = (CORBA_short) event->keycode;
keystroke->timestamp = (CORBA_unsigned_long) event->timestamp;
keystroke->modifiers = (CORBA_unsigned_short) (event->state & 0xFFFF);
-
+ if (event->string)
+ {
+ keystroke->event_string = CORBA_string_dup (event->string);
+ }
+ else
+ {
+ keystroke->event_string = CORBA_string_dup ("");
+ }
switch (event->type)
{
case (ATK_KEY_EVENT_PRESS):
@@ -366,7 +372,7 @@
}
static gint
-bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
+spi_atk_bridge_key_listener (AtkKeyEventStruct *event, gpointer data)
{
CORBA_boolean result;
Accessibility_DeviceEvent key_event;
@@ -381,7 +387,7 @@
else
{
- accessibility_init_keystroke_from_atk_key_event (&key_event, event);
+ spi_init_keystroke_from_atk_key_event (&key_event, event);
result = Accessibility_DeviceEventController_notifyListenersSync (
controller, &key_event, &ev);
@@ -393,10 +399,10 @@
}
static gboolean
-bridge_signal_listener (GSignalInvocationHint *signal_hint,
- guint n_param_values,
- const GValue *param_values,
- gpointer data)
+spi_atk_bridge_signal_listener (GSignalInvocationHint *signal_hint,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer data)
{
GObject *gobject;
GSignalQuery signal_query;
@@ -418,7 +424,7 @@
gobject = g_value_get_object (param_values + 0);
- emit_eventv (gobject, 0, 0, "object:%s", name);
+ spi_atk_emit_eventv (gobject, 0, 0, "object:%s", name);
return TRUE;
}
Index: cspi/bonobo/cspi-bonobo-listener.c
===================================================================
RCS file: /cvs/gnome/at-spi/cspi/bonobo/cspi-bonobo-listener.c,v
retrieving revision 1.9
diff -u -r1.9 cspi-bonobo-listener.c
--- cspi/bonobo/cspi-bonobo-listener.c 2001/12/15 22:53:58 1.9
+++ cspi/bonobo/cspi-bonobo-listener.c 2001/12/17 17:53:44
@@ -195,6 +195,7 @@
akeystroke.keyID = keystroke->id;
akeystroke.keycode = keystroke->hw_code;
akeystroke.timestamp = keystroke->timestamp;
+ akeystroke.keystring = g_strdup (keystroke->event_string);
akeystroke.modifiers = keystroke->modifiers;
/* FIXME: re-enterancy hazard on this list */
Index: registryd/deviceeventcontroller.c
===================================================================
RCS file: /cvs/gnome/at-spi/registryd/deviceeventcontroller.c,v
retrieving revision 1.21
diff -u -r1.21 deviceeventcontroller.c
--- registryd/deviceeventcontroller.c 2001/12/15 22:54:00 1.21
+++ registryd/deviceeventcontroller.c 2001/12/17 17:53:46
@@ -24,7 +24,7 @@
#include <config.h>
-#define SPI_DEBUG
+#undef SPI_DEBUG
#ifdef SPI_DEBUG
# include <stdio.h>
@@ -32,6 +32,8 @@
#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
+#define XK_MISCELLANY
+#include <X11/keysymdef.h>
#include <gdk/gdkx.h> /* TODO: hide dependency (wrap in single porting file) */
#include <gdk/gdkwindow.h>
@@ -436,6 +438,8 @@
{
Accessibility_DeviceEvent key_event;
KeySym keysym;
+ const int cbuf_bytes = 20;
+ char cbuf [cbuf_bytes];
keysym = XLookupKeysym (x_key_event, 0);
key_event.id = (CORBA_long)(keysym);
@@ -449,6 +453,33 @@
key_event.type = Accessibility_KEY_RELEASED;
}
key_event.modifiers = (CORBA_unsigned_short)(x_key_event->state);
+
+ switch (keysym)
+ {
+ case ' ':
+ key_event.event_string = CORBA_string_dup ("space");
+ break;
+ case XK_Tab:
+ key_event.event_string = CORBA_string_dup ("Tab");
+ break;
+ case XK_BackSpace:
+ key_event.event_string = CORBA_string_dup ("Backspace");
+ break;
+ case XK_Return:
+ key_event.event_string = CORBA_string_dup ("Return");
+ break;
+ default:
+ if (XLookupString (x_key_event, cbuf, cbuf_bytes, &keysym, NULL) > 0)
+ {
+ key_event.event_string = CORBA_string_dup (cbuf);
+ }
+ else
+ {
+ key_event.event_string = CORBA_string_dup ("");
+ }
+ }
+
+ key_event.timestamp = (CORBA_unsigned_long) x_key_event->time;
#ifdef SPI_KEYEVENT_DEBUG
fprintf (stderr,
"Key %lu pressed (%c), modifiers %d\n",
@@ -488,7 +519,6 @@
if (XFilterEvent (x_event, None)) continue;
if (x_event->type == KeyPress || x_event->type == KeyRelease)
{
- fprintf (stderr, "x event type=%d\n", x_event->type);
key_event = spi_keystroke_from_x_key_event ((XKeyEvent *) x_event);
/* relay to listeners, and decide whether to consume it or not */
is_consumed = spi_notify_keylisteners (controller->key_listeners, &key_event, CORBA_TRUE, &ev);
Index: test/simple-at.c
===================================================================
RCS file: /cvs/gnome/at-spi/test/simple-at.c,v
retrieving revision 1.28
diff -u -r1.28 simple-at.c
--- test/simple-at.c 2001/12/15 22:54:01 1.28
+++ test/simple-at.c 2001/12/17 17:53:47
@@ -366,11 +366,13 @@
static SPIBoolean
report_command_key_event (AccessibleKeystroke *key, void *user_data)
{
- fprintf (stderr, "Command KeyEvent %s%c (keycode %d)\n",
+ fprintf (stderr, "Command KeyEvent %s%c (keycode %d); string=%s; time=%lx\n",
(key->modifiers & SPI_KEYMASK_ALT)?"Alt-":"",
((key->modifiers & SPI_KEYMASK_SHIFT)^(key->modifiers & SPI_KEYMASK_SHIFTLOCK))?
(char) toupper((int) key->keyID) : (char) tolower((int) key->keyID),
- (int) key->keycode);
+ (int) key->keycode,
+ key->keystring,
+ (long int) key->timestamp);
return is_command_key (key);
}
@@ -378,10 +380,11 @@
static SPIBoolean
report_ordinary_key_event (AccessibleKeystroke *key, void *user_data)
{
- fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\ttime %ld\n",
+ fprintf (stderr, "Received key event:\tsym %ld\n\tmods %x\n\tcode %d\n\tstring=\'%s\'\n\ttime %lx\n",
(long) key->keyID,
(unsigned int) key->modifiers,
(int) key->keycode,
+ key->keystring,
(long int) key->timestamp);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]