Commit c6d30753 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

macdrv: Rework the way we handle cursor position and composition text.

parent 49dbf246
......@@ -356,14 +356,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
event->im_set_text.data = [window imeData];
event->im_set_text.text = (CFStringRef)[[markedText string] copy];
event->im_set_text.complete = FALSE;
[[window queue] postEvent:event];
macdrv_release_event(event);
event = macdrv_create_event(IM_SET_CURSOR_POS, window);
event->im_set_cursor_pos.data = [window imeData];
event->im_set_cursor_pos.pos = markedTextSelection.location;
event->im_set_text.cursor_pos = markedTextSelection.location;
[[window queue] postEvent:event];
......
......@@ -35,7 +35,6 @@ static const char *dbgstr_event(int type)
"APP_DEACTIVATED",
"APP_QUIT_REQUESTED",
"DISPLAYS_CHANGED",
"IM_SET_CURSOR_POS",
"IM_SET_TEXT",
"KEY_PRESS",
"KEY_RELEASE",
......@@ -92,7 +91,6 @@ static macdrv_event_mask get_event_mask(DWORD mask)
event_mask |= event_mask_for_type(APP_DEACTIVATED);
event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
event_mask |= event_mask_for_type(DISPLAYS_CHANGED);
event_mask |= event_mask_for_type(IM_SET_CURSOR_POS);
event_mask |= event_mask_for_type(IM_SET_TEXT);
event_mask |= event_mask_for_type(STATUS_ITEM_CLICKED);
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
......@@ -181,9 +179,6 @@ void macdrv_handle_event(const macdrv_event *event)
case DISPLAYS_CHANGED:
macdrv_displays_changed(event);
break;
case IM_SET_CURSOR_POS:
macdrv_im_set_cursor_pos(event);
break;
case IM_SET_TEXT:
macdrv_im_set_text(event);
break;
......
......@@ -940,15 +940,14 @@ UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROCW lpfnEnumProc, LPCWSTR lpsz
return 0;
}
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
LPCVOID lpRead, DWORD dwReadLen)
static BOOL IME_SetCompositionString(void* hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, DWORD cursor_pos, BOOL cursor_valid)
{
LPINPUTCONTEXT lpIMC;
DWORD flags = 0;
WCHAR wParam = 0;
LPIMEPRIVATE myPrivate;
TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
TRACE("(%p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen);
/*
* Explanation:
......@@ -957,9 +956,6 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
* TODO: set the Cocoa window's marked text string and tell text input context
*/
if (lpRead && dwReadLen)
FIXME("Reading string unimplemented\n");
lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL)
......@@ -985,8 +981,8 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
wParam = ((const WCHAR*)lpComp)[0];
flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART;
wParam = ((const WCHAR*)lpComp)[0];
flags |= GCS_COMPCLAUSE | GCS_COMPATTR | GCS_DELTASTART;
}
else
{
......@@ -994,6 +990,16 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr;
}
if (cursor_valid)
{
LPCOMPOSITIONSTRING compstr;
compstr = ImmLockIMCC(lpIMC->hCompStr);
compstr->dwCursorPos = cursor_pos;
ImmUnlockIMCC(lpIMC->hCompStr);
flags |= GCS_CURSORPOS;
}
}
GenerateIMEMessage(hIMC, WM_IME_COMPOSITION, wParam, flags);
......@@ -1003,44 +1009,23 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
return TRUE;
}
DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize)
{
FIXME("(%p, %x %x %p %p %x): stub\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
static void IME_SetCursorPos(void* hIMC, DWORD pos)
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
LPCVOID lpRead, DWORD dwReadLen)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING compstr;
if (!hSelectedFrom)
return;
lpIMC = LockRealIMC(hIMC);
if (!lpIMC)
return;
TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
compstr = ImmLockIMCC(lpIMC->hCompStr);
if (!compstr)
{
UnlockRealIMC(hIMC);
return;
}
if (lpRead && dwReadLen)
FIXME("Reading string unimplemented\n");
compstr->dwCursorPos = pos;
ImmUnlockIMCC(lpIMC->hCompStr);
UnlockRealIMC(hIMC);
GenerateIMEMessage(FROM_MACDRV, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
return;
return IME_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, 0, FALSE);
}
static void IME_SetCompositionString(void* hIMC, LPCVOID lpComp, DWORD dwCompLen)
DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize)
{
ImeSetCompositionString(hIMC, SCS_SETSTR, lpComp, dwCompLen, NULL, 0);
FIXME("(%p, %x %x %p %p %x): stub\n", hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
static void IME_NotifyComplete(void* hIMC)
......@@ -1437,23 +1422,6 @@ void IME_RegisterClasses(HINSTANCE hImeInst)
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
}
/***********************************************************************
* macdrv_im_set_cursor_pos
*/
void macdrv_im_set_cursor_pos(const macdrv_event *event)
{
HWND hwnd = macdrv_get_window_hwnd(event->window);
void *himc = event->im_set_cursor_pos.data;
TRACE("win %p/%p himc %p pos %u\n", hwnd, event->window, himc, event->im_set_cursor_pos.pos);
if (!himc) himc = RealIMC(FROM_MACDRV);
IME_SetCursorPos(himc, event->im_set_cursor_pos.pos);
}
/***********************************************************************
* macdrv_im_set_text
*/
......@@ -1481,7 +1449,8 @@ void macdrv_im_set_text(const macdrv_event *event)
}
if (himc)
IME_SetCompositionString(himc, chars, length * sizeof(*chars));
IME_SetCompositionString(himc, SCS_SETSTR, chars, length * sizeof(*chars),
event->im_set_text.cursor_pos, !event->im_set_text.complete);
else
{
INPUT input;
......
......@@ -202,7 +202,6 @@ extern void IME_RegisterClasses(HINSTANCE hImeInst) DECLSPEC_HIDDEN;
extern BOOL macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *key_state,
void *himc) DECLSPEC_HIDDEN;
extern void macdrv_im_set_cursor_pos(const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_im_set_text(const macdrv_event *event) DECLSPEC_HIDDEN;
extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN;
......
......@@ -165,7 +165,6 @@ enum {
APP_DEACTIVATED,
APP_QUIT_REQUESTED,
DISPLAYS_CHANGED,
IM_SET_CURSOR_POS,
IM_SET_TEXT,
KEY_PRESS,
KEY_RELEASE,
......@@ -208,11 +207,8 @@ typedef struct macdrv_event {
} displays_changed;
struct {
void *data;
unsigned int pos;
} im_set_cursor_pos;
struct {
void *data;
CFStringRef text; /* new text or NULL if just completing existing text */
unsigned int cursor_pos;
unsigned int complete; /* is completing text? */
} im_set_text;
struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment