|
From: Ian P. <piu...@us...> - 2003-09-16 07:55:10
|
Update of /cvsroot/squeak/squeak/platforms/unix/vm-display-X11 In directory sc8-pr-cvs1:/tmp/cvs-serv25305 Modified Files: sqUnixX11.c Log Message: Fix browserPipes init. Add input method support for dead keys. Add -nointl option. Index: sqUnixX11.c =================================================================== RCS file: /cvsroot/squeak/squeak/platforms/unix/vm-display-X11/sqUnixX11.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sqUnixX11.c 1 Sep 2003 08:13:31 -0000 1.11 --- sqUnixX11.c 16 Sep 2003 07:55:04 -0000 1.12 *************** *** 37,41 **** /* Author: Ian Piumarta <ian...@in...> * ! * Last edited: 2003-08-30 11:47:06 by piumarta on emilia.inria.fr * * Support for more intelligent CLIPBOARD selection handling contributed by: --- 37,41 ---- /* Author: Ian Piumarta <ian...@in...> * ! * Last edited: 2003-09-16 06:53:35 by piumarta on emilia.inria.fr * * Support for more intelligent CLIPBOARD selection handling contributed by: *************** *** 83,86 **** --- 83,87 ---- #undef FULL_UPDATE_ON_EXPOSE + #undef DEBUG_CONV #undef DEBUG_EVENTS #undef DEBUG_SELECTIONS *************** *** 103,106 **** --- 104,108 ---- #include <signal.h> #include <fcntl.h> + #include <locale.h> #if defined(HAVE_SYS_SELECT_H) *************** *** 215,218 **** --- 217,227 ---- int headless= 0; + typedef int (*x2sqKey_t)(XKeyEvent *xevt); + + static int x2sqKeyPlain(XKeyEvent *xevt); + static int x2sqKeyInput(XKeyEvent *xevt); + + static x2sqKey_t x2sqKey= x2sqKeyPlain; + #define inBrowser() (-1 != browserPipes[0]) *************** *** 1009,1013 **** ! static int x2sqKey(XKeyEvent *xevt) { unsigned char buf[32]; --- 1018,1150 ---- ! int recode(int charCode) ! { ! if (charCode >= 128) ! { ! unsigned char buf[32]; ! unsigned char out[32]; ! buf[0]= charCode; ! if (convertChars((char *)buf, 1, uxXWinEncoding, ! (char *)out, sizeof(out), ! sqTextEncoding, 0, 1)) ! charCode= out[0]; ! # if defined(DEBUG_EVENTS) ! fprintf(stderr, " 8-bit: %d=%02x [%c->%c]\n", charCode, charCode, ! (char *)uxXWinEncoding, (char *)sqTextEncoding); ! # endif ! } ! return charCode; ! } ! ! ! static int x2sqKeyInput(XKeyEvent *xevt) ! { ! static int initialised= 0; ! static XIM im= 0; ! static XIC ic= 0; ! static int lastKey= -1; ! ! if (!initialised) ! { ! initialised= 1; ! if (!setlocale(LC_CTYPE, "")) ! { ! fprintf(stderr, "setlocale() failed\n"); ! goto revertInput; ! } ! if (!(im= XOpenIM(stDisplay, 0, 0, 0))) ! { ! fprintf(stderr, "XOpenIM() failed\n"); ! goto revertInput; ! } ! else ! { ! if (!(ic= XCreateIC(im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, ! XNClientWindow, stWindow, 0))) ! { ! fprintf(stderr, "XCreateIC() failed\n"); ! goto revertInput; ! } ! else ! { ! unsigned int mask; ! XWindowAttributes xwa; ! XGetWindowAttributes(stDisplay, stWindow, &xwa); ! XGetICValues(ic, XNFilterEvents, &mask, NULL); ! mask |= xwa.your_event_mask; ! XSelectInput(stDisplay, stWindow, mask); ! } ! } ! } ! ! if (KeyPress != xevt->type) ! { ! int key= lastKey; ! lastKey= -1;; ! return key; ! } ! ! #if defined(DEBUG_CONV) ! printf("keycode %u\n", xevt->keycode); ! #endif ! ! { ! unsigned char string[128]; /* way too much */ ! KeySym symbolic; ! Status status; ! int count= XmbLookupString(ic, (XKeyPressedEvent *)xevt, ! string, sizeof(string), &symbolic, &status); ! switch (status) ! { ! case XLookupNone: /* still composing */ ! # if defined(DEBUG_CONV) ! fprintf(stderr, "x2sqKey XLookupNone\n"); ! # endif ! return -1; ! ! case XLookupChars: ! # if defined(DEBUG_CONV) ! fprintf(stderr, "x2sqKey XLookupChars count %d\n", count); ! # endif ! case XLookupBoth: ! # if defined(DEBUG_CONV) ! fprintf(stderr, "x2sqKey XLookupBoth count %d\n", count); ! # endif ! lastKey= (count ? recode(string[0]) : -1); ! # if defined(DEBUG_CONV) ! fprintf(stderr, "x2sqKey == %d\n", lastKey); ! # endif ! return lastKey; ! ! case XLookupKeySym: ! # if defined(DEBUG_CONV) ! fprintf(stderr, "x2sqKey XLookupKeySym\n"); ! # endif ! { ! int charCode= translateCode(symbolic); ! # if defined(DEBUG_CONV) ! printf("SYM %d -> %d\n", symbolic, charCode); ! # endif ! if (charCode < 0) ! return -1; /* unknown key */ ! if ((charCode == 127) && mapDelBs) ! charCode= 8; ! return lastKey= charCode; ! } ! ! default: ! fprintf(stderr, "this cannot happen\n"); ! return lastKey= -1; ! } ! return lastKey= -1; ! } ! ! revertInput: ! x2sqKey= x2sqKeyPlain; ! return x2sqKey(xevt); ! } ! ! ! static int x2sqKeyPlain(XKeyEvent *xevt) { unsigned char buf[32]; *************** *** 1028,1045 **** charCode &= 0xff; } ! if (charCode >= 128) ! { ! unsigned char out[32]; ! ! buf[0]= charCode; ! if (convertChars((char *)buf, 1, uxXWinEncoding, (char *)out, sizeof(out), sqTextEncoding, 0, 1)) ! charCode= out[0]; ! # if defined(DEBUG_EVENTS) ! fprintf(stderr, " 8-bit: %d=%02x [%s->%s]\n", charCode, charCode, (char *)uxXWinEncoding, (char *)sqTextEncoding); ! # endif ! } ! return charCode; } static int x2sqButton(int button) { --- 1165,1172 ---- charCode &= 0xff; } ! return recode(charCode); } + static int x2sqButton(int button) { *************** *** 1140,1143 **** --- 1267,1273 ---- } + if (True == XFilterEvent(evt, 0)) + return; + switch (evt->type) { *************** *** 4138,4141 **** --- 4268,4272 ---- printf(" -lazy go to sleep when main window unmapped\n"); printf(" -mapdelbs map Delete key onto Backspace\n"); + printf(" -nointl disable international keyboard support\n"); printf(" -notitle disable the Squeak window title bar\n"); printf(" -optmod <n> map Mod<n> to the Option key\n"); *************** *** 4156,4161 **** --- 4287,4296 ---- char *ev= 0; + if (getenv("LC_CTYPE") || getenv("LC_ALL")) + x2sqKey= x2sqKeyInput; + if (getenv("SQUEAK_LAZY")) sleepWhenUnmapped= 1; if (getenv("SQUEAK_SPY")) withSpy= 1; + if (getenv("SQUEAK_NOINTL")) x2sqKey= x2sqKeyPlain; if (getenv("SQUEAK_NOTITLE")) noTitle= 1; if (getenv("SQUEAK_FULLSCREEN")) fullScreen= 1; *************** *** 4189,4192 **** --- 4324,4328 ---- else if (!strcmp(arg, "-fullscreen")) fullScreen= 1; else if (!strcmp(arg, "-iconic")) iconified= 1; + else if (!strcmp(arg, "-nointl")) x2sqKey= x2sqKeyPlain; else if (argv[1]) /* option requires an argument */ { *************** *** 4208,4212 **** if (!argv[2]) return 0; sscanf(argv[1], "%i", &browserPipes[0]); ! sscanf(argv[1], "%i", &browserPipes[1]); /* receive browserWindow */ # if defined(DEBUG_BROWSER) --- 4344,4348 ---- if (!argv[2]) return 0; sscanf(argv[1], "%i", &browserPipes[0]); ! sscanf(argv[2], "%i", &browserPipes[1]); /* receive browserWindow */ # if defined(DEBUG_BROWSER) *************** *** 4220,4224 **** } # if defined(DEBUG_BROWSER) ! fprintf(stderr, "browser: window = 0x%x\n" browserWindow); # endif return 3; --- 4356,4360 ---- } # if defined(DEBUG_BROWSER) ! fprintf(stderr, "browser: window = 0x%x\n", browserWindow); # endif return 3; |