diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-06-02 02:24:25 +0300 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2006-06-06 12:47:43 -0700 |
commit | a4ac2242b588da23044a20aa999ae84d4de7b2d8 (patch) | |
tree | 0fb3a9cd95262f74d43780da828e5146d49348b1 | |
parent | 90de1e2e141ec591048a76cb695579ef809a28d3 (diff) | |
download | xorg-lib-libX11-a4ac2242b588da23044a20aa999ae84d4de7b2d8.tar.gz |
im: add Braille input method (#6296)
Bug #6296: Add a Braille input method. (Samuel Thibault)
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | modules/im/ximcp/imLcFlt.c | 36 | ||||
-rw-r--r-- | modules/im/ximcp/imLcIc.c | 16 | ||||
-rw-r--r-- | modules/im/ximcp/imLcLkup.c | 142 | ||||
-rw-r--r-- | modules/im/ximcp/imRm.c | 4 | ||||
-rw-r--r-- | src/util/makekeys.c | 2 | ||||
-rw-r--r-- | src/xlibi18n/Ximint.h | 2 | ||||
-rw-r--r-- | src/xlibi18n/XimintL.h | 3 |
8 files changed, 146 insertions, 61 deletions
diff --git a/configure.ac b/configure.ac index bfde734c..704b628c 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ AC_PROG_CC XORG_PROG_RAWCPP # Checks for pkg-config packages -PKG_CHECK_MODULES(XPROTO, xproto) +PKG_CHECK_MODULES(XPROTO, [xproto >= 7.0.6]) AC_SUBST(XPROTO_CFLAGS) PKG_CHECK_MODULES(X11, xextproto xtrans xau xcmiscproto bigreqsproto) diff --git a/modules/im/ximcp/imLcFlt.c b/modules/im/ximcp/imLcFlt.c index c3c64bf4..1ca19df8 100644 --- a/modules/im/ximcp/imLcFlt.c +++ b/modules/im/ximcp/imLcFlt.c @@ -51,16 +51,43 @@ _XimLocalFilter(d, w, ev, client_data) static char buf[256]; DefTree *p; - if( (ev->type != KeyPress) - || (ev->xkey.keycode == 0) - || (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) ) - return(False); + if(ev->xkey.keycode == 0) + return (False); XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL); if(IsModifierKey(keysym)) return (False); + if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) { + if(ev->type == KeyPress) { + ic->private.local.brl_pressed |= + 1<<(keysym-XK_braille_dot_1); + } else { + if(!ic->private.local.brl_committing + || ev->xkey.time - ic->private.local.brl_release_start > 300) { + ic->private.local.brl_committing = ic->private.local.brl_pressed; + ic->private.local.brl_release_start = ev->xkey.time; + } + ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1)); + if(!ic->private.local.brl_pressed) { + if(ic->private.local.brl_committing) { + ic->private.local.brl_committed = + ic->private.local.brl_committing; + ic->private.local.composed = NULL; + ev->type = KeyPress; + ev->xkey.keycode = 0; + _XPutBackEvent(d, ev); + } + } + } + return(True); + } + + if( (ev->type != KeyPress) + || (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) ) + return(False); + for(p = ic->private.local.context; p; p = p->next) { if(((ev->xkey.state & p->modifier_mask) == p->modifier) && (keysym == p->keysym)) { @@ -74,6 +101,7 @@ _XimLocalFilter(d, w, ev, client_data) return(True); } else { /* Terminate (reached to leaf) */ ic->private.local.composed = p; + ic->private.local.brl_committed = 0; /* return back to client KeyPressEvent keycode == 0 */ ev->xkey.keycode = 0; _XPutBackEvent(d, ev); diff --git a/modules/im/ximcp/imLcIc.c b/modules/im/ximcp/imLcIc.c index 760e24c5..ddf7c69e 100644 --- a/modules/im/ximcp/imLcIc.c +++ b/modules/im/ximcp/imLcIc.c @@ -87,7 +87,7 @@ _XimLocalSetFocus( if (ic->core.focus_window) _XRegisterFilterByType(ic->core.im->core.display, - ic->core.focus_window, KeyPress, KeyPress, + ic->core.focus_window, KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic); return; } @@ -97,8 +97,11 @@ _XimLocalReset( XIC xic) { Xic ic = (Xic)xic; - ic->private.local.composed = (DefTree *)NULL; - ic->private.local.context = ((Xim)ic->core.im)->private.local.top; + ic->private.local.composed = (DefTree *)NULL; + ic->private.local.context = ((Xim)ic->core.im)->private.local.top; + ic->private.local.brl_pressed = 0; + ic->private.local.brl_committing = 0; + ic->private.local.brl_committed = 0; } Private char * @@ -149,8 +152,11 @@ _XimLocalCreateIC( ic->methods = &Local_ic_methods; ic->core.im = im; - ic->private.local.context = ((Xim)im)->private.local.top; - ic->private.local.composed = (DefTree *)NULL; + ic->private.local.context = ((Xim)im)->private.local.top; + ic->private.local.composed = (DefTree *)NULL; + ic->private.local.brl_pressed = 0; + ic->private.local.brl_committing = 0; + ic->private.local.brl_committed = 0; num = im->core.ic_num_resources; len = sizeof(XIMResource) * num; diff --git a/modules/im/ximcp/imLcLkup.c b/modules/im/ximcp/imLcLkup.c index 59025a52..f99cd831 100644 --- a/modules/im/ximcp/imLcLkup.c +++ b/modules/im/ximcp/imLcLkup.c @@ -42,6 +42,7 @@ PERFORMANCE OF THIS SOFTWARE. #include <X11/Xutil.h> #include "Xlibint.h" #include "Xlcint.h" +#include "XlcPubI.h" #include "Ximint.h" Public int @@ -60,25 +61,43 @@ _XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status) if(status) *status = XLookupNone; return(0); } - if(ev->keycode == 0 && ic->private.local.composed != NULL) { /* Composed Event */ - ret = strlen(ic->private.local.composed->mb); - if(ret > bytes) { - if(status) *status = XBufferOverflow; - return(ret); - } - memcpy(buffer, ic->private.local.composed->mb, ret); - if(keysym) *keysym = ic->private.local.composed->ks; - if (ret > 0) { - if (keysym && *keysym != NoSymbol) { + if(ev->keycode == 0 && + ( (ic->private.local.composed != NULL) + ||(ic->private.local.brl_committed != 0))) { + if (ic->private.local.brl_committed != 0) { /* Braille Event */ + unsigned char pattern = ic->private.local.brl_committed; + char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)]; + ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern); + if(ret > bytes) { + if(status) *status = XBufferOverflow; + return(ret); + } + if(keysym) { + *keysym = XK_braille_blank | pattern; if(status) *status = XLookupBoth; - } else { + } else if(status) *status = XLookupChars; + memcpy(buffer, mb, ret); + } else { /* Composed Event */ + ret = strlen(ic->private.local.composed->mb); + if(ret > bytes) { + if(status) *status = XBufferOverflow; + return(ret); } - } else { - if(keysym && *keysym != NoSymbol) { - if(status) *status = XLookupKeySym; + memcpy(buffer, ic->private.local.composed->mb, ret); + if(keysym) *keysym = ic->private.local.composed->ks; + if (ret > 0) { + if (keysym && *keysym != NoSymbol) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } } else { - if(status) *status = XLookupNone; + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } } } return (ret); @@ -119,26 +138,41 @@ _XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status) if(status) *status = XLookupNone; return(0); } - if(ev->keycode == 0) { /* Composed Event */ - ret = _Xwcslen(ic->private.local.composed->wc); - if(ret > wlen) { - if(status) *status = XBufferOverflow; - return (ret); - } - memcpy((char *)buffer, (char *)ic->private.local.composed->wc, - ret * sizeof(wchar_t)); - if(keysym) *keysym = ic->private.local.composed->ks; - if (ret > 0) { - if (keysym && *keysym != NoSymbol) { + if(ev->keycode == 0) { + if (ic->private.local.brl_committed != 0) { /* Braille Event */ + unsigned char pattern = ic->private.local.brl_committed; + ret = 1; + if (ret > wlen) { + if(status) *status = XBufferOverflow; + return (ret); + } + *buffer = BRL_UC_ROW | pattern; + if(keysym) { + *keysym = XK_braille_blank | pattern; if(status) *status = XLookupBoth; - } else { + } else if(status) *status = XLookupChars; + } else { /* Composed Event */ + ret = _Xwcslen(ic->private.local.composed->wc); + if(ret > wlen) { + if(status) *status = XBufferOverflow; + return (ret); } - } else { - if(keysym && *keysym != NoSymbol) { - if(status) *status = XLookupKeySym; + memcpy((char *)buffer, (char *)ic->private.local.composed->wc, + ret * sizeof(wchar_t)); + if(keysym) *keysym = ic->private.local.composed->ks; + if (ret > 0) { + if (keysym && *keysym != NoSymbol) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } } else { - if(status) *status = XLookupNone; + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } } } return (ret); @@ -179,25 +213,37 @@ _XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status) if(status) *status = XLookupNone; return(0); } - if(ev->keycode == 0) { /* Composed Event */ - ret = strlen(ic->private.local.composed->utf8); - if(ret > bytes) { - if(status) *status = XBufferOverflow; - return (ret); - } - memcpy(buffer, ic->private.local.composed->utf8, ret); - if(keysym) *keysym = ic->private.local.composed->ks; - if (ret > 0) { - if (keysym && *keysym != NoSymbol) { - if(status) *status = XLookupBoth; - } else { - if(status) *status = XLookupChars; + if(ev->keycode == 0) { + if (ic->private.local.brl_committed != 0) { /* Braille Event */ + unsigned char pattern = ic->private.local.brl_committed; + ret = 3; + if (ret > bytes) { + if(status) *status = XBufferOverflow; + return (ret); } - } else { - if(keysym && *keysym != NoSymbol) { - if(status) *status = XLookupKeySym; + buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f); + buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6); + buffer[2] = 0x80 | (pattern & 0x3f); + } else { /* Composed Event */ + ret = strlen(ic->private.local.composed->utf8); + if(ret > bytes) { + if(status) *status = XBufferOverflow; + return (ret); + } + memcpy(buffer, ic->private.local.composed->utf8, ret); + if(keysym) *keysym = ic->private.local.composed->ks; + if (ret > 0) { + if (keysym && *keysym != NoSymbol) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } } else { - if(status) *status = XLookupNone; + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } } } return (ret); diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c index 7dbc385c..0ea4d11f 100644 --- a/modules/im/ximcp/imRm.c +++ b/modules/im/ximcp/imRm.c @@ -2702,7 +2702,7 @@ _XimEncodeLocalTopValue( if (flag) { _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window, - KeyPress, KeyPress, _XimLocalFilter, (XPointer)ic); + KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic); } } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) { if (ic->core.client_window) { @@ -2713,7 +2713,7 @@ _XimEncodeLocalTopValue( ic->core.focus_window = (Window)p->value; if (flag) { _XRegisterFilterByType(ic->core.im->core.display, - ic->core.focus_window, KeyPress, KeyPress, + ic->core.focus_window, KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic); } } else diff --git a/src/util/makekeys.c b/src/util/makekeys.c index 4f7a2234..214ea5c8 100644 --- a/src/util/makekeys.c +++ b/src/util/makekeys.c @@ -49,7 +49,7 @@ static struct info { KeySym val; } info[KTNUM]; -#define MIN_REHASH 10 +#define MIN_REHASH 15 #define MATCHES 10 char tab[KTNUM]; diff --git a/src/xlibi18n/Ximint.h b/src/xlibi18n/Ximint.h index e9bdda24..c0d1fcbc 100644 --- a/src/xlibi18n/Ximint.h +++ b/src/xlibi18n/Ximint.h @@ -180,6 +180,8 @@ typedef struct _XimDefICValues { #define XIM_FALSE False #define XIM_OVERFLOW (-1) +#define BRL_UC_ROW 0x2800 + /* * Global symbols */ diff --git a/src/xlibi18n/XimintL.h b/src/xlibi18n/XimintL.h index 2d4f6a9e..1036a62b 100644 --- a/src/xlibi18n/XimintL.h +++ b/src/xlibi18n/XimintL.h @@ -84,5 +84,8 @@ typedef struct _XicLocalPrivateRec { XIMResourceList ic_resources; unsigned int ic_num_resources; + + unsigned char brl_pressed, brl_committing, brl_committed; + Time brl_release_start; } XicLocalPrivateRec; #endif /* _XIMINTL_H */ |