From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 1 + dlls/winemac.drv/event.c | 32 +++++++++++++++++++++++ dlls/winemac.drv/ime.c | 52 ++++++++++++++++++-------------------- dlls/winemac.drv/macdrv.h | 2 +- dlls/winemac.drv/unixlib.h | 21 ++++++++++++++- 5 files changed, 78 insertions(+), 30 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 27eda4d2ac8..d38e7cf9164 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -29,6 +29,7 @@ HMODULE macdrv_module = 0; typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_ime_query_char_rect, macdrv_ime_set_text, };
diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 68b66d610fe..43cd3f85bcd 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -179,6 +179,38 @@ static void macdrv_sent_text_input(const macdrv_event *event) }
+/************************************************************************** + * query_ime_char_rect + */ +BOOL query_ime_char_rect(macdrv_query* query) +{ + HWND hwnd = macdrv_get_window_hwnd(query->window); + void *himc = query->ime_char_rect.data; + CFRange *range = &query->ime_char_rect.range; + CGRect *rect = &query->ime_char_rect.rect; + struct ime_query_char_rect_result result = {0}; + struct ime_query_char_rect_params params; + BOOL ret; + + TRACE_(imm)("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location, + range->length); + + params.hwnd = hwnd; + params.data = himc; + params.result = &result; + params.location = range->location; + params.length = range->length; + ret = macdrv_client_func(client_func_ime_query_char_rect, ¶ms, sizeof(params)); + *range = CFRangeMake(result.location, result.length); + *rect = cgrect_from_rect(result.rect); + + TRACE_(imm)(" -> %s range %ld-%ld rect %s\n", ret ? "TRUE" : "FALSE", range->location, + range->length, wine_dbgstr_cgrect(*rect)); + + return ret; +} + + /*********************************************************************** * macdrv_query_event * diff --git a/dlls/winemac.drv/ime.c b/dlls/winemac.drv/ime.c index 2cf3aefb79d..251c22d5005 100644 --- a/dlls/winemac.drv/ime.c +++ b/dlls/winemac.drv/ime.c @@ -1438,43 +1438,42 @@ NTSTATUS WINAPI macdrv_ime_set_text(void *arg, ULONG size) }
/************************************************************************** - * query_ime_char_rect + * macdrv_ime_query_char_rect */ -BOOL query_ime_char_rect(macdrv_query* query) +NTSTATUS WINAPI macdrv_ime_query_char_rect(void *arg, ULONG size) { - HWND hwnd = macdrv_get_window_hwnd(query->window); - void *himc = query->ime_char_rect.data; - CFRange* range = &query->ime_char_rect.range; - CGRect* rect = &query->ime_char_rect.rect; + struct ime_query_char_rect_params *params = arg; + struct ime_query_char_rect_result *result = params->result; + void *himc = params->data; IMECHARPOSITION charpos; BOOL ret = FALSE;
- TRACE("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location, - range->length); + result->location = params->location; + result->length = params->length;
if (!himc) himc = RealIMC(FROM_MACDRV);
charpos.dwSize = sizeof(charpos); - charpos.dwCharPos = range->location; + charpos.dwCharPos = params->location; if (ImmRequestMessageW(himc, IMR_QUERYCHARPOSITION, (ULONG_PTR)&charpos)) { int i;
- *rect = CGRectMake(charpos.pt.x, charpos.pt.y, 0, charpos.cLineHeight); + SetRect(&result->rect, charpos.pt.x, charpos.pt.y, 0, charpos.pt.y + charpos.cLineHeight);
/* iterate over rest of length to extend rect */ - for (i = 1; i < range->length; i++) + for (i = 1; i < params->length; i++) { charpos.dwSize = sizeof(charpos); - charpos.dwCharPos = range->location + i; + charpos.dwCharPos = params->location + i; if (!ImmRequestMessageW(himc, IMR_QUERYCHARPOSITION, (ULONG_PTR)&charpos) || - charpos.pt.y != rect->origin.y) + charpos.pt.y != result->rect.top) { - range->length = i; + result->length = i; break; }
- rect->size.width = charpos.pt.x - rect->origin.x; + result->rect.right = charpos.pt.x; }
ret = TRUE; @@ -1501,15 +1500,15 @@ BOOL query_ime_char_rect(macdrv_query* query) if (private->textfont) oldfont = SelectObject(dc, private->textfont);
- if (range->location > compstr->dwCompStrLen) - range->location = compstr->dwCompStrLen; - if (range->location + range->length > compstr->dwCompStrLen) - range->length = compstr->dwCompStrLen - range->location; + if (result->location > compstr->dwCompStrLen) + result->location = compstr->dwCompStrLen; + if (result->location + result->length > compstr->dwCompStrLen) + result->length = compstr->dwCompStrLen - result->location;
- GetTextExtentPoint32W(dc, str, range->location, &size); + GetTextExtentPoint32W(dc, str, result->location, &size); charpos.rcDocument.left = size.cx; charpos.rcDocument.top = 0; - GetTextExtentPoint32W(dc, str, range->location + range->length, &size); + GetTextExtentPoint32W(dc, str, result->location + result->length, &size); charpos.rcDocument.right = size.cx; charpos.rcDocument.bottom = size.cy;
@@ -1518,7 +1517,7 @@ BOOL query_ime_char_rect(macdrv_query* query)
LPtoDP(dc, (POINT*)&charpos.rcDocument, 2); MapWindowPoints(private->hwndDefault, 0, (POINT*)&charpos.rcDocument, 2); - *rect = cgrect_from_rect(charpos.rcDocument); + result->rect = charpos.rcDocument; ret = TRUE;
if (oldfont) @@ -1540,16 +1539,13 @@ BOOL query_ime_char_rect(macdrv_query* query) if (GetGUIThreadInfo(0, >i)) { MapWindowPoints(gti.hwndCaret, 0, (POINT*)>i.rcCaret, 2); - *rect = cgrect_from_rect(gti.rcCaret); + result->rect = gti.rcCaret; ret = TRUE; } }
- if (ret && range->length && !rect->size.width) - rect->size.width = 1; - - TRACE(" -> %s range %ld-%ld rect %s\n", ret ? "TRUE" : "FALSE", range->location, - range->length, wine_dbgstr_cgrect(*rect)); + if (ret && result->length && result->rect.left == result->rect.right) + result->rect.right++;
return ret; } diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index c9fcf1dbf4b..de8384d5437 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -290,7 +290,7 @@ extern NTSTATUS macdrv_init(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_ime_process_text_input(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI macdrv_ime_set_text(void *params, ULONG size) DECLSPEC_HIDDEN; -extern BOOL query_ime_char_rect(macdrv_query* query) DECLSPEC_HIDDEN; +extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECLSPEC_HIDDEN;
/* unixlib interface */
diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index 20447f1f3b9..dd03cd4de95 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -66,10 +66,29 @@ struct notify_icon_params /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_ime_set_text = NtUserDriverCallbackFirst, + client_func_ime_query_char_rect = NtUserDriverCallbackFirst, + client_func_ime_set_text, client_func_last };
+/* macdrv_ime_query_char_rect result */ +struct ime_query_char_rect_result +{ + RECT rect; + UINT32 location; + UINT32 length; +}; + +/* macdrv_ime_query_char_rect params */ +struct ime_query_char_rect_params +{ + HWND hwnd; + void *data; + UINT32 location; + UINT32 length; + struct ime_query_char_rect_result *result; /* FIXME: Use NtCallbackReturn instead */ +}; + /* macdrv_ime_set_text params */ struct ime_set_text_params {