Fix for problem with is_text flag in key events; is_text is no longer
authorbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Wed, 9 Apr 2003 23:30:38 +0000 (23:30 +0000)
committerbillh <billh@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Wed, 9 Apr 2003 23:30:38 +0000 (23:30 +0000)
reported as TRUE when control sequences are intercepted.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@417 e2bd861d-eb25-0410-b326-f6ed22b6b98c

ChangeLog
registryd/deviceeventcontroller.c
test/key-listener-test.c

index 756507e..ca37af8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2003-04-10  Bill Haneman <bill.haneman@sun.com>
+
+       * registryd/deviceeventcontroller.c:
+       (spi_keystroke_from_x_key_event):
+       Instead of checking to see if the keysym is
+       printable, check the string from XLookupString
+       if available, get the first unicode character from it,
+       and call g_unichar_isprint to determine whether the
+       is_text flag should be TRUE or FALSE.
+       
+       Fix for bug 110419.
+
 2003-04-02  Padraig O'Briain <padraig.obriain@sun.com>
 
        * atk-bridge/bridge.c: Add support for extended events
index 3476234..bf51240 100644 (file)
@@ -2,7 +2,7 @@
  *
  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
  *
- * Copyright 2001, 2002 Sun Microsystems Inc.,
+ * Copyright 2001, 2003 Sun Microsystems Inc.,
  * Copyright 2001, 2002 Ximian, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -1249,9 +1249,6 @@ spi_keystroke_from_x_key_event (XKeyEvent *x_key_event)
         key_event.event_string = CORBA_string_dup ("space");
         break;
       case XK_Tab:
-#ifdef SPI_KEYEVENT_DEBUG
-       fprintf(stderr, "Tab\n");
-#endif
         key_event.event_string = CORBA_string_dup ("Tab");
        break;
       case XK_BackSpace:
@@ -1326,12 +1323,14 @@ spi_keystroke_from_x_key_event (XKeyEvent *x_key_event)
       default:
         if (nbytes > 0)
           {
+           gunichar c;
            cbuf[nbytes] = '\0'; /* OK since length is cbuf_bytes+1 */
             key_event.event_string = CORBA_string_dup (cbuf);
-           if ((keysym && g_ascii_isprint (keysym)) || (nbytes == 1))
+           c = g_utf8_get_char_validated (cbuf, nbytes);
+           if ((c > 0) && g_unichar_isprint (c))
              {
                key_event.is_text = CORBA_TRUE; 
-               /* FIXME: incorrect for some composed chars, unicode chars? */
+               /* incorrect for some composed chars? */
              }
           }
         else
@@ -1343,10 +1342,13 @@ spi_keystroke_from_x_key_event (XKeyEvent *x_key_event)
   key_event.timestamp = (CORBA_unsigned_long) x_key_event->time;
 #ifdef SPI_KEYEVENT_DEBUG
   fprintf (stderr,
-     "Key %lu pressed (%c), modifiers %d\n",
-     (unsigned long) keysym,
-     keysym ? (int) keysym : '*',
-     (int) x_key_event->state);
+          "Key %lu pressed (%c), modifiers %d; string=%s [%x] %s\n",
+          (unsigned long) keysym,
+          keysym ? (int) keysym : '*',
+          (int) x_key_event->state,
+          key_event.event_string,
+          key_event.event_string[0],
+          (key_event.is_text == CORBA_TRUE) ? "(text)" : "(not text)");
 #endif
 #ifdef SPI_DEBUG
   fprintf (stderr, "%s%c",
index e09942a..fc59fc0 100644 (file)
@@ -94,7 +94,7 @@ main (int argc, char **argv)
 
   retval = SPI_registerAccessibleKeystrokeListener(all_key_listener,
                                          SPI_KEYSET_ALL_KEYS,
-                                         SPI_KEYMASK_CONTROL,
+                                         SPI_KEYMASK_CONTROL | SPI_KEYMASK_SHIFT,
                                          (unsigned long) ( SPI_KEY_PRESSED | SPI_KEY_RELEASED ),
                                          SPI_KEYLISTENER_ALL_WINDOWS);