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) ...@@ -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.data = [window imeData];
event->im_set_text.text = (CFStringRef)[[markedText string] copy]; event->im_set_text.text = (CFStringRef)[[markedText string] copy];
event->im_set_text.complete = FALSE; event->im_set_text.complete = FALSE;
event->im_set_text.cursor_pos = markedTextSelection.location;
[[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;
[[window queue] postEvent:event]; [[window queue] postEvent:event];
......
...@@ -35,7 +35,6 @@ static const char *dbgstr_event(int type) ...@@ -35,7 +35,6 @@ static const char *dbgstr_event(int type)
"APP_DEACTIVATED", "APP_DEACTIVATED",
"APP_QUIT_REQUESTED", "APP_QUIT_REQUESTED",
"DISPLAYS_CHANGED", "DISPLAYS_CHANGED",
"IM_SET_CURSOR_POS",
"IM_SET_TEXT", "IM_SET_TEXT",
"KEY_PRESS", "KEY_PRESS",
"KEY_RELEASE", "KEY_RELEASE",
...@@ -92,7 +91,6 @@ static macdrv_event_mask get_event_mask(DWORD mask) ...@@ -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_DEACTIVATED);
event_mask |= event_mask_for_type(APP_QUIT_REQUESTED); event_mask |= event_mask_for_type(APP_QUIT_REQUESTED);
event_mask |= event_mask_for_type(DISPLAYS_CHANGED); 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(IM_SET_TEXT);
event_mask |= event_mask_for_type(STATUS_ITEM_CLICKED); event_mask |= event_mask_for_type(STATUS_ITEM_CLICKED);
event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED); event_mask |= event_mask_for_type(WINDOW_CLOSE_REQUESTED);
...@@ -181,9 +179,6 @@ void macdrv_handle_event(const macdrv_event *event) ...@@ -181,9 +179,6 @@ void macdrv_handle_event(const macdrv_event *event)
case DISPLAYS_CHANGED: case DISPLAYS_CHANGED:
macdrv_displays_changed(event); macdrv_displays_changed(event);
break; break;
case IM_SET_CURSOR_POS:
macdrv_im_set_cursor_pos(event);
break;
case IM_SET_TEXT: case IM_SET_TEXT:
macdrv_im_set_text(event); macdrv_im_set_text(event);
break; break;
......
...@@ -940,15 +940,14 @@ UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROCW lpfnEnumProc, LPCWSTR lpsz ...@@ -940,15 +940,14 @@ UINT WINAPI ImeEnumRegisterWord(REGISTERWORDENUMPROCW lpfnEnumProc, LPCWSTR lpsz
return 0; return 0;
} }
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, static BOOL IME_SetCompositionString(void* hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, DWORD cursor_pos, BOOL cursor_valid)
LPCVOID lpRead, DWORD dwReadLen)
{ {
LPINPUTCONTEXT lpIMC; LPINPUTCONTEXT lpIMC;
DWORD flags = 0; DWORD flags = 0;
WCHAR wParam = 0; WCHAR wParam = 0;
LPIMEPRIVATE myPrivate; 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: * Explanation:
...@@ -957,9 +956,6 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW ...@@ -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 * 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); lpIMC = LockRealIMC(hIMC);
if (lpIMC == NULL) if (lpIMC == NULL)
...@@ -994,6 +990,16 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW ...@@ -994,6 +990,16 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
ImmDestroyIMCC(lpIMC->hCompStr); ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = newCompStr; 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); GenerateIMEMessage(hIMC, WM_IME_COMPOSITION, wParam, flags);
...@@ -1003,44 +1009,23 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW ...@@ -1003,44 +1009,23 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
return TRUE; return TRUE;
} }
DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize) LPCVOID lpRead, DWORD dwReadLen)
{
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)
{ {
LPINPUTCONTEXT lpIMC; TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
LPCOMPOSITIONSTRING compstr;
if (!hSelectedFrom)
return;
lpIMC = LockRealIMC(hIMC);
if (!lpIMC)
return;
compstr = ImmLockIMCC(lpIMC->hCompStr); if (lpRead && dwReadLen)
if (!compstr) FIXME("Reading string unimplemented\n");
{
UnlockRealIMC(hIMC);
return;
}
compstr->dwCursorPos = pos; return IME_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, 0, FALSE);
ImmUnlockIMCC(lpIMC->hCompStr);
UnlockRealIMC(hIMC);
GenerateIMEMessage(FROM_MACDRV, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
return;
} }
DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
static void IME_SetCompositionString(void* hIMC, LPCVOID lpComp, DWORD dwCompLen) 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) static void IME_NotifyComplete(void* hIMC)
...@@ -1437,23 +1422,6 @@ void IME_RegisterClasses(HINSTANCE hImeInst) ...@@ -1437,23 +1422,6 @@ void IME_RegisterClasses(HINSTANCE hImeInst)
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); 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 * macdrv_im_set_text
*/ */
...@@ -1481,7 +1449,8 @@ void macdrv_im_set_text(const macdrv_event *event) ...@@ -1481,7 +1449,8 @@ void macdrv_im_set_text(const macdrv_event *event)
} }
if (himc) 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 else
{ {
INPUT input; INPUT input;
......
...@@ -202,7 +202,6 @@ extern void IME_RegisterClasses(HINSTANCE hImeInst) DECLSPEC_HIDDEN; ...@@ -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, extern BOOL macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *key_state,
void *himc) DECLSPEC_HIDDEN; 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 void macdrv_im_set_text(const macdrv_event *event) DECLSPEC_HIDDEN;
extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN; extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN;
......
...@@ -165,7 +165,6 @@ enum { ...@@ -165,7 +165,6 @@ enum {
APP_DEACTIVATED, APP_DEACTIVATED,
APP_QUIT_REQUESTED, APP_QUIT_REQUESTED,
DISPLAYS_CHANGED, DISPLAYS_CHANGED,
IM_SET_CURSOR_POS,
IM_SET_TEXT, IM_SET_TEXT,
KEY_PRESS, KEY_PRESS,
KEY_RELEASE, KEY_RELEASE,
...@@ -208,11 +207,8 @@ typedef struct macdrv_event { ...@@ -208,11 +207,8 @@ typedef struct macdrv_event {
} displays_changed; } displays_changed;
struct { struct {
void *data; void *data;
unsigned int pos;
} im_set_cursor_pos;
struct {
void *data;
CFStringRef text; /* new text or NULL if just completing existing text */ CFStringRef text; /* new text or NULL if just completing existing text */
unsigned int cursor_pos;
unsigned int complete; /* is completing text? */ unsigned int complete; /* is completing text? */
} im_set_text; } im_set_text;
struct { 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