Commit 6a7c131d authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winemac: Return the caret position in query_ime_char_rect.

And drop the ime_query_char_rect driver user callback.
parent c6da1739
......@@ -374,7 +374,6 @@ static const kernel_callback kernel_callbacks[] =
macdrv_dnd_query_drag,
macdrv_dnd_query_drop,
macdrv_dnd_query_exited,
macdrv_ime_query_char_rect,
};
C_ASSERT(NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last);
......
......@@ -401,25 +401,21 @@ BOOL query_ime_char_rect(macdrv_query* query)
HWND hwnd = macdrv_get_window_hwnd(query->window);
void *himc = query->ime_char_rect.himc;
CFRange *range = &query->ime_char_rect.range;
CGRect *rect = &query->ime_char_rect.rect;
struct ime_query_char_rect_result result = { .location = 0 };
struct ime_query_char_rect_params params;
BOOL ret;
GUITHREADINFO info = {.cbSize = sizeof(info)};
BOOL ret = FALSE;
TRACE_(imm)("win %p/%p himc %p range %ld-%ld\n", hwnd, query->window, himc, range->location,
range->length);
params.hwnd = HandleToUlong(hwnd);
params.himc = (UINT_PTR)himc;
params.result = (UINT_PTR)&result;
params.location = range->location;
params.length = range->length;
ret = macdrv_client_func(client_func_ime_query_char_rect, &params, sizeof(params));
*range = CFRangeMake(result.location, result.length);
*rect = cgrect_from_rect(result.rect);
if (NtUserGetGUIThreadInfo(0, &info))
{
NtUserMapWindowPoints(info.hwndCaret, 0, (POINT*)&info.rcCaret, 2);
if (range->length && info.rcCaret.left == info.rcCaret.right) info.rcCaret.right++;
query->ime_char_rect.rect = cgrect_from_rect(info.rcCaret);
}
TRACE_(imm)(" -> %s range %ld-%ld rect %s\n", ret ? "TRUE" : "FALSE", range->location,
range->length, wine_dbgstr_cgrect(*rect));
range->length, wine_dbgstr_cgrect(query->ime_char_rect.rect));
return ret;
}
......
......@@ -46,47 +46,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm);
static HIMC *hSelectedFrom = NULL;
static INT hSelectedCount = 0;
static WCHAR *input_context_get_comp_str( INPUTCONTEXT *ctx, BOOL result, UINT *length )
{
COMPOSITIONSTRING *string;
WCHAR *text = NULL;
UINT len, off;
if (!(string = ImmLockIMCC( ctx->hCompStr ))) return NULL;
len = result ? string->dwResultStrLen : string->dwCompStrLen;
off = result ? string->dwResultStrOffset : string->dwCompStrOffset;
if (len && off && (text = malloc( (len + 1) * sizeof(WCHAR) )))
{
memcpy( text, (BYTE *)string + off, len * sizeof(WCHAR) );
text[len] = 0;
*length = len;
}
ImmUnlockIMCC( ctx->hCompStr );
return text;
}
static HWND input_context_get_ui_hwnd( INPUTCONTEXT *ctx )
{
struct ime_private *priv;
HWND hwnd;
if (!(priv = ImmLockIMCC( ctx->hPrivate ))) return NULL;
hwnd = priv->hwndDefault;
ImmUnlockIMCC( ctx->hPrivate );
return hwnd;
}
static HFONT input_context_select_ui_font( INPUTCONTEXT *ctx, HDC hdc )
{
struct ime_private *priv;
HFONT font = NULL;
if (!(priv = ImmLockIMCC( ctx->hPrivate ))) return NULL;
if (priv->textfont) font = SelectObject( hdc, priv->textfont );
ImmUnlockIMCC( ctx->hPrivate );
return font;
}
static HIMC RealIMC(HIMC hIMC)
{
if (hIMC == FROM_MACDRV)
......@@ -216,109 +175,3 @@ BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)
return TRUE;
}
/* Interfaces to other parts of the Mac driver */
/**************************************************************************
* macdrv_ime_query_char_rect
*/
NTSTATUS WINAPI macdrv_ime_query_char_rect(void *arg, ULONG size)
{
struct ime_query_char_rect_params *params = arg;
struct ime_query_char_rect_result *result = param_ptr(params->result);
void *himc = param_ptr(params->himc);
IMECHARPOSITION charpos;
BOOL ret = FALSE;
result->location = params->location;
result->length = params->length;
if (!himc) himc = RealIMC(FROM_MACDRV);
charpos.dwSize = sizeof(charpos);
charpos.dwCharPos = params->location;
if (ImmRequestMessageW(himc, IMR_QUERYCHARPOSITION, (ULONG_PTR)&charpos))
{
int i;
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 < params->length; i++)
{
charpos.dwSize = sizeof(charpos);
charpos.dwCharPos = params->location + i;
if (!ImmRequestMessageW(himc, IMR_QUERYCHARPOSITION, (ULONG_PTR)&charpos) ||
charpos.pt.y != result->rect.top)
{
result->length = i;
break;
}
result->rect.right = charpos.pt.x;
}
ret = TRUE;
}
if (!ret)
{
LPINPUTCONTEXT ic = ImmLockIMC(himc);
if (ic)
{
WCHAR *str;
HWND hwnd;
UINT len;
if ((hwnd = input_context_get_ui_hwnd( ic )) && IsWindowVisible( hwnd ) &&
(str = input_context_get_comp_str( ic, FALSE, &len )))
{
HDC dc = GetDC( hwnd );
HFONT font = input_context_select_ui_font( ic, dc );
SIZE size;
if (result->location > len) result->location = len;
if (result->location + result->length > len) result->length = len - result->location;
GetTextExtentPoint32W( dc, str, result->location, &size );
charpos.rcDocument.left = size.cx;
charpos.rcDocument.top = 0;
GetTextExtentPoint32W( dc, str, result->location + result->length, &size );
charpos.rcDocument.right = size.cx;
charpos.rcDocument.bottom = size.cy;
if (ic->cfCompForm.dwStyle == CFS_DEFAULT)
OffsetRect(&charpos.rcDocument, 10, 10);
LPtoDP(dc, (POINT*)&charpos.rcDocument, 2);
MapWindowPoints( hwnd, 0, (POINT *)&charpos.rcDocument, 2 );
result->rect = charpos.rcDocument;
ret = TRUE;
if (font) SelectObject( dc, font );
ReleaseDC( hwnd, dc );
free( str );
}
}
ImmUnlockIMC(himc);
}
if (!ret)
{
GUITHREADINFO gti;
gti.cbSize = sizeof(gti);
if (GetGUIThreadInfo(0, &gti))
{
MapWindowPoints(gti.hwndCaret, 0, (POINT*)&gti.rcCaret, 2);
result->rect = gti.rcCaret;
ret = TRUE;
}
}
if (ret && result->length && result->rect.left == result->rect.right)
result->rect.right++;
return ret;
}
......@@ -31,8 +31,6 @@ extern NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) DECLSPEC_HID
extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECLSPEC_HIDDEN;
extern HMODULE macdrv_module DECLSPEC_HIDDEN;
#endif /* __WINE_MACDRV_DLL_H */
......@@ -91,7 +91,6 @@ enum macdrv_client_funcs
client_func_dnd_query_drag,
client_func_dnd_query_drop,
client_func_dnd_query_exited,
client_func_ime_query_char_rect,
client_func_last
};
......@@ -149,24 +148,6 @@ struct dnd_query_exited_params
UINT32 hwnd;
};
/* 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
{
UINT32 hwnd;
UINT32 location;
UINT32 himc;
UINT64 result; /* FIXME: Use NtCallbackReturn instead */
UINT32 length;
};
static inline void *param_ptr(UINT64 param)
{
return (void *)(UINT_PTR)param;
......
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