From fa464f2a2175be1b89d80fb5088c4155b554e14e Mon Sep 17 00:00:00 2001 From: billh Date: Mon, 14 Jan 2002 17:48:47 +0000 Subject: [PATCH] Workaround/error trapping for failed keygrabs in device event controller; helpful when running on Solaris in particular. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@222 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 10 ++++++ docs/reference/cspi/tmpl/spi_accessible.sgml | 3 +- docs/reference/cspi/tmpl/spi_action.sgml | 12 ++++--- docs/reference/cspi/tmpl/spi_component.sgml | 9 ++++-- docs/reference/cspi/tmpl/spi_editabletext.sgml | 18 +++++++---- docs/reference/cspi/tmpl/spi_hyperlink.sgml | 7 ++-- docs/reference/cspi/tmpl/spi_hypertext.sgml | 6 ++-- docs/reference/cspi/tmpl/spi_image.sgml | 3 ++ docs/reference/cspi/tmpl/spi_registry.sgml | 6 ++-- docs/reference/cspi/tmpl/spi_selection.sgml | 12 ++++--- docs/reference/cspi/tmpl/spi_table.sgml | 45 +++++++++++++++++--------- docs/reference/cspi/tmpl/spi_text.sgml | 32 ++++++++++++------ registryd/deviceeventcontroller.c | 26 +++++++++++++++ test/keysynth-demo.c | 2 +- 14 files changed, 142 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3aa428..365b29a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2002-01-11 Bill Haneman + * registryd/deviceeventcontroller.c: + Replaced standard X error handler with a special handler that + is non-fatal for failed keygrabs. This works around + problems with keygrab clashes sometimes observed on + Solaris using CDE. + Re-instated SPI_DEVICE_TYPE_MOUSE in enum (didn't reinstate + mouse handling code as yet). + +2002-01-11 Bill Haneman + * configure.in: Incremented revision for desktop alpha release. diff --git a/docs/reference/cspi/tmpl/spi_accessible.sgml b/docs/reference/cspi/tmpl/spi_accessible.sgml index f177805..449ffe5 100644 --- a/docs/reference/cspi/tmpl/spi_accessible.sgml +++ b/docs/reference/cspi/tmpl/spi_accessible.sgml @@ -76,8 +76,9 @@ Accessible Objects @obj: -@childIndex: @Returns: + +@childIndex: diff --git a/docs/reference/cspi/tmpl/spi_action.sgml b/docs/reference/cspi/tmpl/spi_action.sgml index 4674885..e9b2142 100644 --- a/docs/reference/cspi/tmpl/spi_action.sgml +++ b/docs/reference/cspi/tmpl/spi_action.sgml @@ -49,8 +49,9 @@ AccessibleAction Interface @obj: -@i: @Returns: + +@i: @@ -59,8 +60,9 @@ AccessibleAction Interface @obj: -@i: @Returns: + +@i: @@ -69,8 +71,9 @@ AccessibleAction Interface @obj: -@i: @Returns: + +@i: @@ -79,7 +82,8 @@ AccessibleAction Interface @obj: -@i: @Returns: + +@i: diff --git a/docs/reference/cspi/tmpl/spi_component.sgml b/docs/reference/cspi/tmpl/spi_component.sgml index b6a1372..bba2e1d 100644 --- a/docs/reference/cspi/tmpl/spi_component.sgml +++ b/docs/reference/cspi/tmpl/spi_component.sgml @@ -62,10 +62,11 @@ AccessibleComponent Interface @obj: +@Returns: + @x: @y: @ctype: -@Returns: @@ -74,10 +75,11 @@ AccessibleComponent Interface @obj: +@Returns: + @x: @y: @ctype: -@Returns: @@ -86,6 +88,7 @@ AccessibleComponent Interface @obj: + @x: @y: @width: @@ -99,6 +102,7 @@ AccessibleComponent Interface @obj: + @x: @y: @ctype: @@ -110,6 +114,7 @@ AccessibleComponent Interface @obj: + @width: @height: diff --git a/docs/reference/cspi/tmpl/spi_editabletext.sgml b/docs/reference/cspi/tmpl/spi_editabletext.sgml index 730d515..8fa6fdd 100644 --- a/docs/reference/cspi/tmpl/spi_editabletext.sgml +++ b/docs/reference/cspi/tmpl/spi_editabletext.sgml @@ -40,9 +40,10 @@ AccessibleEditableText Interface @obj: +@Returns: + @startPos: @endPos: -@Returns: @@ -51,9 +52,10 @@ AccessibleEditableText Interface @obj: +@Returns: + @startPos: @endPos: -@Returns: @@ -62,10 +64,11 @@ AccessibleEditableText Interface @obj: +@Returns: + @position: @text: @length: -@Returns: @@ -74,9 +77,10 @@ AccessibleEditableText Interface @obj: +@Returns: + @startPos: @endPos: -@Returns: @@ -85,8 +89,9 @@ AccessibleEditableText Interface @obj: -@position: @Returns: + +@position: @@ -106,8 +111,9 @@ AccessibleEditableText Interface @obj: @attributes: +@Returns: + @startOffset: @endOffset: -@Returns: diff --git a/docs/reference/cspi/tmpl/spi_hyperlink.sgml b/docs/reference/cspi/tmpl/spi_hyperlink.sgml index 8d03b55..2f923b0 100644 --- a/docs/reference/cspi/tmpl/spi_hyperlink.sgml +++ b/docs/reference/cspi/tmpl/spi_hyperlink.sgml @@ -45,6 +45,7 @@ AccessibleHyperlink Interface @obj: + @startIndex: @endIndex: @@ -55,8 +56,9 @@ AccessibleHyperlink Interface @obj: -@i: @Returns: + +@i: @@ -65,8 +67,9 @@ AccessibleHyperlink Interface @obj: -@i: @Returns: + +@i: diff --git a/docs/reference/cspi/tmpl/spi_hypertext.sgml b/docs/reference/cspi/tmpl/spi_hypertext.sgml index 5a7f2c0..30d313a 100644 --- a/docs/reference/cspi/tmpl/spi_hypertext.sgml +++ b/docs/reference/cspi/tmpl/spi_hypertext.sgml @@ -49,8 +49,9 @@ AccessibleHypertext Interface @obj: -@linkIndex: @Returns: + +@linkIndex: @@ -59,7 +60,8 @@ AccessibleHypertext Interface @obj: -@characterOffset: @Returns: + +@characterOffset: diff --git a/docs/reference/cspi/tmpl/spi_image.sgml b/docs/reference/cspi/tmpl/spi_image.sgml index 32f036e..f666d78 100644 --- a/docs/reference/cspi/tmpl/spi_image.sgml +++ b/docs/reference/cspi/tmpl/spi_image.sgml @@ -49,6 +49,7 @@ AccessibleImage Interface @obj: + @width: @height: @@ -59,6 +60,7 @@ AccessibleImage Interface @obj: + @x: @y: @ctype: @@ -70,6 +72,7 @@ AccessibleImage Interface @obj: + @x: @y: @width: diff --git a/docs/reference/cspi/tmpl/spi_registry.sgml b/docs/reference/cspi/tmpl/spi_registry.sgml index 09ab7cd..fb55349 100644 --- a/docs/reference/cspi/tmpl/spi_registry.sgml +++ b/docs/reference/cspi/tmpl/spi_registry.sgml @@ -195,10 +195,11 @@ Registry queries +@Returns: + @keyval: @keystring: @synth_type: -@Returns: @@ -206,9 +207,10 @@ Registry queries +@Returns: + @x: @y: @name: -@Returns: diff --git a/docs/reference/cspi/tmpl/spi_selection.sgml b/docs/reference/cspi/tmpl/spi_selection.sgml index d46f4ae..2668a50 100644 --- a/docs/reference/cspi/tmpl/spi_selection.sgml +++ b/docs/reference/cspi/tmpl/spi_selection.sgml @@ -49,8 +49,9 @@ AccessibleSelection Interface @obj: -@selectedChildIndex: @Returns: + +@selectedChildIndex: @@ -59,8 +60,9 @@ AccessibleSelection Interface @obj: -@childIndex: @Returns: + +@childIndex: @@ -69,8 +71,9 @@ AccessibleSelection Interface @obj: -@childIndex: @Returns: + +@childIndex: @@ -79,8 +82,9 @@ AccessibleSelection Interface @obj: -@selectedChildIndex: @Returns: + +@selectedChildIndex: diff --git a/docs/reference/cspi/tmpl/spi_table.sgml b/docs/reference/cspi/tmpl/spi_table.sgml index 331c16a..38d142a 100644 --- a/docs/reference/cspi/tmpl/spi_table.sgml +++ b/docs/reference/cspi/tmpl/spi_table.sgml @@ -40,9 +40,10 @@ AccessibleTable Interface @obj: +@Returns: + @row: @column: -@Returns: @@ -60,8 +61,9 @@ AccessibleTable Interface @obj: -@index: @Returns: + +@index: @@ -70,8 +72,9 @@ AccessibleTable Interface @obj: -@column: @Returns: + +@column: @@ -80,9 +83,10 @@ AccessibleTable Interface @obj: +@Returns: + @row: @column: -@Returns: @@ -91,8 +95,9 @@ AccessibleTable Interface @obj: -@column: @Returns: + +@column: @@ -101,9 +106,10 @@ AccessibleTable Interface @obj: +@Returns: + @row: @column: -@Returns: @@ -148,8 +154,9 @@ AccessibleTable Interface @obj: -@index: @Returns: + +@index: @@ -158,8 +165,9 @@ AccessibleTable Interface @obj: -@row: @Returns: + +@row: @@ -168,9 +176,10 @@ AccessibleTable Interface @obj: +@Returns: + @row: @column: -@Returns: @@ -179,8 +188,9 @@ AccessibleTable Interface @obj: -@row: @Returns: + +@row: @@ -189,8 +199,9 @@ AccessibleTable Interface @obj: -@selectedRows: @Returns: + +@selectedRows: @@ -199,8 +210,9 @@ AccessibleTable Interface @obj: -@selectedColumns: @Returns: + +@selectedColumns: @@ -218,8 +230,9 @@ AccessibleTable Interface @obj: -@column: @Returns: + +@column: @@ -228,8 +241,9 @@ AccessibleTable Interface @obj: -@row: @Returns: + +@row: @@ -238,8 +252,9 @@ AccessibleTable Interface @obj: +@Returns: + @row: @column: -@Returns: diff --git a/docs/reference/cspi/tmpl/spi_text.sgml b/docs/reference/cspi/tmpl/spi_text.sgml index c4e6c77..b3bc9dd 100644 --- a/docs/reference/cspi/tmpl/spi_text.sgml +++ b/docs/reference/cspi/tmpl/spi_text.sgml @@ -55,9 +55,10 @@ AccessibleText Interface @obj: +@Returns: + @startOffset: @endOffset: -@Returns: @@ -66,10 +67,11 @@ AccessibleText Interface @obj: +@Returns: + @offset: @startOffset: @endOffset: -@Returns: @@ -96,6 +98,7 @@ AccessibleText Interface @obj: + @offset: @x: @y: @@ -119,10 +122,11 @@ AccessibleText Interface @obj: +@Returns: + @x: @y: @type: -@Returns: @@ -131,6 +135,7 @@ AccessibleText Interface @obj: + @selectionNum: @startOffset: @endOffset: @@ -142,9 +147,10 @@ AccessibleText Interface @obj: +@Returns: + @startOffset: @endOffset: -@Returns: @@ -153,11 +159,12 @@ AccessibleText Interface @obj: +@Returns: + @offset: @type: @startOffset: @endOffset: -@Returns: @@ -166,11 +173,12 @@ AccessibleText Interface @obj: +@Returns: + @offset: @type: @startOffset: @endOffset: -@Returns: @@ -179,11 +187,12 @@ AccessibleText Interface @obj: +@Returns: + @offset: @type: @startOffset: @endOffset: -@Returns: @@ -192,8 +201,9 @@ AccessibleText Interface @obj: -@selectionNum: @Returns: + +@selectionNum: @@ -202,8 +212,9 @@ AccessibleText Interface @obj: -@newOffset: @Returns: + +@newOffset: @@ -212,9 +223,10 @@ AccessibleText Interface @obj: +@Returns: + @selectionNum: @startOffset: @endOffset: -@Returns: diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 04586e0..4338cb8 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -49,8 +49,11 @@ /* A pointer to our parent object class */ static GObjectClass *spi_device_event_controller_parent_class; +int (*x_default_error_handler) (Display *display, XErrorEvent *error_event); + typedef enum { SPI_DEVICE_TYPE_KBD, + SPI_DEVICE_TYPE_MOUSE, SPI_DEVICE_TYPE_LAST_DEFINED } SpiDeviceTypeCategory; @@ -309,6 +312,19 @@ global_filter_fn (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) return GDK_FILTER_CONTINUE; } +int +_spi_controller_device_error_handler (Display *display, XErrorEvent *error) +{ + if (error->error_code == BadAccess) + { + g_message ("Could not complete key grab: grab already in use.\n"); + } + else + { + (*x_default_error_handler) (display, error); + } +} + static void spi_controller_register_with_devices (SpiDEController *controller) { @@ -321,6 +337,8 @@ spi_controller_register_with_devices (SpiDEController *controller) gdk_window_set_events (gdk_get_default_root_window (), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); + x_default_error_handler = XSetErrorHandler (_spi_controller_device_error_handler); + XSelectInput (GDK_DISPLAY (), DefaultRootWindow (GDK_DISPLAY ()), KeyPressMask | KeyReleaseMask); @@ -597,6 +615,9 @@ spi_controller_update_key_grabs (SpiDEController *controller, } else if (grab_mask->pending_remove) { +#ifdef SPI_DEBUG + fprintf (stderr, "ungrabbing, mask=%x\n", grab_mask->mod_mask); +#endif XUngrabKey (GDK_DISPLAY (), grab_mask->key_val, grab_mask->mod_mask, @@ -606,6 +627,10 @@ spi_controller_update_key_grabs (SpiDEController *controller, } else if (grab_mask->pending_add || re_issue_grab) { + +#ifdef SPI_DEBUG + fprintf (stderr, "grab with mask %x\n", grab_mask->mod_mask); +#endif XGrabKey (GDK_DISPLAY (), grab_mask->key_val, grab_mask->mod_mask, @@ -648,6 +673,7 @@ spi_device_event_controller_object_finalize (GObject *object) fprintf(stderr, "spi_device_event_controller_object_finalize called\n"); #endif /* disconnect any special listeners, get rid of outstanding keygrabs */ + XUngrabKey (GDK_DISPLAY (), AnyKey, AnyModifier, DefaultRootWindow (GDK_DISPLAY ())); spi_device_event_controller_parent_class->finalize (object); } diff --git a/test/keysynth-demo.c b/test/keysynth-demo.c index e3713eb..305f805 100644 --- a/test/keysynth-demo.c +++ b/test/keysynth-demo.c @@ -480,7 +480,7 @@ main (int argc, char **argv) /* will listen only to Alt-key combinations */ SPI_registerAccessibleKeystrokeListener (key_listener, (AccessibleKeySet *) SPI_KEYSET_ALL_KEYS, - SPI_KEYMASK_ALT, + SPI_KEYMASK_ALT | SPI_KEYMASK_CONTROL, (unsigned long) ( KeyPress | KeyRelease), SPI_KEYLISTENER_CANCONSUME | SPI_KEYLISTENER_ALL_WINDOWS); create_vkbd (); -- 2.7.4