From: billh Date: Mon, 19 Apr 2004 11:07:12 +0000 (+0000) Subject: Fix for bug #114771; we now send correct strings in key event 'string' field X-Git-Tag: AT_SPI2_CORE_0_1_3~587 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=413b8cc64167ad0ca33439ad41210d0338e37d9b;p=platform%2Fupstream%2Fat-spi2-core.git Fix for bug #114771; we now send correct strings in key event 'string' field even for non-textual key events. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@656 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- diff --git a/ChangeLog b/ChangeLog index 305a6cc..dd8105a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2004-03-24 Bill Haneman +2004-04-19 Bill Haneman * configure.in: Revved to 1.5.1. diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index c758234..95640d8 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -57,6 +57,7 @@ #include "deviceeventcontroller.h" KeySym ucs2keysym (long ucs); +long keysym2ucs(KeySym keysym); #define CHECK_RELEASE_DELAY 20 #define BIT(c, x) (c[x/8]&(1<<(x%8))) @@ -1589,8 +1590,8 @@ spi_keystroke_from_x_key_event (XKeyEvent *x_key_event) gunichar c; cbuf[nbytes] = '\0'; /* OK since length is cbuf_bytes+1 */ key_event.event_string = CORBA_string_dup (cbuf); - c = g_utf8_get_char_validated (cbuf, nbytes); - if ((c > 0) && g_unichar_isprint (c)) + c = keysym2ucs (keysym); + if (c > 0 && !g_unichar_iscntrl (c)) { key_event.is_text = CORBA_TRUE; /* incorrect for some composed chars? */ diff --git a/registryd/ucs2keysym.c b/registryd/ucs2keysym.c index 58e418c..d568845 100644 --- a/registryd/ucs2keysym.c +++ b/registryd/ucs2keysym.c @@ -821,3 +821,34 @@ KeySym ucs2keysym (long ucs) return ucs | 0x01000000; } +long keysym2ucs(KeySym keysym) +{ + int min = 0; + int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; + int mid; + + /* first check for Latin-1 characters (1:1 mapping) */ + if ((keysym >= 0x0020 && keysym <= 0x007e) || + (keysym >= 0x00a0 && keysym <= 0x00ff)) + return (long) keysym; + + /* also check for directly encoded 24-bit UCS characters */ + if ((keysym & 0xff000000) == 0x01000000) + return keysym & 0x00ffffff; + + /* binary search in table */ + while (max >= min) { + mid = (min + max) / 2; + if (keysymtab[mid].keysym < keysym) + min = mid + 1; + else if (keysymtab[mid].keysym > keysym) + max = mid - 1; + else { + /* found it */ + return keysymtab[mid].ucs; + } + } + + /* no matching Unicode value found */ + return -1; +}