diff -u -r wine-20030408/controls/edit.c wine-20030408.new/controls/edit.c --- wine-20030408/controls/edit.c 2003-02-28 05:09:46.000000000 +0800 +++ wine-20030408.new/controls/edit.c 2003-04-15 10:48:04.000000000 +0800 @@ -57,6 +57,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(edit); WINE_DECLARE_DEBUG_CHANNEL(combo); WINE_DECLARE_DEBUG_CHANNEL(relay); +WINE_DECLARE_DEBUG_CHANNEL(xim); #define BUFLIMIT_MULTI 65534 /* maximum buffer size (not including '\0') FIXME: BTW, new specs say 65535 (do you dare ???) */ @@ -761,7 +762,8 @@ } } break; - + case WM_IME_CHAR: + unicode = TRUE; case WM_CHAR: { WCHAR charW; @@ -780,6 +782,7 @@ SendMessageW(GetParent(hwnd), WM_KEYDOWN, charW, 0); break; } + TRACE_(xim)("receive charW: %04x\n",charW); EDIT_WM_Char(es, charW); break; } diff -u -r wine-20030408/dlls/x11drv/clipboard.c wine-20030408.new/dlls/x11drv/clipboard.c --- wine-20030408/dlls/x11drv/clipboard.c 2003-01-24 05:32:35.000000000 +0800 +++ wine-20030408.new/dlls/x11drv/clipboard.c 2003-04-10 21:58:57.000000000 +0800 @@ -127,7 +127,7 @@ return 0; else if ( 0 == strncmp(itemFmtName, FMT_PREFIX, strlen(FMT_PREFIX)) ) return RegisterClipboardFormatA(itemFmtName + strlen(FMT_PREFIX)); - else if ( 0 == strcmp(itemFmtName, "STRING") ) + else if ( 0 == strcmp(itemFmtName, "STRING") || 0 == strcmp(itemFmtName, "text/plain")) return CF_UNICODETEXT; else if ( 0 == strcmp(itemFmtName, "PIXMAP") || 0 == strcmp(itemFmtName, "BITMAP") ) @@ -482,6 +482,7 @@ lpFormat->drvData = targetList[i]; TRACE("\tAtom# %d: '%s' --> FormatID(%d) %s\n", i, itemFmtName, wFormat, lpFormat->Name); + break; //Exit after getting the First recognized format } } @@ -544,7 +545,6 @@ } TRACE("\tretrieving %ld bytes...\n", itemSize * aformat/8); - lRequestLength = (itemSize * aformat/8)/4 + 1; bwc = aformat/8; /* we want to read the property, but not it too large of chunks or @@ -583,8 +583,10 @@ * Translate the X property into the appropriate Windows clipboard * format, if possible. */ - if ( (reqType == XA_STRING) - && (atype == XA_STRING) && (aformat == 8) ) + char *itemFmtName = TSXGetAtomName(display, atype); + if ( ( ((reqType == XA_STRING) && (atype == XA_STRING) ) + || strcmp(itemFmtName, "text/plain") == 0 ) + && (aformat == 8) ) /* convert Unix text to CF_UNICODETEXT */ { int i,inlcount = 0; diff -u -r wine-20030408/dlls/x11drv/event.c wine-20030408.new/dlls/x11drv/event.c --- wine-20030408/dlls/x11drv/event.c 2003-01-23 09:29:58.000000000 +0800 +++ wine-20030408.new/dlls/x11drv/event.c 2003-04-15 10:37:02.000000000 +0800 @@ -56,6 +56,8 @@ extern Atom dndProtocol; extern Atom dndSelection; +extern BOOL updatedXIMPos; + #define DndNotDnd -1 /* OffiX drag&drop */ #define DndUnknown 0 #define DndRawData 1 @@ -142,6 +144,39 @@ ignore = XFilterEvent( &event, None ); wine_tsx11_unlock(); if (!ignore) EVENT_ProcessEvent( &event ); + else{ // Support for OVERTHESPOT style of XIM (force keymap update) + if ( data->xim && event.type == KeyRelease && !updatedXIMPos){ + HWND hWnd; + wine_tsx11_lock(); + if (XFindContext( data->display, event.xany.window, winContext, (char **)&hWnd ) != 0) + hWnd = 0; // Not for a registered window + wine_tsx11_unlock(); + XIC xic = X11DRV_get_ic(hWnd); + if(xic){ + POINT p[1]; + XVaNestedList preedit_attr; + + GetCaretPos(&p[0]); + MapWindowPoints(GetFocus(),hWnd,p,1); + //ClientToScreen(hWnd, &p); + XPoint spot; + spot.x = p[0].x; + spot.y = p[0].y; + spot.y += 30; //FIXME: How to get the caret's height + preedit_attr = XVaCreateNestedList(0, + XNSpotLocation, &spot, + NULL); + XSetICValues(xic,XNPreeditAttributes,preedit_attr,NULL); + // use this variable to check whether we need to update XIM position + updatedXIMPos = TRUE; + + //force wine to update keymap + XKeymapEvent forceUpdateKeymap; + XQueryKeymap(data->display, forceUpdateKeymap.key_vector); + X11DRV_KeymapNotify(hWnd, &forceUpdateKeymap); + } + } + } count++; wine_tsx11_lock(); } @@ -610,6 +645,10 @@ } if (!bExists) { + /* Add COMPOUND_TEXT prop for STRING additionally */ + if (prop == XA_STRING) + targets[cTargets++] = TSXInternAtom(display, "COMPOUND_TEXT", False); + targets[cTargets++] = prop; /* Add PIXMAP prop for bitmaps additionally */ @@ -1007,6 +1046,7 @@ Atom xaClipboard = TSXInternAtom(display, "CLIPBOARD", False); Atom xaTargets = TSXInternAtom(display, "TARGETS", False); Atom xaMultiple = TSXInternAtom(display, "MULTIPLE", False); + Atom xaCompoud = TSXInternAtom(display, "COMPOUND_TEXT", True); /* * We can only handle the selection request if : @@ -1038,7 +1078,7 @@ /* MULTIPLE selection request */ rprop = EVENT_SelectionRequest_MULTIPLE( hWnd, event ); } - else if(event->target == XA_STRING) /* treat CF_TEXT as Unix text */ + else if(event->target == XA_STRING || event->target == xaCompoud) /* treat CF_TEXT as Unix text */ { /* XA_STRING selection request */ rprop = EVENT_SelectionRequest_STRING( display, request, event->target, rprop ); diff -u -r wine-20030408/dlls/x11drv/keyboard.c wine-20030408.new/dlls/x11drv/keyboard.c --- wine-20030408/dlls/x11drv/keyboard.c 2003-03-24 04:07:55.000000000 +0800 +++ wine-20030408.new/dlls/x11drv/keyboard.c 2003-04-15 10:44:42.000000000 +0800 @@ -51,6 +51,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(keyboard); WINE_DECLARE_DEBUG_CHANNEL(key); WINE_DECLARE_DEBUG_CHANNEL(dinput); +WINE_DECLARE_DEBUG_CHANNEL(xim); int min_keycode, max_keycode, keysyms_per_keycode; WORD keyc2vkey[256], keyc2scan[256]; @@ -61,6 +62,8 @@ static char KEYBOARD_MapDeadKeysym(KeySym keysym); +BOOL updatedXIMPos = FALSE; + /* Keyboard translation tables */ #define MAIN_LEN 49 static const WORD main_key_scan_qwerty[MAIN_LEN] = @@ -976,6 +979,85 @@ KEYBOARD_UpdateOneState( VK_SHIFT, shift, time ); } +#define NALLOC 64 +static BOOL XIM_KeyEvent(XIC xic, HWND hwnd, XKeyEvent *event) +{ + BOOL done = FALSE; + + TRACE_(xim)("hwnd %04x \n", (unsigned int) hwnd); + + if (event->type == KeyPress) + { + KeySym keysym; + Status status; + int i, nbyte; + DWORD dwOutput; + WCHAR wcOutput[NALLOC]; + LPSTR bytes; + DWORD nalloc = NALLOC; + updatedXIMPos = FALSE; + bytes = HeapAlloc(GetProcessHeap(),0,NALLOC); + + nbyte = XmbLookupString(xic, event, bytes, nalloc, &keysym, &status); + TRACE_(xim)("nbyte = %d, status = 0x%x\n", nbyte, status); + + if (status == XBufferOverflow) + { + nalloc = nbyte; + bytes = HeapReAlloc(GetProcessHeap(), 0, bytes, nbyte); + nbyte = XmbLookupString(xic, event, bytes, nalloc, &keysym, &status); + TRACE_(xim)("nbyte = %d, status = 0x%x\n", nbyte, status); + } + + switch (status) + { + case XLookupBoth: + if (keysym < 128 || (keysym & 0xff00) == 0xff00) + { + TRACE_(xim)("keysym = 0x%x\n", (int)keysym); + break; /* Leave to the default handler */ + } + /* fall through */ + case XLookupChars: + { + INT codepage = GetACP(); + if (codepage == 932) + { + /* + * Japanese is encoded with windows as SJIS (932) however + * Under unix we use EUS (20932) So we need to translate + * the input as 20932... + */ + dwOutput = MultiByteToWideChar(20932, + 0, bytes, nbyte, wcOutput, sizeof(wcOutput)); + } + else + dwOutput = MultiByteToWideChar(codepage, + 0, bytes, nbyte, wcOutput, sizeof(wcOutput)); + + for(i=0; ikeycode=(event->keycode & 0xff); wine_tsx11_lock(); - if (xic) - ascii_chars = XmbLookupString(xic, event, Str, sizeof(Str), &keysym, NULL); - else + if (xic && XIM_KeyEvent(xic, GetFocus(), event)){ + return; + }else ascii_chars = XLookupString(event, Str, sizeof(Str), &keysym, NULL); wine_tsx11_unlock(); Only in wine-20030408.new/dlls/x11drv: keyboard.c.ok diff -u -r wine-20030408/dlls/x11drv/window.c wine-20030408.new/dlls/x11drv/window.c --- wine-20030408/dlls/x11drv/window.c 2003-01-30 09:07:43.000000000 +0800 +++ wine-20030408.new/dlls/x11drv/window.c 2003-04-10 21:58:57.000000000 +0800 @@ -65,6 +65,8 @@ static LPCSTR client_window_atom; static LPCSTR icon_window_atom; +XFontSet ximFontSet; + /*********************************************************************** * is_window_managed * @@ -691,11 +693,24 @@ if (is_top_level) { XIM xim = x11drv_thread_data()->xim; - if (xim) data->xic = XCreateIC( xim, - XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, data->whole_window, - XNFocusWindow, data->whole_window, - 0 ); + if (xim){ // OVERTHESPOT STYLE support + XPoint spot = {0,0}; + char * FontSet = "*-r-*"; + char **missing_charsets; + int count; + ximFontSet = XCreateFontSet(display, FontSet, &missing_charsets, &count, NULL); + XFreeStringList (missing_charsets); + XVaNestedList preedit = XVaCreateNestedList(0, + XNFontSet, ximFontSet, + XNSpotLocation, &spot, + NULL); + data->xic = XCreateIC( xim, + XNInputStyle, XIMPreeditPosition | XIMStatusNothing, + XNClientWindow, root_window, + XNFocusWindow, data->whole_window, + XNPreeditAttributes, preedit, + 0 ); + } } /* non-maximized child must be at bottom of Z order */