mirror of
https://github.com/reactos/wine.git
synced 2025-01-24 04:45:18 +00:00
macdrv: Rework the way we handle cursor position and composition text.
This commit is contained in:
parent
49dbf2464f
commit
c6d307533b
@ -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,6 +1009,17 @@ BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DW
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeSetCompositionString(HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen,
|
||||
LPCVOID lpRead, DWORD dwReadLen)
|
||||
{
|
||||
TRACE("(%p, %d, %p, %d, %p, %d):\n", hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
|
||||
|
||||
if (lpRead && dwReadLen)
|
||||
FIXME("Reading string unimplemented\n");
|
||||
|
||||
return IME_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, 0, FALSE);
|
||||
}
|
||||
|
||||
DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu,
|
||||
LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize)
|
||||
{
|
||||
@ -1011,38 +1028,6 @@ DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMEN
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void IME_SetCursorPos(void* hIMC, DWORD pos)
|
||||
{
|
||||
LPINPUTCONTEXT lpIMC;
|
||||
LPCOMPOSITIONSTRING compstr;
|
||||
|
||||
if (!hSelectedFrom)
|
||||
return;
|
||||
|
||||
lpIMC = LockRealIMC(hIMC);
|
||||
if (!lpIMC)
|
||||
return;
|
||||
|
||||
compstr = ImmLockIMCC(lpIMC->hCompStr);
|
||||
if (!compstr)
|
||||
{
|
||||
UnlockRealIMC(hIMC);
|
||||
return;
|
||||
}
|
||||
|
||||
compstr->dwCursorPos = pos;
|
||||
ImmUnlockIMCC(lpIMC->hCompStr);
|
||||
UnlockRealIMC(hIMC);
|
||||
GenerateIMEMessage(FROM_MACDRV, WM_IME_COMPOSITION, pos, GCS_CURSORPOS);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void IME_SetCompositionString(void* hIMC, LPCVOID lpComp, DWORD dwCompLen)
|
||||
{
|
||||
ImeSetCompositionString(hIMC, SCS_SETSTR, lpComp, dwCompLen, NULL, 0);
|
||||
}
|
||||
|
||||
static void IME_NotifyComplete(void* hIMC)
|
||||
{
|
||||
NotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
|
||||
@ -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,
|
||||
@ -206,13 +205,10 @@ typedef struct macdrv_event {
|
||||
struct {
|
||||
int activating;
|
||||
} 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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user